fixed to work with web interface.
authorTim Abbott <tabbott@mit.edu>
Sun, 7 Oct 2007 22:32:15 +0000 (18:32 -0400)
committerTim Abbott <tabbott@mit.edu>
Sun, 7 Oct 2007 22:32:15 +0000 (18:32 -0400)
svn path=/trunk/packages/sipb-xen-remctl-auto/sipb-xen-remctl-auto/; revision=126

files/usr/sbin/remctl-update.sh

index 4427531..9b7f309 100755 (executable)
@@ -12,7 +12,7 @@ ACLDIR=$DIR/acl
 
 update_machine()
 {
-    machine=$1
+    machine="$1"
     sed "s/#MACHINENAME#/$machine/g" "$TEMPLATE" | \
        sed "s,#BINDIR#,$BINDIR,g" >| "$MACHINETMP"
     if ! cmp -s "$MACHINEDIR/$machine" "$MACHINETMP"; then
@@ -24,14 +24,16 @@ update_machine()
 
 update_moiragroup()
 {
-    group=$1
+    group="$1"
     # Should perhaps replace with LDAP, but fine for now.
 
     # We should do more careful error checking so we don't take away
     # all bits and delete the moira-acl files whenever there's an AFS
     # outage.
-    pts membership -nameorid "system:$group" -noauth | tail -n+2 | \
-       sed 's/\./\//; s/^  //; s/$/@ATHENA.MIT.EDU/g' >| "$MOIRATMP"
+    pts membership system:"$group" -noauth | tail -n+2 | \
+       sed 's/\./\//' | \
+       sed 's/^  //' | \
+       sed 's/$/@ATHENA.MIT.EDU/g' >| "$MOIRATMP"
     if test -s "$MOIRATMP"; then
        if ! cmp -s "$MOIRADIR/$group" "$MOIRATMP"; then
            mv "$MOIRATMP" "$MOIRADIR/$group"
@@ -72,6 +74,26 @@ case "$1" in
        # This extracts the list of all moira lists we care about, and updates those.
        grep -R moira "$ACLDIR/" /etc/remctl/acl/ | perl -pe 's/.*moira-acl\/(.*)/$1/g' >| "$AUTOMOIRALIST"
        ;;
+    register)
+       if [ "$2" == "Domain-0" ]; then
+           echo "No, you can't control Domain 0"
+           exit 1
+       fi
+       if [ -e /etc/xen/"$2" ]; then
+           echo "Machine already exists outside database"
+           exit 1
+       fi
+       if [ -e "$ACLDIR"/"$2" ]; then
+           echo "Machine already registered"
+           exit 1
+       fi
+       echo "include /etc/remctl/acl/web" > "$ACLDIR/$2"
+       "$0" web
+       ;;
+    web)
+       "$0" auto_machine_list
+       "$0" all_machines
+       ;;      
     all)
        "$0" auto_machine_list
        "$0" all_machines