e2df3b907c3e95c7897fa6e84b4bbb5c2697046c
[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         if [ ! -d $NAME ]; then
9                 continue;
10         fi
11         if ! sudo vserver $NAME status &> /dev/null; then
12                 continue;
13         fi
14         
15         echo "Hashifying vserver $NAME..."
16         sudo vserver $NAME hashify
17 done
18
19 # Change to /tmp, to minimize the chance for an error to damage the root fs
20 cd /tmp
21 echo "Cleaning up unused hashed files..."
22 for HASH_DIR in $VSERVERS_CONF/.defaults/apps/vunify/hash/*; do
23         if [ -L $HASH_DIR ]; then
24                 # All symbolic links 
25                 sudo find -H $HASH_DIR -type f -links 1 -print0 | sudo xargs -0 rm
26         fi
27 done