From 104f3aecf5aae58d2e8c147418f4a97420a86c88 Mon Sep 17 00:00:00 2001 From: xcsoft Date: Tue, 21 Jun 2022 12:29:58 +0800 Subject: [PATCH 1/9] Create mds-cli --- mds-cli | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 mds-cli diff --git a/mds-cli b/mds-cli new file mode 100644 index 000000000..907f97f34 --- /dev/null +++ b/mds-cli @@ -0,0 +1,73 @@ +#!/www/server/mdserver-web/bin/python +# description: mdserver-web cli tools +# ln -s /www/server/mdserver-web/mds-cli /usr/bin/mds-cli +import os +import sys + +def mw_start(): + """ + Start mdserver-web + """ + os.system('bash cli.sh start') + print("服务已启动") + + +def mw_stop(): + """ + stop mdserver-web + """ + os.system('bash cli.sh stop') + print("服务已停止") + +def mw_restart(): + """ + restart mdserver-web + """ + os.system('bash cli.sh stop && bash cli.sh start') + print("服务已重启") + +def mw_reset_username(): + """ + reset mdserver-web username + """ + from tools import set_panel_username + user_name = input("请输入新的用户名: ") + set_panel_username(user_name) + +def mw_reset_pwd(): + """ + reset mdserver-web password + """ + from tools import set_panel_pwd + pwd = input("请输入新的密码: ") + set_panel_pwd(pwd, True) + + +if __name__ == '__main__': + sys.path.append(os.getcwd() + "/class/core") + + try: + str = ''' + ==== mdserver-web cli tools ==== + 1. 启动服务 2. 停止服务 + 3. 重启服务 4. 修改用户名 + 5. 修改密码 + ================================= + ''' + print(str) + sw = input("请输入您要进行的操作: ") + + if sw == '1': + mw_start() + elif sw == '2': + mw_stop() + elif sw == '3': + mw_restart() + elif sw == '4': + mw_reset_username() + elif sw == '5': + mw_reset_pwd() + else: + print("操作不存在") + except KeyboardInterrupt: + print("\n操作已终止") From d252ab9aa85e52c0fd45dc4c5a3989097cb3806f Mon Sep 17 00:00:00 2001 From: xcsoft Date: Tue, 21 Jun 2022 12:30:54 +0800 Subject: [PATCH 2/9] add mds-cli --- scripts/install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install.sh b/scripts/install.sh index 44552dddb..9d894d9af 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -74,7 +74,8 @@ fi echo "use system version: ${OSNAME}" curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install/${OSNAME}.sh | bash +ln -s /www/server/mdserver-web/mds-cli /usr/bin/mds-cli endTime=`date +%s` ((outTime=(${endTime}-${startTime})/60)) -echo -e "Time consumed:\033[32m $outTime \033[0mMinute!" \ No newline at end of file +echo -e "Time consumed:\033[32m $outTime \033[0mMinute!" From 381e941cf138ba178e821726f756e631508aa138 Mon Sep 17 00:00:00 2001 From: xcsoft Date: Tue, 21 Jun 2022 12:32:56 +0800 Subject: [PATCH 3/9] Update install.sh --- scripts/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install.sh b/scripts/install.sh index 9d894d9af..814cfbc95 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -74,6 +74,7 @@ fi echo "use system version: ${OSNAME}" curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install/${OSNAME}.sh | bash +chmod +x /www/server/mdserver-web/mds-cli ln -s /www/server/mdserver-web/mds-cli /usr/bin/mds-cli endTime=`date +%s` From d0a449a57237b7665d20cba85371cb25b0c87969 Mon Sep 17 00:00:00 2001 From: xcsoft Date: Tue, 21 Jun 2022 12:37:42 +0800 Subject: [PATCH 4/9] Update mds-cli --- mds-cli | 1 + 1 file changed, 1 insertion(+) diff --git a/mds-cli b/mds-cli index 907f97f34..2ff326018 100644 --- a/mds-cli +++ b/mds-cli @@ -44,6 +44,7 @@ def mw_reset_pwd(): if __name__ == '__main__': + os.chdir("/www/server/mdserver-web") sys.path.append(os.getcwd() + "/class/core") try: From b60689bc707079f0b654564ee1a5d33ef9e2f4c8 Mon Sep 17 00:00:00 2001 From: soxft Date: Tue, 21 Jun 2022 12:52:28 +0800 Subject: [PATCH 5/9] fix --- mds-cli => mw-cli | 29 ++++++++++++++++++----------- scripts/install.sh | 4 ++-- 2 files changed, 20 insertions(+), 13 deletions(-) rename mds-cli => mw-cli (79%) diff --git a/mds-cli b/mw-cli similarity index 79% rename from mds-cli rename to mw-cli index 2ff326018..8d5f63f10 100644 --- a/mds-cli +++ b/mw-cli @@ -1,31 +1,34 @@ #!/www/server/mdserver-web/bin/python # description: mdserver-web cli tools -# ln -s /www/server/mdserver-web/mds-cli /usr/bin/mds-cli +# ln -s /www/server/mdserver-web/mw-cli /usr/bin/mw-cli import os import sys + def mw_start(): """ Start mdserver-web """ - os.system('bash cli.sh start') + os.system('systemctl start mw') print("服务已启动") - - + + def mw_stop(): """ stop mdserver-web """ - os.system('bash cli.sh stop') + os.system('systemctl stop mw') print("服务已停止") + def mw_restart(): """ restart mdserver-web """ - os.system('bash cli.sh stop && bash cli.sh start') + os.system('systemctl restart mw') print("服务已重启") + def mw_reset_username(): """ reset mdserver-web username @@ -33,7 +36,8 @@ def mw_reset_username(): from tools import set_panel_username user_name = input("请输入新的用户名: ") set_panel_username(user_name) - + + def mw_reset_pwd(): """ reset mdserver-web password @@ -44,9 +48,9 @@ def mw_reset_pwd(): if __name__ == '__main__': - os.chdir("/www/server/mdserver-web") + os.chdir("/www/server/mdserver-web") sys.path.append(os.getcwd() + "/class/core") - + try: str = ''' ==== mdserver-web cli tools ==== @@ -55,8 +59,11 @@ if __name__ == '__main__': 5. 修改密码 ================================= ''' - print(str) - sw = input("请输入您要进行的操作: ") + if len(sys.argv) == 2: + sw = sys.argv[1] + else: + print(str) + sw = input("请输入您要进行的操作: ") if sw == '1': mw_start() diff --git a/scripts/install.sh b/scripts/install.sh index 814cfbc95..25f0f0f00 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -74,8 +74,8 @@ fi echo "use system version: ${OSNAME}" curl -fsSL https://raw.githubusercontent.com/midoks/mdserver-web/master/scripts/install/${OSNAME}.sh | bash -chmod +x /www/server/mdserver-web/mds-cli -ln -s /www/server/mdserver-web/mds-cli /usr/bin/mds-cli +chmod +x /www/server/mdserver-web/mw-cli +ln -s /www/server/mdserver-web/mw-cli /usr/bin/mw-cli endTime=`date +%s` ((outTime=(${endTime}-${startTime})/60)) From 2805b7bdc49db230a572099cb0dce7c3821fa805 Mon Sep 17 00:00:00 2001 From: soxft Date: Tue, 21 Jun 2022 12:57:29 +0800 Subject: [PATCH 6/9] remove * --- scripts/init.d/mw.tpl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 4c5192f11..437b3a662 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -185,13 +185,11 @@ case "$1" in if [ -f $mw_path/data/admin_path.pl ];then auth_path=$(cat $mw_path/data/admin_path.pl) fi - if [ "$address" = "" ];then - address=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress) - fi + echo -e "==================================================================" echo -e "\033[32mMW-Panel default info!\033[0m" echo -e "==================================================================" - echo "MW-Panel-URL: http://$address:$port$auth_path" + echo -e "MW-Panel-URL: http://$address:$port$auth_path" echo -e `python3 $mw_path/tools.py username` echo -e "password: $password" echo -e "\033[33mWarning:\033[0m" From 8a1153827916ab5ecf67082ec300285cd76c4878 Mon Sep 17 00:00:00 2001 From: xcsoft Date: Tue, 21 Jun 2022 17:34:32 +0800 Subject: [PATCH 7/9] fix: remove config file when uninstall --- plugins/xhprof/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/xhprof/install.sh b/plugins/xhprof/install.sh index 14af37c44..938a854d7 100755 --- a/plugins/xhprof/install.sh +++ b/plugins/xhprof/install.sh @@ -26,6 +26,7 @@ Uninstall_xh() { rm -rf ${serverPath}/xhprof cd /tmp/xhprof && rm -rf *.xhprof + rm -f /www/server/web_conf/nginx/vhost/xhprof.conf echo '卸载完成' > $install_tmp } From 71c03e2440888e6181dba787cb8cc21d24836b2d Mon Sep 17 00:00:00 2001 From: xcsoft Date: Tue, 21 Jun 2022 11:05:57 +0000 Subject: [PATCH 8/9] fix: static site --- .gitignore | 2 +- plugins/openresty/install.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1f01fc2e6..aae13447a 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,4 @@ pyvenv.cfg include data/api_login.txt data/sessions -data/ssl.pl +data/ssl.pl diff --git a/plugins/openresty/install.sh b/plugins/openresty/install.sh index 3676c3bc5..53ae30979 100755 --- a/plugins/openresty/install.sh +++ b/plugins/openresty/install.sh @@ -43,8 +43,7 @@ Install_openresty() --with-http_slice_module \ --with-http_stub_status_module && make && make install && \ echo "${VERSION}" > $serverPath/openresty/version.pl - - + echo "" > $serverPath/web_conf/nginx/enable-php-00.conf echo '安装完成' > $install_tmp } From a33c151ed891b4728adb754a334ee810c68e1bdc Mon Sep 17 00:00:00 2001 From: xcsoft Date: Tue, 21 Jun 2022 20:17:55 +0800 Subject: [PATCH 9/9] fix --- scripts/init.d/mw.tpl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/init.d/mw.tpl b/scripts/init.d/mw.tpl index 437b3a662..c59f86a7f 100755 --- a/scripts/init.d/mw.tpl +++ b/scripts/init.d/mw.tpl @@ -185,6 +185,9 @@ case "$1" in if [ -f $mw_path/data/admin_path.pl ];then auth_path=$(cat $mw_path/data/admin_path.pl) fi + if [ "$address" = "" ];then + address=$(curl -sS --connect-timeout 10 -m 60 https://v6r.ipip.net/?format=text) + fi echo -e "==================================================================" echo -e "\033[32mMW-Panel default info!\033[0m" @@ -197,4 +200,4 @@ case "$1" in echo -e "\033[33mrelease the following port (7200|888|80|443|20|21) in the security group\033[0m" echo -e "==================================================================" ;; -esac \ No newline at end of file +esac