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
|
|
|
|
2016-02-25 05:26:18 +00:00
|
|
|
base_dir=$(dirname $0)
|
|
|
|
|
|
|
|
. ${base_dir}/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
|
|
|
|
2016-02-25 05:26:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-04-20 02:12:11 +00:00
|
|
|
|
2015-04-22 10:57:55 +00:00
|
|
|
PROC_NAME="jumpsever"
|
|
|
|
lockfile=/var/lock/subsys/${PROC_NAME}
|
|
|
|
|
|
|
|
|
|
|
|
start() {
|
2016-02-26 06:13:21 +00:00
|
|
|
jump_start=$"Starting ${PROC_NAME} service:"
|
|
|
|
|
|
|
|
if [ -f $lockfile ];then
|
|
|
|
echo "jumpserver is running..."
|
|
|
|
success "$jump_start"
|
|
|
|
else
|
2016-02-26 15:09:19 +00:00
|
|
|
# daemon python $base_dir/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 &
|
2016-02-26 06:13:21 +00:00
|
|
|
daemon python $base_dir/manage.py crontab add &>> /tmp/jumpserver.log 2>&1
|
|
|
|
daemon python $base_dir/run_websocket.py &> /dev/null 2>&1 &
|
2015-12-21 06:28:12 +00:00
|
|
|
sleep 4
|
2015-04-22 10:57:55 +00:00
|
|
|
|
2016-02-26 06:13:21 +00:00
|
|
|
echo -n "$jump_start"
|
|
|
|
nums=0
|
2015-12-19 09:26:34 +00:00
|
|
|
for i in manage.py run_websocket.py;do
|
2016-02-26 06:13:21 +00:00
|
|
|
if ps aux | grep "$i" | grep -v 'grep' &> /dev/null; then
|
|
|
|
nums=$[nums+1]
|
|
|
|
else
|
|
|
|
echo "$i not running"
|
|
|
|
fi
|
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"
|
2016-02-26 06:13:21 +00:00
|
|
|
if [ ! -e $lockfile ]; then
|
|
|
|
lockfile_dir=`dirname $lockfile`
|
|
|
|
mkdir -pv $lockfile_dir
|
|
|
|
fi
|
2015-04-22 10:57:55 +00:00
|
|
|
touch "$lockfile"
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
failure "$jump_start"
|
|
|
|
echo
|
|
|
|
fi
|
2016-02-26 06:13:21 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2015-04-22 10:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
|
2016-02-26 06:13:21 +00:00
|
|
|
echo -n $"Stopping ${PROC_NAME} service:"
|
|
|
|
|
2016-02-23 10:46:00 +00:00
|
|
|
daemon python $base_dir/manage.py crontab remove &>> /tmp/jumpserver.log 2>&1
|
2016-02-26 06:13:21 +00:00
|
|
|
ps aux | grep -E 'manage.py|run_websocket.py' | grep -v grep | awk '{print $2}' | xargs kill -9 &> /dev/null
|
|
|
|
ret=$?
|
2015-12-21 08:10:07 +00:00
|
|
|
|
2016-02-26 06:13:21 +00:00
|
|
|
if [ $ret -eq 0 ]; then
|
|
|
|
echo_success
|
|
|
|
echo
|
2015-12-21 08:10:07 +00:00
|
|
|
rm -f "$lockfile"
|
2016-02-26 06:13:21 +00:00
|
|
|
else
|
|
|
|
echo_failure
|
|
|
|
echo
|
2015-12-21 08:10:07 +00:00
|
|
|
rm -f "$lockfile"
|
2016-02-26 06:13:21 +00:00
|
|
|
fi
|
2015-04-22 10:57:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
restart(){
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
2016-02-26 06:13:21 +00:00
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
|
|
|
|
restart)
|
|
|
|
restart
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2015-04-22 10:57:55 +00:00
|
|
|
echo $"Usage: $0 {start|stop|restart}"
|
2016-02-26 06:13:21 +00:00
|
|
|
exit 2
|
|
|
|
esac
|