Merge pull request #75 from soxft/dev

#72
This commit is contained in:
Mr Chen 2022-06-21 20:26:29 +08:00 committed by GitHub
commit 9036c03b5f
6 changed files with 92 additions and 8 deletions

2
.gitignore vendored
View File

@ -129,4 +129,4 @@ pyvenv.cfg
include
data/api_login.txt
data/sessions
data/ssl.pl
data/ssl.pl

81
mw-cli Normal file
View File

@ -0,0 +1,81 @@
#!/www/server/mdserver-web/bin/python
# description: mdserver-web cli tools
# ln -s /www/server/mdserver-web/mw-cli /usr/bin/mw-cli
import os
import sys
def mw_start():
"""
Start mdserver-web
"""
os.system('systemctl start mw')
print("服务已启动")
def mw_stop():
"""
stop mdserver-web
"""
os.system('systemctl stop mw')
print("服务已停止")
def mw_restart():
"""
restart mdserver-web
"""
os.system('systemctl restart mw')
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__':
os.chdir("/www/server/mdserver-web")
sys.path.append(os.getcwd() + "/class/core")
try:
str = '''
==== mdserver-web cli tools ====
1. 启动服务 2. 停止服务
3. 重启服务 4. 修改用户名
5. 修改密码
=================================
'''
if len(sys.argv) == 2:
sw = sys.argv[1]
else:
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操作已终止")

View File

@ -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
}

View File

@ -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
}

View File

@ -185,13 +185,14 @@ 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)
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"
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"
@ -199,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
esac

View File

@ -74,7 +74,9 @@ 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/mw-cli
ln -s /www/server/mdserver-web/mw-cli /usr/bin/mw-cli
endTime=`date +%s`
((outTime=(${endTime}-${startTime})/60))
echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"