Archived
1
0
This repository has been archived on 2021-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
ACU/process/launch.sh

94 lines
2.6 KiB
Bash
Raw Normal View History

#! /bin/sh
cd $(dirname "$0")
GREP='/bin/egrep'
SCREEN='/usr/bin/screen'
SED='/bin/sed -E'
2013-09-15 10:52:20 +00:00
SU='/bin/su -s /bin/sh'
PERL='/usr/bin/env perl'
2013-09-15 10:52:20 +00:00
launch_screen()
{
2013-09-15 11:23:04 +00:00
CMD=$2
if [ -n "$3" ] && [ -f "$3" ]
then
2013-09-15 12:39:56 +00:00
TMP=`$SU -c 'mktemp' intradmin`
$SU -c "killall ssh-agent" intradmin
2013-09-15 12:39:56 +00:00
$SU -c "ssh-agent" intradmin > "$TMP"
$SU -c ". $TMP; ssh-add '$3'" intradmin
CMD=". $TMP; ssh-add -l; echo; $CMD"
2013-09-15 11:23:04 +00:00
fi
2013-09-15 12:39:56 +00:00
$SU -c "$SCREEN -S '$1' -d -m bash -c '$CMD'" intradmin
2013-09-15 12:54:36 +00:00
if [ -f "$TMP" ]
then
sleep 1
/bin/rm "$TMP"
fi
2013-09-15 11:23:04 +00:00
}
if [ -z "$1" ]
then
2013-09-15 13:27:05 +00:00
ACTION="restart"
2013-09-14 09:19:06 +00:00
else
2013-09-15 13:27:05 +00:00
ACTION="$1"
fi
2013-09-15 13:27:05 +00:00
if [ -z "$2" ]
then
HOSTNAME=`/bin/hostname`
else
HOSTNAME="$2"
fi
2013-09-15 13:40:09 +00:00
if [ "$ACTION" = "stop" ] || [ "$ACTION" = "restart" ]
2013-09-15 13:27:05 +00:00
then
# 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
fi
2013-09-15 13:40:09 +00:00
if [ "$ACTION" = "start" ] || [ "$ACTION" = "restart" ]
2013-09-15 13:27:05 +00:00
then
case $HOSTNAME in
2013-09-15 13:27:05 +00:00
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"
2013-09-15 14:32:51 +00:00
#launch_screen "lerdorf_process_files_intradata_get" "while true; do $PERL ~/liblerdorf/process/files/intradata_get.pl; done"
2013-09-15 13:27:05 +00:00
;;
noyce)
launch_screen "lerdorf_process_files_intradata_get" "while true; do $PERL ~/liblerdorf/process/files/intradata_get.pl; done"
launch_screen "lerdorf_process_projects_gen_grading" "while true; do $PERL ~/liblerdorf/process/projects/gen_grading.pl; done"
2013-09-15 13:27:05 +00:00
;;
2013-09-20 01:39:10 +00:00
ksh)
launch_screen "lerdorf_process_files_moulette_get" "while true; do $PERL ~/liblerdorf/process/files/moulette_get.pl; done"
;;
2013-09-15 13:27:05 +00:00
*)
echo "No process to launch for $HOSTNAME" >&2
exit 1
;;
esac
fi