ksa启动脚本备份 init.d
看雪安全接入 Kanxue Security Access
官网:https://ksa.kanxue.com/
下载地址:https://ksa.kanxue.com/view/img/product/KSA_0.80.zip
PROG 执行文件名
PROG_PATH 执行文件所在目录
#!/bin/bash
# chkconfig: 2345 56 26
# description: KSA Service
### BEGIN INIT INFO
# Provides: ksa
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop KSA
### END INIT INFO
PROG="ksa_arm64"
PROG_PATH="/usr/local/ksa"
PIDFILE="/var/run/ksa_arm64.pid"
start() {
if [ -f "$PIDFILE" ]; then
ps -p $(cat ${PIDFILE}) > /dev/null 2>&1
if [ $? -ne "0" ]; then
echo KSA is not running, buy pid file is exits ${PIDFILE}
exit 1
else
echo "KSA is running! ($(cat ${PIDFILE}))"
exit 0
fi
fi
echo "Starting KSA server..."
$PROG_PATH/$PROG 2>&1 >/var/log/$PROG &
sleep 5
pid=$(ps x | grep $PROG | grep -v grep | awk '{print $1}')
echo $pid > "$PIDFILE"
echo "Starting KSA success!"
}
stop() {
echo "Stopping ..."
# 方法一
kill -9 `cat $PIDFILE`
# 方法二
pid=$(ps x | grep $PROG | grep -v grep | awk '{print $1}')
kill -9 $pid
# 删除临时文件
sleep 1
rm -f "$PIDFILE"
rm -f "$PROG_PATH/ksa.log"
echo "KSA stopped"
}
## Check to see if we are running as root first.
## Found at http://www.cyberciti.biz/tips/shell-root-user-check-script.html
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
case "$1" in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
reload|restart|force-reload)
stop
sleep 1
start
exit 0
;;
**)
echo "Usage: $0 {start|stop|restart}" 1>&2
exit 1
;;
esac