mirror of https://github.com/helloxz/dnmp.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
1.5 KiB
89 lines
1.5 KiB
11 months ago
|
#!/bin/sh
|
||
|
############### XCDN管理脚本 ###############
|
||
|
# Author:xiaoz.me
|
||
|
# Update:2021-11-17
|
||
|
# Github:https://github.com/helloxz/xcdn
|
||
|
####################### END #######################
|
||
|
|
||
|
#nginx路径
|
||
|
NGINX_PATH="/usr/local/nginx"
|
||
|
nginx="${NGINX_PATH}/sbin/nginx"
|
||
|
|
||
|
#获取用户传递的参数
|
||
|
arg1=$1
|
||
|
|
||
|
if [ "${BRANCH}" = "" ]
|
||
|
then
|
||
|
BRANCH="master"
|
||
|
fi
|
||
|
|
||
|
#启动脚本
|
||
|
function start(){
|
||
|
#运行nginx
|
||
|
$nginx -g "daemon off;" -c /data/xcdn/conf/nginx.conf
|
||
|
#sleep 10
|
||
|
#tail -f /data/xcdn/logs/error.log
|
||
|
}
|
||
|
#停止脚本
|
||
|
function stop() {
|
||
|
#运行nginx
|
||
|
$nginx -c /data/xcdn/conf/nginx.conf -s stop
|
||
|
}
|
||
|
#退出脚本
|
||
|
function quit() {
|
||
|
#运行nginx
|
||
|
$nginx -c /data/xcdn/conf/nginx.conf -s quit
|
||
|
}
|
||
|
|
||
|
#重载配置
|
||
|
function reload(){
|
||
|
$nginx -c /data/xcdn/conf/nginx.conf -t && $nginx -c /data/xcdn/conf/nginx.conf -s reload
|
||
|
}
|
||
|
|
||
|
# 检查配置
|
||
|
function check_conf() {
|
||
|
$nginx -c /data/xcdn/conf/nginx.conf -t
|
||
|
}
|
||
|
|
||
|
#强制更新配置
|
||
|
function update(){
|
||
|
cd /data/xcdn
|
||
|
git pull origin ${BRANCH}
|
||
|
reload
|
||
|
}
|
||
|
|
||
|
#push代码
|
||
|
function push(){
|
||
|
cd /data/xcdn
|
||
|
git add /data/xcdn/conf/*
|
||
|
git add /data/xcdn/ssl/*
|
||
|
git commit -m "$(date +%Y-%m-%d/%H:%m)"
|
||
|
git push origin ${BRANCH}
|
||
|
}
|
||
|
|
||
|
# 根据用户输入执行不同动作
|
||
|
case ${arg1} in
|
||
|
'start')
|
||
|
start
|
||
|
;;
|
||
|
'stop')
|
||
|
stop
|
||
|
;;
|
||
|
'quit')
|
||
|
quit
|
||
|
;;
|
||
|
'reload')
|
||
|
reload
|
||
|
;;
|
||
|
'-t')
|
||
|
check_conf
|
||
|
;;
|
||
|
'update')
|
||
|
update
|
||
|
;;
|
||
|
*)
|
||
|
echo 'Parameter error!'
|
||
|
;;
|
||
|
esac
|
||
|
|