X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-remote.git/blobdiff_plain/c4370f4c3994d4ea126a511b1fa920898c5aa1ac..4d5a090ff15267db03697a074944a1b0687e94e3:/files/usr/sbin/remctl-update.sh?ds=sidebyside diff --git a/files/usr/sbin/remctl-update.sh b/files/usr/sbin/remctl-update.sh index 9b7f309..f0254b9 100755 --- a/files/usr/sbin/remctl-update.sh +++ b/files/usr/sbin/remctl-update.sh @@ -46,6 +46,15 @@ update_moiragroup() rm -f "$MOIRATMP" } +check_machine_name() +{ + machinename="$1" + if ! perl -0e 'exit($ARGV[0] !~ /^[A-Za-z0-9][A-Za-z0-9._-]*$/)' -- "$machinename"; then + echo "Bad machine name" + exit 1 + fi +} + case "$1" in moiragroup) update_moiragroup "$2" @@ -74,27 +83,37 @@ 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" ;; + unregister) + machine="$2" + check_machine_name "$machine" + rm -f "$ACLDIR"/"$machine" + rm -f "$MACHINEDIR"/"$machine" + "$0" web + ;; + moveregister) + oldmachine="$2" + newmachine="$3" + check_machine_name "$oldmachine" + check_machine_name "$newmachine" + mv "$ACLDIR"/"$oldmachine" "$ACLDIR"/"$newmachine" + rm -f "$MACHINEDIR"/"$oldmachine" + "$0" web + ;; 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 + machine="$2" + check_machine_name "$machine" + if [ -e "$ACLDIR"/"$machine" ]; then echo "Machine already registered" exit 1 fi - echo "include /etc/remctl/acl/web" > "$ACLDIR/$2" + echo "include /etc/remctl/acl/web" > "$ACLDIR/$machine" "$0" web ;; web) "$0" auto_machine_list "$0" all_machines ;; - all) + remctl-moira-update|all) "$0" auto_machine_list "$0" all_machines "$0" auto_moira_list