jumpserver/service.sh

104 lines
2.0 KiB
Bash
Raw Normal View History

2015-04-20 02:12:11 +00:00
#!/bin/bash
2015-04-22 10:57:55 +00:00
# jumpserver Startup script for the jumpserver Server
#
# chkconfig: - 85 12
# description: Open source detecting system
# processname: jumpserver
2015-04-20 02:12:11 +00:00
# Date: 2015-04-12
# Version: 2.0.0
# Site: http://www.jumpserver.org
2015-12-19 09:26:34 +00:00
# Author: Jumpserver Team
2015-04-20 02:12:11 +00:00
. /etc/init.d/functions
2015-04-22 10:57:55 +00:00
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin
2015-04-20 02:12:11 +00:00
base_dir=$(dirname $0)
2015-04-22 10:57:55 +00:00
PROC_NAME="jumpsever"
lockfile=/var/lock/subsys/${PROC_NAME}
start() {
jump_start=$"Starting ${PROC_NAME} service:"
if [ -f $lockfile ];then
echo "jumpserver is running..."
success "$jump_start"
else
daemon python $base_dir/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 &
2015-12-19 09:26:34 +00:00
daemon python $base_dir/run_websocket.py &> /dev/null 2>&1 &
2015-04-24 10:19:43 +00:00
sleep 2
2015-04-22 10:57:55 +00:00
2015-04-24 10:19:43 +00:00
echo -n "$jump_start"
2015-04-22 10:57:55 +00:00
nums=0
2015-12-19 09:26:34 +00:00
for i in manage.py run_websocket.py;do
ps aux | grep "$i" | grep -v 'grep' &> /dev/null && let nums+=1 || echo "$i not running"
2015-04-22 10:57:55 +00:00
done
2015-12-19 09:26:34 +00:00
if [ "x$nums" == "x2" ];then
2015-04-22 10:57:55 +00:00
success "$jump_start"
touch "$lockfile"
echo
else
failure "$jump_start"
echo
fi
fi
}
stop() {
echo -n $"Stopping ${PROC_NAME} service:"
if [ -e $lockfile ];then
2015-12-19 09:26:34 +00:00
ps aux | grep -E 'manage.py|run_websocket.py' | grep -v grep | awk '{print $2}' | xargs kill -9 &> /dev/null
2015-04-22 10:57:55 +00:00
ret=$?
if [ $ret -eq 0 ]; then
echo_success
echo
rm -f "$lockfile"
else
echo_failure
echo
2015-12-19 14:08:56 +00:00
rm -f "$lockfile"
2015-04-22 10:57:55 +00:00
fi
else
echo_success
echo
fi
}
restart(){
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 2
esac