X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=usr%2Flocal%2Fbin%2Fvserver-hashify-all;h=055cc5101194fd51d0ff35a886e2978f01ce2141;hb=70f4f512ef539e6140c47f3fc32fe5022a75fb07;hp=7c038c1c82d9d77564f8dc27d7c0f8ca504c0666;hpb=a4bde3f71bdff8105f7aedb20cba896be1c54406;p=matthijs%2Fservers%2Fdrsnuggles.git diff --git a/usr/local/bin/vserver-hashify-all b/usr/local/bin/vserver-hashify-all index 7c038c1..055cc51 100755 --- a/usr/local/bin/vserver-hashify-all +++ b/usr/local/bin/vserver-hashify-all @@ -1,25 +1,30 @@ #!/bin/sh # The dir containing vserver configuration -VSERVERS_CONF=/etc/vservers +VSERVERS_CONF="/etc/vservers" -cd $VSERVERS_CONF -for NAME in *; do - # Check if its config dir exists - if [ ! -d $NAME ]; then +for VDIR in "$VSERVERS_CONF"/*; do + NAME=`basename $VDIR` + # Check if its a config dir + if [ ! -d "$VDIR" ]; then continue; fi + if [ ! -d "$VDIR"/apps/vunify ]; then + echo "Skipping vserver $NAME, hashify is disabled" + continue + fi + echo "Hashifying vserver $NAME..." - sudo vserver $NAME hashify + sudo vserver "$NAME" hashify done # Change to /tmp, to minimize the chance for an error to damage the root fs cd /tmp echo "Cleaning up unused hashed files..." -for HASH_DIR in $VSERVERS_CONF/.defaults/apps/vunify/hash/*; do - if [ -L $HASH_DIR ]; then +for HASH_DIR in "$VSERVERS_CONF"/.defaults/apps/vunify/hash/*; do + if [ -L "$HASH_DIR" ]; then # All symbolic links - sudo find -H $HASH_DIR -type f -links 1 -print0 | sudo xargs -0 rm + sudo find -H "$HASH_DIR" -type f -links 1 -print0 | sudo xargs --null --no-run-if-empty rm fi done