vserver: Hashify hosts even when they are not running.
[matthijs/servers/drsnuggles.git] / usr / local / bin / vserver-hashify-all
1 #!/bin/sh
2
3 # The dir containing vserver configuration
4 VSERVERS_CONF=/etc/vservers
5
6 cd $VSERVERS_CONF
7 for NAME in *; do
8         # Check if its config dir exists
9         if [ ! -d $NAME ]; then
10                 continue;
11         fi
12         
13         echo "Hashifying vserver $NAME..."
14         sudo vserver $NAME hashify
15 done
16
17 # Change to /tmp, to minimize the chance for an error to damage the root fs
18 cd /tmp
19 echo "Cleaning up unused hashed files..."
20 for HASH_DIR in $VSERVERS_CONF/.defaults/apps/vunify/hash/*; do
21         if [ -L $HASH_DIR ]; then
22                 # All symbolic links 
23                 sudo find -H $HASH_DIR -type f -links 1 -print0 | sudo xargs -0 rm
24         fi
25 done