| Server IP : 43.141.50.122 / Your IP : 113.219.202.173 Web Server : Apache System : Linux VM-8-5-opencloudos 6.6.34-9.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 19 19:35:45 CST 2024 x86_64 User : www ( 1000) PHP Version : 8.1.27 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /etc/rc.d/init.d/ |
Upload File : |
#!/bin/bash
# chkconfig: 2345 55 25
# description: BT-Panel-Hids
### BEGIN INIT INFO
# Provides: BT-Panel-Hids
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts BT-Panel-Hids
# Description: starts the BT-Panel-Hids Service
### END INIT INFO
target_dir=/www/server/panel/plugin/bt_hids
cd $target_dir
server_start()
{
status_path="/www/server/panel/data/hids_data/status.pl"
if [ -e "$status_path" ]; then
echo "status.pl 文件存在"
status=$(cat /www/server/panel/data/hids_data/status.pl)
if [ "$status" = "True" ]; then
isStart=$(ps aux |grep '/bt_hids/load_hids.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "Starting BT-Panel-Hids ... \c"
btpython /www/server/panel/plugin/bt_hids/load_hids.py
sleep 0.2
isStart=$(ps aux |grep '/bt_hids/load_hids.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
echo -e "\033[31mError: BT-Panel-Hids service startup failed.\033[0m"
return;
fi
echo $isStart > "/www/server/panel/data/hids_data/pid.pl"
echo -e " \033[32mdone\033[0m"
else
echo "Starting BT-Panel-Hids.. (pid $isStart) already running"
fi
else
echo "status_file is false"
fi
fi
}
service_stop()
{
echo -e "Stopping BT-Panel-Hids...\c";
pids=$(ps aux |grep '/bt_hids/load_hids.py'|grep -v grep|awk '{print $2}')
arr=($pids)
for p in ${arr[@]}
do
kill -9 $p
done
rmmod hids_driver
echo -e " \033[32mdone\033[0m"
}
service_status()
{
isStart=$(ps aux |grep '/bt_hids/load_hids.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" != '' ];then
echo -e "\033[32mBT-Panel-Hids (pid $(echo $isStart)) already running\033[0m"
else
echo -e "\033[31mBT-Panel-Hids not running\033[0m"
fi
# $target_dir/tools get_status
}
case "$1" in
'start')
server_start
;;
'stop')
service_stop
;;
'restart')
service_stop
sleep 1
server_start
;;
'status')
service_status
;;
'default')
# echo 选项为空
;;
esac