Remove double htmlspecialchars
[aur.git] / scripts / uploadbuckets.sh
blob32526926658f9a4c1d31ccb302aea3d1e749793a
1 #!/bin/bash
3 DRYRUN=${DRYRUN:-1}
5 source="$1"
6 dest="$2"
8 if [[ -z $source || -z $dest ]]; then
9 echo 'usage: uploadbuckets.sh <source> <dest>'
10 echo 'Script runs in DRYRUN mode by default.'
11 echo 'To run for real, set DRYRUN=0 in your environment.'
12 exit 1
15 if [[ ! -d $source ]]; then
16 echo 'error: source is not a directory'
17 exit 1
20 if [[ -e $dest && ! -d $dest ]]; then
21 echo 'error: dest is not a directory'
22 exit 1
25 if [[ $(readlink -e $dest) = $(readlink -e $source) ]]; then
26 echo 'error: source and dest cannot be the same. Rotate the result'
27 echo 'into place once the migration is complete.'
28 exit 1
31 if [[ ! -d $dest ]]; then
32 mkdir $dest
35 shopt -s nullglob
37 for package in "$source"/*; do
38 pkgname="${package##*/}"
39 newfolder="$dest/${pkgname:0:2}"
40 if [[ ! -d "$newfolder" ]]; then
41 if [[ $DRYRUN -gt 0 ]]; then
42 echo mkdir -p "$newfolder"
43 else
44 mkdir -p "$newfolder"
47 if [[ $DRYRUN -gt 0 ]]; then
48 echo mv "$source/$pkgname" "$newfolder/$pkgname"
49 else
50 mv "$source/$pkgname" "$newfolder/$pkgname"
52 done
54 if [[ $DRYRUN -gt 0 ]]; then
55 echo
56 echo 'DRYRUN mode was enabled.'
57 echo 'To run for real, set DRYRUN=0 in your environment.'