redis-cli
diff --git a/app/utils/header.py b/app/utils/header.py
index 57a264c..5549d2e 100644
--- a/app/utils/header.py
+++ b/app/utils/header.py
@@ -64,19 +64,30 @@ browser=requests.Session()
#获取参数
def GetConfig(key):
- if key=='allow_site':
- value=redis_client.get('allow_site') if redis_client.exists('allow_site') else ','.join(allow_site)
- else:
- value=redis_client.get(key) if redis_client.exists(key) else eval(key)
- #这里是为了储存
- if key=='od_users'and isinstance(value,dict):
- config_path=os.path.join(config_dir,'self_config.py')
- with open(config_path,'r') as f:
- text=f.read()
- value=re.findall('od_users=([\w\W]*})',text)[0]
- # value=json.dumps(value)
- if not redis_client.exists(key):
- redis_client.set(key,value)
+ try:
+ if key=='allow_site':
+ value=redis_client.get('allow_site') if redis_client.exists('allow_site') else ','.join(allow_site)
+ else:
+ value=redis_client.get(key) if redis_client.exists(key) else eval(key)
+ #这里是为了储存
+ if key=='od_users'and isinstance(value,dict):
+ config_path=os.path.join(config_dir,'self_config.py')
+ with open(config_path,'r') as f:
+ text=f.read()
+ value=re.findall('od_users=([\w\W]*})',text)[0]
+ # value=json.dumps(value)
+ if not redis_client.exists(key):
+ redis_client.set(key,value)
+ except:
+ if key=='allow_site':
+ value=','.join(allow_site)
+ else:
+ value=eval(key)
+ if key=='od_users'and isinstance(value,dict):
+ config_path=os.path.join(config_dir,'self_config.py')
+ with open(config_path,'r') as f:
+ text=f.read()
+ value=re.findall('od_users=([\w\W]*})',text)[0]
#这里是为了转为字典
if key=='od_users':
config_path=os.path.join(config_dir,'self_config.py')
@@ -86,6 +97,39 @@ def GetConfig(key):
value=json.loads(value)
return value
+
+############功能函数
+def set(key,value,user=GetConfig('default_pan')):
+ InfoLogger().print_r('set {}:{}'.format(key,value))
+ config_path=os.path.join(config_dir,'self_config.py')
+ if key in ['client_secret','client_id','share_path','other_name','od_type','app_url']:
+ # old_kv=re.findall('"{}":.*{{[\w\W]*}}'.format(user),old_text)[0]
+ # new_kv=re.sub('"{}":.*.*?,'.format(key),'"{}":"{}",'.format(key,value),old_kv,1)
+ # new_text=old_text.replace(old_kv,new_kv,1)
+ od_users[user][key]=value
+ config_path=os.path.join(config_dir,'self_config.py')
+ with open(config_path,'r') as f:
+ old_text=f.read()
+ with open(config_path,'w') as f:
+ old_od=re.findall('od_users={[\w\W]*}',old_text)[0]
+ new_od='od_users='+json.dumps(od_users,indent=4,ensure_ascii=False)
+ new_text=old_text.replace(old_od,new_od,1)
+ f.write(new_text)
+ return
+ with open(config_path,'r') as f:
+ old_text=f.read()
+ with open(config_path,'w') as f:
+ if key=='allow_site':
+ value=value.split(',')
+ new_text=re.sub('{}=.*'.format(key),'{}={}'.format(key,value),old_text)
+ elif key in ['tj_code','cssCode','headCode','footCode','robots']:
+ new_text=re.sub('{}="""[\w\W]*?"""'.format(key),'{}="""{}"""'.format(key,value),old_text)
+ else:
+ new_text=re.sub('{}=.*'.format(key),'{}="{}"'.format(key,value),old_text)
+ f.write(new_text)
+
+
+
#转字符串
def convert2unicode(string):
return string.encode('utf-8')
diff --git a/install.sh b/install.sh
index 4bf8248..f55445b 100755
--- a/install.sh
+++ b/install.sh
@@ -1,130 +1,295 @@
-#!/etc/bash
-function wget_exists(){
- echo "1. 安装wget";
- which wget > /dev/null 2>&1
- if [ $? == 0 ]; then
- echo "wget exist"
- else
- echo "wget dose not exist"
- yum install wget -y
+#!/bin/bash
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+# ====================================================
+# Description:PyOne 一键脚本 for Debian 8+ 、CentOS 7、Ubuntu 16+
+# ====================================================
+
+#fonts color
+Red="\033[31m"
+Font="\033[0m"
+Blue="\033[36m"
+
+
+check_port() {
+ netstat -tlpn | grep "\b$1\b"
+}
+#root permission
+check_root(){
+ if [[ $EUID -ne 0 ]]; then
+ echo "${Red}Error:请使用root运行该脚本!"${Font} 1>&2
+ exit 1
+ fi
+}
+
+#check system
+check_system(){
+ if [[ -f /etc/redhat-release ]]; then
+ release="centos"
+ elif cat /etc/issue | grep -Eqi "debian"; then
+ release="debian"
+ elif cat /etc/issue | grep -Eqi "ubuntu"; then
+ release="ubuntu"
+ elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
+ release="centos"
+ elif cat /proc/version | grep -Eqi "debian"; then
+ release="debian"
+ elif cat /proc/version | grep -Eqi "ubuntu"; then
+ release="ubuntu"
+ elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
+ release="centos"
fi
}
-function git_exists(){
- echo "2. 安装git";
- which git > /dev/null 2>&1
- if [ $? == 0 ]; then
- echo "git exist"
+#check version
+check_version(){
+ if [[ -s /etc/redhat-release ]]; then
+ version=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`
+ else
+ version=`grep -oE "[0-9.]+" /etc/issue | cut -d . -f 1`
+ fi
+ bit=`uname -m`
+ if [[ ${bit} = "x86_64" ]]; then
+ bit="64"
else
- echo "git dose not exist"
- yum install git -y
+ bit="32"
fi
+ if [[ "${release}" = "centos" && ${version} -ge 7 ]];then
+ echo -e "${Blue}当前系统为CentOS ${version}${Font} "
+ elif [[ "${release}" = "debian" && ${version} -ge 8 ]];then
+ echo -e "${Blue}当前系统为Debian ${version}${Font} "
+ elif [[ "${release}" = "ubuntu" && ${version} -ge 16 ]];then
+ echo -e "${Blue}当前系统为Ubuntu ${version}${Font} "
+ else
+ echo -e "${Red}脚本不支持当前系统,安装中断!${Font} "
+ exit 1
+ fi
+ for EXE in grep cut xargs systemctl ip awk
+ do
+ if ! type -p ${EXE}; then
+ echo -e "${Red}系统精简厉害,脚本自动退出${Font}"
+ exit 1
+ fi
+ done
}
-#安装pip
-function pip_exists(){
- echo "3. 安装pip";
- which pip > /dev/null 2>&1
- if [ $? == 0 ]; then
- echo "pip exist"
+
+
+check_service(){
+ read -p "请输入redis端口号[6379]:" redis_port
+ if [ -z "${redis_port}" ];then
+ redis_port=6379
+ fi
+
+ read -p "请输入redis端口号[27017]:" mongo_port
+
+ if [ -z "${mongo_port}" ];then
+ mongo_port=27017
+ fi
+
+
+ if check_port ${redis_port}; then
+ echo ""
else
- echo "pip dose not exist"
- wget https://bootstrap.pypa.io/get-pip.py
- python get-pip.py
- rm -rf get-pip.py
+ echo -e "${Red}Error:请先在宝塔安装redis"${Font} 1>&2
+ exit 1
+ fi
+
+ if check_port ${mongo_port}; then
+ echo ""
+ else
+ echo -e "${Red}Error:请先在宝塔安装MongoDB"${Font} 1>&2
+ exit 1
fi
}
-#安装python依赖包
-function install_(){
- echo "4. 安装python依赖包";
- pip install -r requirements.txt -U
+#enter info
+enter(){
+ stty erase '^H' && read -p "请设置Aria2密钥:" aria2_pass
+ sed -i "s/ARIA2_SECRET=\"abbey\"/ARIA2_SECRET=\"${aria2_pass}\"/g" self_config.py
+
+ read -p "请设置PyOne的后台密码:" pyone_pass
+ sed -i "s/password=\"PyOne\"/password=\"${pyone_pass}\"/g" self_config.py
}
-#配置文件
-function config_file(){
- echo "5. 配置文件";
+
+config_file(){
cur_dir=`pwd`
cp self_config.py.sample self_config.py
- cp supervisord.conf.sample supervisord.conf
- mkdir /var/run/supervisor
- chmod +x /var/run/supervisor
sed -i "s|/root/PyOne|$cur_dir|" self_config.py
- sed -i "s|/root/PyOne|$cur_dir|" supervisord.conf
}
-#添加开机任务
-function auto_boot(){
- echo "6. 配置开机启动";
- cur_dir=`pwd`
- echo "supervisord -c $cur_dir/supervisord.conf" >> /etc/rc.d/rc.local
- echo "sh /data/aria2/aria2.sh start" >> /etc/rc.d/rc.local
- chmod +x /etc/rc.d/rc.local
- # sh /data/arai2/aria2.sh start
-}
-#安装aria2
-function install_aria2(){
- echo "7. 安装aria2";
- which aria2c > /dev/null 2>&1
- if [ $? == 0 ]; then
- echo "检测到已安装aria2"
- echo "请到后台配置aria2信息"
- echo "如果您配置了aria2授权信息,请确保是rpc-secret模式!如果不是,则不能正常工作。"
- echo "开启rpc-secret模式方法:"
- echo " >1. 编辑aria2的配置文件,将rpc-secret这一行反注释,然后'rpc-secret='后面填写密码"
- echo " >2. 将rpc-user和rpc-passwd注释掉"
- echo " >3. 重启aria2"
+#install depend
+install_depend(){
+echo -e "${Blue}开始安装依赖${Font}"
+ if [[ "${release}" = "centos" ]]; then
+ yum -y install make git gcc crontabs lsof unzip python-devel libffi-devel openssl-devel -y
else
- git clone https://github.com/abbeyokgo/aria2_installer.git
- cd aria2_installer
- sh install_aria2.sh
- echo "安装aria2完成"
- echo "如果已经成功安装,请到后台配置aria2信息"
- cd ..
- rm -rf aria2_installer
+ apt update -y
+ apt install -y make git cron build-essential python-dev lsof unzip python-setuptools python-wheel libffi-devel libssl-dev
fi
}
-#开放端口
-function open_port(){
- if [ -e "/etc/sysconfig/iptables" ]
- then
- iptables -I INPUT -p tcp --dport 34567 -j ACCEPT
- service iptables save
- service iptables restart
+
+#install aria2
+install_aria2(){
+ echo -e "${Blue}开始安装Aria2...${Font}"
+ wget -N --no-check-certificate https://www.moerats.com/usr/shell/PyOne/aria2-1.34.0-linux-${bit}.tar.gz
+ tar zxvf aria2-1.34.0-linux-${bit}.tar.gz
+ rm -rf aria2-1.34.0-linux-${bit}.tar.gz
+ cd aria2-1.34.0-linux-${bit}
+ make install
+ EXEC="$(command -v aria2c)"
+ if [[ -n ${EXEC} ]]; then
+ echo -e "${Blue}Aria2安装成功!${Font}"
else
- firewall-cmd --zone=public --add-port=34567/tcp --permanent
- firewall-cmd --reload
+ echo -e "${Red}Aria2安装失败!${Font}"
+ exit 1
fi
+ cd ..
+ rm -rf aria2-1.34.0-linux-${bit}
+ mkdir "/root/.aria2" && mkdir /root/Download
+ wget -N --no-check-certificate https://www.moerats.com/usr/shell/Aria2/dht.dat -P '/root/.aria2/'
+ wget -N --no-check-certificate https://www.moerats.com/usr/shell/PyOne/aria2.conf -P '/root/.aria2/'
+ wget -N --no-check-certificate https://www.moerats.com/usr/shell/PyOne/trackers-list-aria2.sh -P '/root/.aria2/'
+ touch /root/.aria2/aria2.session
+ chmod +x /root/.aria2/trackers-list-aria2.sh
+ chmod 777 /root/.aria2/aria2.session
+ sed -i "s/rpc-secret=/rpc-secret=${pass}/g" /root/.aria2/aria2.conf
+ echo -e "${Blue}开始设置trackers-list自动更新!${Font}"
+ if [[ "${release}" = "centos" ]]; then
+ echo "0 0 */7 * * /root/.aria2/trackers-list-aria2.sh" >> /var/spool/cron/root
+ else
+ echo "0 0 */7 * * /root/.aria2/trackers-list-aria2.sh" >> /var/spool/cron/crontabs/root
+ fi
+}
+
+#install pyone
+install_pip(){
+ echo -e "${Blue}正在安装pip!${Font}"
+ if [[ "${release}" = "centos" ]]; then
+ yum install -y python-pip
+ EXEC="$(command -v pip)"
+ if [[ -z ${EXEC} ]]; then
+ wget https://bootstrap.pypa.io/get-pip.py
+ python get-pip.py
+ fi
+ else
+ apt -y install python-pip
+ fi
+ EXEC="$(command -v pip)"
+ if [[ -n ${EXEC} ]]; then
+ echo -e "${Blue}pip安装成功!${Font}"
+ else
+ echo -e "${Red}pip安装失败!${Font}"
+ exit 1
+ fi
+
+}
+
+install_package(){
+ pip2 install -r requirements.txt
+}
+
+
+
+#open firewall
+firewall(){
+ if [[ "${release}" = "centos" ]]; then
+ firewall-cmd --zone=public --add-port=6800/tcp --permanent
+ firewall-cmd --zone=public --add-port=34567/tcp --permanent
+ firewall-cmd --zone=public --add-port=80/tcp --permanent
+ firewall-cmd --zone=public --add-port=443/tcp --permanent
+ firewall-cmd --reload
+ fi
}
+#set start up
+start(){
+ echo -e "${Blue}正在为相关应用设置开机自启!${Font}"
+echo "[Unit]
+Description=Aria2 server
+After=network.target
+Wants=network.target
+
+[Service]
+Type=simple
+PIDFile=/var/run/aria2c.pid
+ExecStart=/usr/bin/aria2c --conf-path=/root/.aria2/aria2.conf
+RestartPreventExitStatus=23
+Restart=always
+User=root
+
+[Install]
+WantedBy=multi-user.target
+" > '/etc/systemd/system/aria2.service'
+echo "[Unit]
+Description=pyone
+After=network.target
+Wants=network.target
-#执行
-install_
-config_file
-#auto_boot
-#install_aria2
-open_port
-yum install gcc libffi-devel python-devel openssl-devel -y
-yum install lsof -y
-mkdir logs
-echo "---------------------------------------------------------------"
-echo "一键脚本运行完成!请检查以下文件:"
-echo " > 1. self_config.py、supervisord.conf是否存在!"
-echo " > 2. 检查self_config.py、supervisord.conf脚本里面的目录是否正确!"
-echo " > 3. 请确保已经安装Nginx、Redis、MongoDB,并已经运行!"
-echo " > 4. 检查/data/aria2是否存在。"
-echo " > 5. 检查aria2是否运行:pgrep 'aria2c'"
-echo " 如果aria2没有运行,运行:sh /data/aria2/aria2.sh start"
-echo
-echo "如果检查没有问题!在网站目录可运行以下脚本运行网站"
-echo "supervisord -c supervisord.conf"
-echo "---------------------------------------------------------------"
-echo
-echo "PyOne交流群:864996565"
-echo "PyOne交流群TG:https://t.me/joinchat/JQOOug6MY11gy_MiXTmqIA"
+[Service]
+Type=simple
+PIDFile=/var/run/pyone.pid
+WorkingDirectory=/root/PyOne
+ExecStart=gunicorn -keventlet -b 0.0.0.0:34567 run:app
+RestartPreventExitStatus=23
+Restart=always
+User=root
+
+[Install]
+WantedBy=multi-user.target
+" > '/etc/systemd/system/pyone.service'
+
+ EXEC="$(command -v gunicorn)"
+ sed -i "s#gunicorn#${EXEC}#g" /etc/systemd/system/pyone.service
+ systemctl start aria2 pyone
+ systemctl enable aria2 pyone
+}
+
+#Complete info
+info(){
+ local_ip=`curl http://whatismyip.akamai.com`
+ echo -e "———————————————————————————————————————"
+ echo -e "${Blue}PyOne安装完成!${Font}"
+ echo -e "${Blue}请通过访问:http://${local_ip}:34567 继续后面的安装${Font}"
+ echo -e "${Blue}PyOne后台密码:${pyone_pass}${Font}"
+ echo -e "${Blue}Aria2密匙:${aria2_pass}${Font}"
+ echo -e "${Blue}常用命令:${Font}"
+ echo -e "${Blue}1. 暂停PyOne: systemctl stop pyone${Font}"
+ echo -e "${Blue}2. 启动PyOne: systemctl start pyone${Font}"
+ echo -e "${Blue}3. 重启PyOne: systemctl restart pyone${Font}"
+ echo -e "${Blue}4. 手动运行PyOne: systemctl stop pyone && gunicorn -keventlet -b 0:34567 run:app${Font}"
+ echo -e "———————————————————————————————————————"
+ echo -e "${Blue}PyOne交流群:864996565${Font}"
+ echo -e "${Blue}PyOne交流群TG:https://t.me/joinchat/JQOOug6MY11gy_MiXTmqIA${Font}"
+}
+
+#start menu
+main(){
+ check_root
+ check_system
+ check_version
+ check_service
+ clear
+ echo -e "———————————————————————————————————————"
+ echo -e "${Blue}PyOne一键脚本 for Debian 8+ 、CentOS 7、Ubuntu 16+${Font}"
+ echo -e "本脚本参考【萌鼠博客】:https://www.moerats.com/archives/806/"
+ echo -e "${Blue}安装之前请确保已经在安装宝塔,并且在宝塔-软件管理已经安装MongoDB和redis${Font}"
+ echo -e "———————————————————————————————————————"
+ config_file
+ enter
+ install_depend
+ install_aria2
+ install_pip
+ install_package
+ firewall
+ start
+ info
+}
+main
diff --git a/run.py b/run.py
index 88482bc..45179aa 100755
--- a/run.py
+++ b/run.py
@@ -2,6 +2,7 @@
import eventlet
eventlet.monkey_patch()
import os
+import traceback
from flask_script import Manager, Shell
from app import create_app
from self_config import *
@@ -30,25 +31,58 @@ if REDIS_PASSWORD!="":
else:
pool = ConnectionPool(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB)
tmp_rd=Redis(connection_pool=pool)
-tmp_rd.set('title',title)
-tmp_rd.set('tj_code',tj_code)
-tmp_rd.set('downloadUrl_timeout',downloadUrl_timeout)
-tmp_rd.set('allow_site',','.join(allow_site))
-tmp_rd.set('ARIA2_HOST',ARIA2_HOST)
-tmp_rd.set('ARIA2_PORT',ARIA2_PORT)
-tmp_rd.set('ARIA2_SECRET',ARIA2_SECRET)
-tmp_rd.set('ARIA2_SCHEME',ARIA2_SCHEME)
-tmp_rd.set('password',password)
-tmp_rd.set('verify_url',verify_url)
-tmp_rd.set('balance',balance)
-tmp_rd.set('admin_prefix',admin_prefix)
-tmp_rd.set('thread_num',thread_num)
-config_path=os.path.join(config_dir,'self_config.py')
-with open(config_path,'r') as f:
- text=f.read()
-tmp_rd.set('users',re.findall('od_users=([\w\W]*})',text)[0])
-key='themelist'
-tmp_rd.delete(key)
+try:
+ tmp_rd.set("allow_site",','.join(allow_site))
+ tmp_rd.set("downloadUrl_timeout",downloadUrl_timeout)
+ tmp_rd.set("password",password)
+ tmp_rd.set("title",title)
+ tmp_rd.set("tj_code",tj_code)
+ tmp_rd.set("headCode",headCode)
+ tmp_rd.set("footCode",footCode)
+ tmp_rd.set("cssCode",cssCode)
+ tmp_rd.set("robots",robots)
+ tmp_rd.set("theme",theme)
+ tmp_rd.set("title_pre",title_pre)
+ tmp_rd.set("redirect_uri",redirect_uri)
+ tmp_rd.set("BaseAuthUrl",BaseAuthUrl)
+ tmp_rd.set("app_url",app_url)
+ tmp_rd.set("ARIA2_HOST",ARIA2_HOST)
+ tmp_rd.set("ARIA2_PORT",ARIA2_PORT)
+ tmp_rd.set("ARIA2_SECRET",ARIA2_SECRET)
+ tmp_rd.set("ARIA2_SCHEME",ARIA2_SCHEME)
+ tmp_rd.set("MONGO_HOST",MONGO_HOST)
+ tmp_rd.set("MONGO_PORT",MONGO_PORT)
+ tmp_rd.set("MONGO_USER",MONGO_USER)
+ tmp_rd.set("MONGO_PASSWORD",MONGO_PASSWORD)
+ tmp_rd.set("MONGO_DB",MONGO_DB)
+ tmp_rd.set("REDIS_HOST",REDIS_HOST)
+ tmp_rd.set("REDIS_PORT",REDIS_PORT)
+ tmp_rd.set("REDIS_PASSWORD",REDIS_PASSWORD)
+ tmp_rd.set("REDIS_DB",REDIS_DB)
+ tmp_rd.set("show_secret",show_secret)
+ tmp_rd.set("default_sort",default_sort)
+ tmp_rd.set("order_m",order_m)
+ tmp_rd.set("encrypt_file",encrypt_file)
+ tmp_rd.set("default_pan",default_pan)
+ tmp_rd.set("admin_prefix",admin_prefix)
+ tmp_rd.set("balance",balance)
+ tmp_rd.set("thread_num",thread_num)
+ tmp_rd.set("verify_url",verify_url)
+ tmp_rd.set("show_doc",show_doc)
+ tmp_rd.set("show_image",show_image)
+ tmp_rd.set("show_video",show_video)
+ tmp_rd.set("show_dash",show_dash)
+ tmp_rd.set("show_audio",show_audio)
+ tmp_rd.set("show_code",show_code)
+ tmp_rd.set("show_redirect",show_redirect)
+ config_path=os.path.join(config_dir,'self_config.py')
+ with open(config_path,'r') as f:
+ text=f.read()
+ tmp_rd.set('users',re.findall('od_users=([\w\W]*})',text)[0])
+ key='themelist'
+ tmp_rd.delete(key)
+except:
+ print('\033[31m redis鉴权失败!请注意修改!\033[0m')
######################函数
app.jinja_env.globals['version']=config.version
app.jinja_env.globals['FetchData']=FetchData
diff --git a/update.sh b/update.sh
index b85c706..4c9d1d4 100755
--- a/update.sh
+++ b/update.sh
@@ -1,5 +1,61 @@
#!/etc/bash
+
+#check system
+check_system(){
+ if [[ -f /etc/redhat-release ]]; then
+ release="centos"
+ elif cat /etc/issue | grep -Eqi "debian"; then
+ release="debian"
+ elif cat /etc/issue | grep -Eqi "ubuntu"; then
+ release="ubuntu"
+ elif cat /etc/issue | grep -Eqi "centos|red hat|redhat"; then
+ release="centos"
+ elif cat /proc/version | grep -Eqi "debian"; then
+ release="debian"
+ elif cat /proc/version | grep -Eqi "ubuntu"; then
+ release="ubuntu"
+ elif cat /proc/version | grep -Eqi "centos|red hat|redhat"; then
+ release="centos"
+ fi
+}
+
+#check version
+check_version(){
+ if [[ -s /etc/redhat-release ]]; then
+ version=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`
+ else
+ version=`grep -oE "[0-9.]+" /etc/issue | cut -d . -f 1`
+ fi
+ bit=`uname -m`
+ if [[ ${bit} = "x86_64" ]]; then
+ bit="64"
+ else
+ bit="32"
+ fi
+ if [[ "${release}" = "centos" && ${version} -ge 7 ]];then
+ echo -e "${Blue}当前系统为CentOS ${version}${Font} "
+ elif [[ "${release}" = "debian" && ${version} -ge 8 ]];then
+ echo -e "${Blue}当前系统为Debian ${version}${Font} "
+ elif [[ "${release}" = "ubuntu" && ${version} -ge 16 ]];then
+ echo -e "${Blue}当前系统为Ubuntu ${version}${Font} "
+ else
+ echo -e "${Red}脚本不支持当前系统,安装中断!${Font} "
+ exit 1
+ fi
+ for EXE in grep cut xargs systemctl ip awk
+ do
+ if ! type -p ${EXE}; then
+ echo -e "${Red}系统精简厉害,脚本自动退出${Font}"
+ exit 1
+ fi
+ done
+}
+
+check_system
+check_version
+
+
#11.20
del_rubbish(){
python -c "from function import *;mon_db.down_db.delete_many({});"
@@ -97,9 +153,6 @@ Disallow: /
}
-
-
-
#2019.02.15
upgrade_to4(){
echo '-------------------------------'
@@ -115,15 +168,13 @@ upgrade(){
touch .install
fi
update_config
- yum install gcc libffi-devel python-devel openssl-devel -y
- pip install -r requirements.txt
- which lsof > /dev/null 2>&1
- if [ $? == 0 ]; then
- echo "lsof exist"
+ if [[ "${release}" = "centos" ]]; then
+ yum install gcc libffi-devel python-devel openssl-devel lsof -y
else
- echo "lsof dose not exist"
- yum install lsof -y
+ apt update -y
+ apt install -y make git cron build-essential python-dev lsof unzip python-setuptools python-wheel libffi-devel libssl-dev
fi
+ pip install -r requirements.txt
}
change_redirect(){
@@ -132,7 +183,12 @@ change_redirect(){
restart(){
- supervisorctl -c supervisord.conf restart pyone
+ num=`ls /etc/systemd/system | grep pyone.service | wc -l`
+ if [ $num == 0 ]; then
+ supervisorctl -c supervisord.conf restart pyone
+ else
+ systemctl restart pyone
+ fi
}
#执行
@@ -187,6 +243,7 @@ echo "2019.05.29更新版本:支持自定义线程数"
echo "2019.05.31更新版本:新增功能:1)下载链接验证开关;优化:1)aria2信息不对时,无法添加任务"
echo "2019.06.13更新版本:新增功能:文件展示设置"
echo "2019.06.14更新版本:稍微完善一下日志记录;分享页面取消token验证;修复开启下载验证之后,后台文件打开失败的bug;新增内嵌窗口"
+echo "2019.07.24更新版本:1. 优化安装脚本,适应Centos7、Debian9+、Ubuntu16+等系统;2、优化安装流程"
echo "---------------------------------------------------------------"
echo "更新完成!"
echo "如果网站无法访问,请检查config.py!"