Update mw.tpl

pull/632/head
Mr Chen 6 months ago
parent f952f88d9a
commit 87c50e529d
  1. 118
      scripts/init.d/mw.tpl

@ -28,13 +28,13 @@ WORKING='[\033[34m*\033[0m]'
PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export LANG=en_US.UTF-8
mw_path={$SERVER_PATH}
ROOT_PATH=$(dirname "$mw_path")
PANEL_DIR={$SERVER_PATH}
ROOT_PATH=$(dirname "$PANEL_DIR")
PATH=$PATH:$mw_path/bin
if [ -f $mw_path/bin/activate ];then
source $mw_path/bin/activate
if [ -f ${PANEL_DIR}/bin/activate ];then
source ${PANEL_DIR}/bin/activate
if [ "$?" != "0" ];then
echo "load local python env fail!"
fi
@ -45,8 +45,8 @@ mw_start_panel()
isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'`
if [ "$isStart" == '' ];then
echo -e "starting mw-panel... \c"
cd $mw_path && gunicorn -c setting.py app:app
port=$(cat ${mw_path}/data/port.pl)
cd ${PANEL_DIR}/web && gunicorn -c setting.py app:app
port=$(cat ${PANEL_DIR}/data/port.pl)
isStart=""
while [[ "$isStart" == "" ]];
do
@ -61,7 +61,7 @@ mw_start_panel()
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
echo '------------------------------------------------------'
tail -n 20 ${mw_path}/logs/error.log
tail -n 20 ${PANEL_DIR}/logs/panel_error.log
echo '------------------------------------------------------'
echo -e "\033[31mError: mw-panel service startup failed.\033[0m"
return;
@ -75,16 +75,16 @@ mw_start_panel()
mw_start_task()
{
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
isStart=$(ps aux |grep 'panel_task.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "starting mw-tasks... \c"
cd $mw_path && python3 task.py >> ${mw_path}/logs/task.log 2>&1 &
cd ${PANEL_DIR} && python3 panel_task.py >> ${PANEL_DIR}/logs/panel_task.log 2>&1 &
sleep 0.3
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
isStart=$(ps aux |grep 'panel_task.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
echo '------------------------------------------------------'
tail -n 20 $mw_path/logs/task.log
tail -n 20 ${PANEL_DIR}/logs/panel_task.log
echo '------------------------------------------------------'
echo -e "\033[31mError: mw-tasks service startup failed.\033[0m"
return;
@ -110,7 +110,7 @@ mw_stop_task()
fi
echo -e "stopping mw-tasks... \c";
pids=$(ps aux | grep 'task.py'|grep -v grep|awk '{print $2}')
pids=$(ps aux | grep 'panel_task.py'|grep -v grep|awk '{print $2}')
arr=($pids)
for p in ${arr[@]}
do
@ -154,7 +154,7 @@ mw_status()
echo -e "\033[31mmw not running\033[0m"
fi
isStart=$(ps aux |grep 'task.py'|grep -v grep|awk '{print $2}')
isStart=$(ps aux |grep 'panel_task.py'|grep -v grep|awk '{print $2}')
if [ "$isStart" != '' ];then
echo -e "\033[32mmw-task (pid $isStart) already running\033[0m"
else
@ -174,7 +174,7 @@ mw_reload()
do
kill -9 $p
done
cd $mw_path && gunicorn -c setting.py app:app
cd ${PANEL_DIR}/web && gunicorn -c setting.py app:app
isStart=`ps aux|grep 'gunicorn -c setting.py app:app'|grep -v grep|awk '{print $2}'`
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
@ -192,27 +192,27 @@ mw_reload()
}
mw_close(){
echo 'True' > $mw_path/data/close.pl
echo 'True' > ${PANEL_DIR}/data/close.pl
}
mw_open()
{
if [ -f $mw_path/data/close.pl ];then
rm -rf $mw_path/data/close.pl
if [ -f ${PANEL_DIR}/data/close.pl ];then
rm -rf ${PANEL_DIR}/data/close.pl
fi
}
mw_unbind_domain()
{
if [ -f $mw_path/data/bind_domain.pl ];then
rm -rf $mw_path/data/bind_domain.pl
if [ -f ${PANEL_DIR}/data/bind_domain.pl ];then
rm -rf ${PANEL_DIR}/data/bind_domain.pl
fi
}
mw_unbind_ssl()
{
if [ -f $mw_path/local ];then
rm -rf $mw_path/local
if [ -f ${PANEL_DIR}/local ];then
rm -rf ${PANEL_DIR}/local
fi
if [ -f $mw_path/nginx ];then
@ -226,12 +226,12 @@ mw_unbind_ssl()
error_logs()
{
tail -n 100 $mw_path/logs/error.log
tail -n 100 ${PANEL_DIR}/logs/panel_error.log
}
mw_update()
{
if [ -f $mw_path/task.py ];then
if [ -f ${PANEL_DIR}/task.py ];then
echo "与后续版本差异太大,不再提供更新"
exit 0
fi
@ -251,7 +251,7 @@ mw_update()
mw_update_dev()
{
if [ -f $mw_path/task.py ];then
if [ -f ${PANEL_DIR}/task.py ];then
echo "与后续版本差异太大,不再提供更新"
exit 0
fi
@ -267,14 +267,14 @@ mw_update_dev()
else
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
fi
cd /www/server/mdserver-web
cd ${PANEL_DIR}
}
mw_update_venv()
{
rm -rf /www/server/mdserver-web/bin
rm -rf /www/server/mdserver-web/lib64
rm -rf /www/server/mdserver-web/lib
rm -rf ${PANEL_DIR}/bin
rm -rf ${PANEL_DIR}/lib64
rm -rf ${PANEL_DIR}/lib
LOCAL_ADDR=common
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
@ -287,7 +287,7 @@ mw_update_venv()
else
curl --insecure -fsSL https://code.midoks.icu/midoks/mdserver-web/raw/branch/dev/scripts/update_dev.sh | bash
fi
cd /www/server/mdserver-web
cd ${PANEL_DIR}
}
mw_mirror()
@ -303,7 +303,7 @@ mw_mirror()
else
bash <(curl --insecure -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh)
fi
cd ${ROOT_PATH}/mdserver-web
cd ${ROOT_PATH}
}
mw_install_app()
@ -338,12 +338,12 @@ mw_debug(){
mw_force_kill
port=7200
if [ -f $mw_path/data/port.pl ];then
port=$(cat $mw_path/data/port.pl)
if [ -f ${PANEL_DIR}/data/port.pl ];then
port=$(cat ${PANEL_DIR}/data/port.pl)
fi
if [ -d ${ROOT_PATH}/mdserver-web ];then
cd ${ROOT_PATH}/mdserver-web
if [ -d ${PANEL_DIR}/web ];then
cd ${PANEL_DIR}/web
fi
gunicorn -b :$port -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app
}
@ -445,7 +445,7 @@ mw_connect_pgdb(){
fi
pwd=$(cd ${ROOT_PATH}/mdserver-web && python3 ${ROOT_PATH}/mdserver-web/plugins/postgresql/index.py root_pwd)
pwd=$(cd ${PANEL_DIR} && python3 ${PANEL_DIR}/plugins/postgresql/index.py root_pwd)
export PGPASSWORD=${pwd}
echo "${ROOT_PATH}/postgresql/bin/psql -U postgres -W"
${ROOT_PATH}/postgresql/bin/psql -U postgres -W
@ -464,7 +464,7 @@ mw_mongodb(){
AUTH_STR=""
if [[ "$MGDB_AUTH" == "enabled" ]];then
pwd=$(cd ${ROOT_PATH}/mdserver-web && python3 ${ROOT_PATH}/mdserver-web/plugins/mongodb/index.py root_pwd)
pwd=$(cd ${PANEL_DIR} && python3 ${PANEL_DIR}/plugins/mongodb/index.py root_pwd)
AUTH_STR="-u root -p ${pwd}"
fi
@ -493,14 +493,14 @@ mw_redis(){
}
mw_venv(){
cd ${ROOT_PATH}/mdserver-web && source bin/activate
cd ${PANEL_DIR} && source bin/activate
}
mw_clean_lib(){
cd ${ROOT_PATH}/mdserver-web && rm -rf lib
cd ${ROOT_PATH}/mdserver-web && rm -rf lib64
cd ${ROOT_PATH}/mdserver-web && rm -rf bin
cd ${ROOT_PATH}/mdserver-web && rm -rf include
cd ${PANEL_DIR} && rm -rf lib
cd ${PANEL_DIR} && rm -rf lib64
cd ${PANEL_DIR} && rm -rf bin
cd ${PANEL_DIR} && rm -rf include
}
case "$1" in
@ -540,35 +540,35 @@ case "$1" in
port=7200
scheme=http
if [ -f $mw_path/ssl/choose.pl ];then
if [ -f ${PANEL_DIR}/ssl/choose.pl ];then
scheme=https
fi
if [ -f $mw_path/data/port.pl ];then
port=$(cat $mw_path/data/port.pl)
if [ -f ${PANEL_DIR}/data/port.pl ];then
port=$(cat ${PANEL_DIR}/data/port.pl)
fi
if [ ! -f $mw_path/data/default.pl ];then
if [ ! -f ${PANEL_DIR}/data/default.pl ];then
echo -e "\033[33mInstall Failed\033[0m"
exit 1
fi
password=$(cat $mw_path/data/default.pl)
if [ -f $mw_path/data/domain.conf ];then
address=$(cat $mw_path/data/domain.conf)
password=$(cat ${PANEL_DIR}/data/default.pl)
if [ -f ${PANEL_DIR}/data/domain.conf ];then
address=$(cat ${PANEL_DIR}/data/domain.conf)
fi
if [ -f $mw_path/data/admin_path.pl ];then
auth_path=$(cat $mw_path/data/admin_path.pl)
if [ -f ${PANEL_DIR}/data/admin_path.pl ];then
auth_path=$(cat ${PANEL_DIR}/data/admin_path.pl)
fi
if [ "$address" == "" ];then
v4=$(python3 $mw_path/tools.py getServerIp 4)
v6=$(python3 $mw_path/tools.py getServerIp 6)
v4=$(python3 ${PANEL_DIR}/tools.py getServerIp 4)
v6=$(python3 ${PANEL_DIR}/tools.py getServerIp 6)
if [ "$v4" != "" ] && [ "$v6" != "" ]; then
if [ ! -f $mw_path/data/ipv6.pl ];then
echo 'True' > $mw_path/data/ipv6.pl
if [ ! -f ${PANEL_DIR}/data/ipv6.pl ];then
echo 'True' > ${PANEL_DIR}/data/ipv6.pl
mw_stop
mw_start
fi
@ -578,9 +578,9 @@ case "$1" in
address="MW-Panel-Url: ${scheme}://$v4:$port$auth_path"
elif [ "$v6" != "" ]; then
if [ ! -f $mw_path/data/ipv6.pl ];then
if [ ! -f ${PANEL_DIR}/data/ipv6.pl ];then
# Need to restart ipv6 to take effect
echo 'True' > $mw_path/data/ipv6.pl
echo 'True' > ${PANEL_DIR}/data/ipv6.pl
mw_stop
mw_start
fi
@ -597,8 +597,8 @@ case "$1" in
echo -e "\033[32mMW-Panel default info!\033[0m"
echo -e "=================================================================="
echo -e "$address"
echo -e `python3 $mw_path/tools.py username`
echo -e `python3 $mw_path/tools.py password`
echo -e `python3 ${PANEL_DIR}/panel_tools.py username`
echo -e `python3 ${PANEL_DIR}/panel_tools.py password`
# echo -e "password: $password"
echo -e "\033[33mWarning:\033[0m"
echo -e "\033[33mIf you cannot access the panel. \033[0m"
@ -606,6 +606,6 @@ case "$1" in
echo -e "=================================================================="
;;
*)
cd $mw_path && python3 $mw_path/tools.py cli $1
cd ${PANEL_DIR} && python3 ${PANEL_DIR}/panel_tools.py cli $1
;;
esac

Loading…
Cancel
Save