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
|
2016-02-26 17:26:36 +00:00
|
|
|
# Date: 2016-02-27
|
|
|
|
# Version: 3.0.1
|
2015-04-20 02:12:11 +00:00
|
|
|
# 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-26 17:26:36 +00:00
|
|
|
jumpserver_dir=
|
2015-04-20 02:12:11 +00:00
|
|
|
|
2016-02-26 17:26:36 +00:00
|
|
|
base_dir=$(dirname $0)
|
|
|
|
jumpserver_dir=${jumpserver_dir:-$base_dir}
|
|
|
|
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
|
|
|
|
if [ -f ${jumpserver_dir}/install/functions ];then
|
|
|
|
. ${jumpserver_dir}/install/functions
|
|
|
|
elif [ -f /etc/init.d/functions ];then
|
|
|
|
. /etc/init.d/functions
|
|
|
|
else
|
|
|
|
echo "No functions script found in [./functions, ./install/functions, /etc/init.d/functions]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
PROC_NAME="jumpserver"
|
2015-04-22 10:57:55 +00:00
|
|
|
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
|
2016-02-26 17:26:36 +00:00
|
|
|
echo -n "jumpserver is running..."
|
|
|
|
success "$jump_start"
|
|
|
|
echo
|
2016-02-26 06:13:21 +00:00
|
|
|
else
|
2016-02-26 17:26:36 +00:00
|
|
|
daemon python $jumpserver_dir/manage.py crontab add &>> /var/log/jumpserver.log 2>&1
|
|
|
|
daemon python $jumpserver_dir/run_server.py &> /dev/null 2>&1 &
|
|
|
|
sleep 1
|
|
|
|
echo -n "$jump_start"
|
|
|
|
ps axu | grep 'run_server' | grep -v 'grep' &> /dev/null
|
|
|
|
if [ $? == '0' ];then
|
|
|
|
success "$jump_start"
|
2016-03-03 07:53:46 +00:00
|
|
|
if [ ! -e $lockfile ]; then
|
2016-03-03 08:37:12 +00:00
|
|
|
lockfile_dir=`dirname $lockfile`
|
2016-03-03 07:53:46 +00:00
|
|
|
mkdir -pv $lockfile_dir
|
|
|
|
fi
|
2016-02-26 17:26:36 +00:00
|
|
|
touch "$lockfile"
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
failure "$jump_start"
|
|
|
|
echo
|
2016-02-26 06:13:21 +00:00
|
|
|
fi
|
2016-02-26 17:26:36 +00:00
|
|
|
fi
|
2015-04-22 10:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stop() {
|
2016-02-26 17:26:36 +00:00
|
|
|
echo -n $"Stopping ${PROC_NAME} service:"
|
|
|
|
daemon python $jumpserver_dir/manage.py crontab remove &>> /var/log/jumpserver.log 2>&1
|
|
|
|
ps aux | grep -E 'run_server.py' | grep -v grep | awk '{print $2}' | xargs kill -9 &> /dev/null
|
|
|
|
ret=$?
|
|
|
|
if [ $ret -eq 0 ]; then
|
|
|
|
echo_success
|
|
|
|
echo
|
2015-12-21 08:10:07 +00:00
|
|
|
rm -f "$lockfile"
|
2016-02-26 17:26:36 +00:00
|
|
|
else
|
|
|
|
echo_failure
|
|
|
|
echo
|
2015-12-21 08:10:07 +00:00
|
|
|
rm -f "$lockfile"
|
2016-02-26 17:26:36 +00:00
|
|
|
fi
|
2015-04-22 10:57:55 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-02-26 17:26:36 +00:00
|
|
|
status(){
|
|
|
|
ps axu | grep 'run_server' | grep -v 'grep' &> /dev/null
|
|
|
|
if [ $? == '0' ];then
|
|
|
|
echo -n "jumpserver is running..."
|
|
|
|
success
|
|
|
|
touch "$lockfile"
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo -n "jumpserver is not running."
|
|
|
|
failure
|
|
|
|
echo
|
|
|
|
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
|
|
|
|
;;
|
|
|
|
|
2016-02-26 17:26:36 +00:00
|
|
|
status)
|
|
|
|
status
|
|
|
|
;;
|
2016-02-26 06:13:21 +00:00
|
|
|
*)
|
2016-02-26 17:26:36 +00:00
|
|
|
echo $"Usage: $0 {start|stop|restart|status}"
|
2016-02-26 06:13:21 +00:00
|
|
|
exit 2
|
|
|
|
esac
|