#! /bin/sh cd $(dirname "$0") GREP='/bin/egrep' SCREEN='/usr/bin/screen' SED='/bin/sed -E' SU='/bin/su -s /bin/sh' PERL='/usr/bin/env perl' launch_screen() { CMD=$2 if [ -n "$3" ] && [ -f "$3" ] then TMP=`$SU -c 'mktemp' intradmin` $SU -c "ssh-agent" intradmin > "$TMP" $SU -c ". $TMP; ssh-add '$3'" intradmin CMD=". $TMP; ssh-add -l; echo; $CMD" fi $SU -c "$SCREEN -S '$1' -d -m bash -c '$CMD'" intradmin sleep 1 /bin/rm "$TMP" } if [ -z "$1" ] then HOSTNAME=`/bin/hostname` else HOSTNAME="$1" fi # Kill old liblersorf screen sessions $SU -c "$SCREEN -ls" intradmin | $GREP '[0-9]+\.lerdorf_[a-zA-Z0-9_-]+' | while read LINE do SNAME=`echo $LINE | $SED "s/^[^0-9]*([0-9]+\.[^ \t]+).*$/\1/"` $SU -c "$SCREEN -S \"$SNAME\" -X kill" intradmin done case $HOSTNAME in cpp) launch_screen "lerdorf_process_ldap_sync_ssh_keys_forge" "while true; do $PERL ~/liblerdorf/process/ldap/sync_ssh_keys_forge.pl; done" ~intradmin/.ssh/git ;; hamano) launch_screen "lerdorf_process_ldap_sync_ssh_keys_git" "while true; do $PERL ~/liblerdorf/process/ldap/sync_ssh_keys_git.pl; done" ~intradmin/.ssh/git ;; moore) launch_screen "lerdorf_process_ldap_check_ssh_key" "while true; do $PERL ~/liblerdorf/process/ldap/check_ssh_key.pl; done" launch_screen "lerdorf_process_ldap_sync_ssh_keys" "while true; do $PERL ~/liblerdorf/process/ldap/sync_ssh_keys.pl; done" launch_screen "lerdorf_process_ldap_update_group" "while true; do $PERL ~/liblerdorf/process/ldap/update_group.pl; done" launch_screen "lerdorf_process_ldap_update_user" "while true; do $PERL ~/liblerdorf/process/ldap/update_user.pl; done" launch_screen "lerdorf_process_files_intradata_get" "while true; do $PERL ~/liblerdorf/process/files/intradata_get.pl; done" ;; noyce) launch_screen "lerdorf_process_files_intradata_get" "while true; do $PERL ~/liblerdorf/process/files/intradata_get.pl; done" ;; *) echo "No process to launch for $HOSTNAME" >&2 exit 1 ;; esac