update caddy service

pull/384/head
233boy 5 years ago
parent 37bd9a1d32
commit eab685736c
  1. 86
      src/download-caddy.sh
  2. 2
      v2ray.sh

@ -1,32 +1,32 @@
_download_caddy_file() { _download_caddy_file() {
# caddy_tmp="/tmp/install_caddy/" caddy_tmp="/tmp/install_caddy/"
# caddy_tmp_file="/tmp/install_caddy/caddy.tar.gz" caddy_tmp_file="/tmp/install_caddy/caddy.tar.gz"
# [[ -d $caddy_tmp ]] && rm -rf $caddy_tmp [[ -d $caddy_tmp ]] && rm -rf $caddy_tmp
# if [[ ! ${caddy_arch} ]]; then if [[ ! ${caddy_arch} ]]; then
# echo -e "$red 获取 Caddy 下载参数失败!$none" && exit 1 echo -e "$red 获取 Caddy 下载参数失败!$none" && exit 1
# fi fi
# local caddy_download_link="https://caddyserver.com/download/linux/${caddy_arch}?license=personal" local caddy_download_link="https://caddyserver.com/download/linux/${caddy_arch}?license=personal"
# mkdir -p $caddy_tmp mkdir -p $caddy_tmp
# if ! wget --no-check-certificate -O "$caddy_tmp_file" $caddy_download_link; then if ! wget --no-check-certificate -O "$caddy_tmp_file" $caddy_download_link; then
# echo -e "$red 下载 Caddy 失败!$none" && exit 1 echo -e "$red 下载 Caddy 失败!$none" && exit 1
# fi fi
# tar zxf $caddy_tmp_file -C $caddy_tmp tar zxf $caddy_tmp_file -C $caddy_tmp
# cp -f ${caddy_tmp}caddy /usr/local/bin/ cp -f ${caddy_tmp}caddy /usr/local/bin/
wget -qO- https://getcaddy.com | bash -s personal # wget -qO- https://getcaddy.com | bash -s personal
if [[ ! -f /usr/local/bin/caddy ]]; then if [[ ! -f /usr/local/bin/caddy ]]; then
echo -e "$red 安装 Caddy 出错!$none" && exit 1 echo -e "$red 安装 Caddy 出错!$none" && exit 1
fi fi
} }
_install_caddy_service() { _install_caddy_service() {
# setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/caddy setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/caddy
if [[ $systemd ]]; then if [[ $systemd ]]; then
# cp -f ${caddy_tmp}init/linux-systemd/caddy.service /lib/systemd/system/ cp -f ${caddy_tmp}init/linux-systemd/caddy.service /lib/systemd/system/
# # sed -i "s/www-data/root/g" /lib/systemd/system/caddy.service # # sed -i "s/www-data/root/g" /lib/systemd/system/caddy.service
# sed -i "/on-abnormal/a RestartSec=3" /lib/systemd/system/caddy.service # sed -i "/on-abnormal/a RestartSec=3" /lib/systemd/system/caddy.service
# sed -i "s/on-abnormal/always/" /lib/systemd/system/caddy.service # sed -i "s/on-abnormal/always/" /lib/systemd/system/caddy.service
@ -34,28 +34,28 @@ _install_caddy_service() {
#### 。。。。。 Warning.....Warning.......Warning........Warning...... #### 。。。。。 Warning.....Warning.......Warning........Warning......
#### 。。。。。 use root user run caddy... #### 。。。。。 use root user run caddy...
cat >/lib/systemd/system/caddy.service <<-EOF # cat >/lib/systemd/system/caddy.service <<-EOF
[Unit] # [Unit]
Description=Caddy HTTP/2 web server # Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs # Documentation=https://caddyserver.com/docs
After=network.target # After=network.target
Wants=network.target # Wants=network.target
[Service] # [Service]
Restart=always # Restart=always
RestartSec=3 # RestartSec=3
Environment=CADDYPATH=/root/.caddy # Environment=CADDYPATH=/root/.caddy
ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp # ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp
ExecReload=/bin/kill -USR1 $MAINPID # ExecReload=/bin/kill -USR1 $MAINPID
KillMode=mixed # KillMode=mixed
KillSignal=SIGQUIT # KillSignal=SIGQUIT
TimeoutStopSec=5s # TimeoutStopSec=5s
LimitNOFILE=1048576 # LimitNOFILE=1048576
LimitNPROC=512 # LimitNPROC=512
[Install] # [Install]
WantedBy=multi-user.target # WantedBy=multi-user.target
EOF # EOF
systemctl enable caddy systemctl enable caddy
else else
cp -f ${caddy_tmp}init/linux-sysvinit/caddy /etc/init.d/caddy cp -f ${caddy_tmp}init/linux-sysvinit/caddy /etc/init.d/caddy
@ -64,18 +64,18 @@ _install_caddy_service() {
update-rc.d -f caddy defaults update-rc.d -f caddy defaults
fi fi
# if [ -z "$(grep www-data /etc/passwd)" ]; then if [ -z "$(grep www-data /etc/passwd)" ]; then
# useradd -M -s /usr/sbin/nologin www-data useradd -M -s /usr/sbin/nologin www-data
# fi fi
# chown -R www-data.www-data /etc/ssl/caddy # chown -R www-data.www-data /etc/ssl/caddy
# ref https://github.com/caddyserver/caddy/tree/master/dist/init/linux-systemd # ref https://github.com/caddyserver/caddy/tree/master/dist/init/linux-systemd
mkdir -p /etc/caddy mkdir -p /etc/caddy
# chown -R root:root /etc/caddy chown -R root:root /etc/caddy
# mkdir -p /etc/ssl/caddy mkdir -p /etc/ssl/caddy
# chown -R root:www-data /etc/ssl/caddy chown -R root:www-data /etc/ssl/caddy
# chmod 0770 /etc/ssl/caddy chmod 0770 /etc/ssl/caddy
## create sites dir ## create sites dir
mkdir -p /etc/caddy/sites mkdir -p /etc/caddy/sites

@ -10,7 +10,7 @@ none='\e[0m'
# Root # Root
[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1 [[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1
_version="v3.15" _version="v3.16"
cmd="apt-get" cmd="apt-get"

Loading…
Cancel
Save