HEX
Server: nginx/1.26.1
System: Linux iZrj9cbdvwu1cot8sjlyzlZ 5.10.134-15.al8.x86_64 #1 SMP Thu Jul 20 00:44:04 CST 2023 x86_64
User: www (1000)
PHP: 7.4.33
Disabled: 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
Upload Files
File: //etc/rc4.d/S55btpanelhids
#!/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"
  # 如果status.pl文件不存在,创建默认开启状态
  if [ ! -e "$status_path" ]; then
    echo "status.pl 文件不存在,创建默认开启状态"
    echo "True" > "$status_path"
  fi
  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.5
                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