New script to manage servers
This commit is contained in:
parent
0001a46686
commit
7b2a4185c9
3 changed files with 75 additions and 35 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# Install missing packets
|
# Install missing packets
|
||||||
PACKAGES_LIST="libnet-ldap-perl libxml-libxml-perl libgearman-client-perl"
|
PACKAGES_LIST="libnet-ldap-perl libxml-libxml-perl libgearman-client-perl libmailtools-perl libmail-sendmail-perl"
|
||||||
|
|
||||||
if ! whereis dpkg > /dev/null 2> /dev/null
|
if ! whereis dpkg > /dev/null 2> /dev/null
|
||||||
then
|
then
|
||||||
|
|
|
||||||
26
commands/manage-server.sh
Normal file
26
commands/manage-server.sh
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
cd $(dirname "$0")
|
||||||
|
|
||||||
|
SRV_LIST="moore noyce hamano cpp"
|
||||||
|
|
||||||
|
ACTIONS="start stop restart"
|
||||||
|
|
||||||
|
for ACT in $ACTIONS
|
||||||
|
do
|
||||||
|
if [ -n "$1" ] && [ "$1" == "$ACT" ]
|
||||||
|
then
|
||||||
|
ACTION="$ACT"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$ACTION" ]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 [$ACTIONS]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for SRV in $SRV_LIST
|
||||||
|
do
|
||||||
|
ssh root@$SRV ~/liblerdorf/process/launch.sh "$ACTION"
|
||||||
|
done
|
||||||
|
|
@ -30,44 +30,58 @@ launch_screen()
|
||||||
|
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
then
|
then
|
||||||
HOSTNAME=`/bin/hostname`
|
ACTION="restart"
|
||||||
else
|
else
|
||||||
HOSTNAME="$1"
|
ACTION="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Kill old liblersorf screen sessions
|
if [ -z "$2" ]
|
||||||
$SU -c "$SCREEN -ls" intradmin | $GREP '[0-9]+\.lerdorf_[a-zA-Z0-9_-]+' |
|
then
|
||||||
while read LINE
|
HOSTNAME=`/bin/hostname`
|
||||||
do
|
else
|
||||||
SNAME=`echo $LINE | $SED "s/^[^0-9]*([0-9]+\.[^ \t]+).*$/\1/"`
|
HOSTNAME="$2"
|
||||||
$SU -c "$SCREEN -S \"$SNAME\" -X kill" intradmin
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
case $HOSTNAME in
|
if [ "$ACTION" == "stop" ] || [ "$ACTION" == "restart" ]
|
||||||
|
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
|
||||||
|
|
||||||
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)
|
if [ "$ACTION" == "start" ] || [ "$ACTION" == "restart" ]
|
||||||
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
|
then
|
||||||
;;
|
case $HOSTNAME in
|
||||||
|
|
||||||
moore)
|
cpp)
|
||||||
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_forge" "while true; do $PERL ~/liblerdorf/process/ldap/sync_ssh_keys_forge.pl; done" ~intradmin/.ssh/git
|
||||||
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"
|
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
|
||||||
launch_screen "lerdorf_process_files_intradata_get" "while true; do $PERL ~/liblerdorf/process/files/intradata_get.pl; done"
|
;;
|
||||||
;;
|
|
||||||
|
moore)
|
||||||
noyce)
|
launch_screen "lerdorf_process_ldap_check_ssh_key" "while true; do $PERL ~/liblerdorf/process/ldap/check_ssh_key.pl; done"
|
||||||
launch_screen "lerdorf_process_files_intradata_get" "while true; do $PERL ~/liblerdorf/process/files/intradata_get.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"
|
||||||
*)
|
|
||||||
echo "No process to launch for $HOSTNAME" >&2
|
launch_screen "lerdorf_process_files_intradata_get" "while true; do $PERL ~/liblerdorf/process/files/intradata_get.pl; done"
|
||||||
exit 1
|
;;
|
||||||
;;
|
|
||||||
esac
|
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
|
||||||
|
fi
|
||||||
|
|
|
||||||
Reference in a new issue