From eab685736ce93acd7494ae7ff301fa2d96fcc244 Mon Sep 17 00:00:00 2001 From: 233boy <31657650+233boy@users.noreply.github.com> Date: Fri, 11 Oct 2019 14:14:37 +0800 Subject: [PATCH] update caddy service --- src/download-caddy.sh | 86 +++++++++++++++++++++---------------------- v2ray.sh | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/download-caddy.sh b/src/download-caddy.sh index 42498ad..692386f 100644 --- a/src/download-caddy.sh +++ b/src/download-caddy.sh @@ -1,32 +1,32 @@ _download_caddy_file() { - # caddy_tmp="/tmp/install_caddy/" - # caddy_tmp_file="/tmp/install_caddy/caddy.tar.gz" - # [[ -d $caddy_tmp ]] && rm -rf $caddy_tmp - # if [[ ! ${caddy_arch} ]]; then - # echo -e "$red 获取 Caddy 下载参数失败!$none" && exit 1 - # fi - # local caddy_download_link="https://caddyserver.com/download/linux/${caddy_arch}?license=personal" + caddy_tmp="/tmp/install_caddy/" + caddy_tmp_file="/tmp/install_caddy/caddy.tar.gz" + [[ -d $caddy_tmp ]] && rm -rf $caddy_tmp + if [[ ! ${caddy_arch} ]]; then + echo -e "$red 获取 Caddy 下载参数失败!$none" && exit 1 + fi + 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 - # echo -e "$red 下载 Caddy 失败!$none" && exit 1 - # fi + if ! wget --no-check-certificate -O "$caddy_tmp_file" $caddy_download_link; then + echo -e "$red 下载 Caddy 失败!$none" && exit 1 + fi - # tar zxf $caddy_tmp_file -C $caddy_tmp - # cp -f ${caddy_tmp}caddy /usr/local/bin/ + tar zxf $caddy_tmp_file -C $caddy_tmp + 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 echo -e "$red 安装 Caddy 出错!$none" && exit 1 fi } _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 - # 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 "/on-abnormal/a RestartSec=3" /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...... #### 。。。。。 use root user run caddy... - cat >/lib/systemd/system/caddy.service <<-EOF - [Unit] - Description=Caddy HTTP/2 web server - Documentation=https://caddyserver.com/docs - After=network.target - Wants=network.target + # cat >/lib/systemd/system/caddy.service <<-EOF + # [Unit] + # Description=Caddy HTTP/2 web server + # Documentation=https://caddyserver.com/docs + # After=network.target + # Wants=network.target - [Service] - Restart=always - RestartSec=3 - Environment=CADDYPATH=/root/.caddy - ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp - ExecReload=/bin/kill -USR1 $MAINPID - KillMode=mixed - KillSignal=SIGQUIT - TimeoutStopSec=5s - LimitNOFILE=1048576 - LimitNPROC=512 + # [Service] + # Restart=always + # RestartSec=3 + # Environment=CADDYPATH=/root/.caddy + # ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp + # ExecReload=/bin/kill -USR1 $MAINPID + # KillMode=mixed + # KillSignal=SIGQUIT + # TimeoutStopSec=5s + # LimitNOFILE=1048576 + # LimitNPROC=512 - [Install] - WantedBy=multi-user.target - EOF + # [Install] + # WantedBy=multi-user.target + # EOF systemctl enable caddy else 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 fi - # if [ -z "$(grep www-data /etc/passwd)" ]; then - # useradd -M -s /usr/sbin/nologin www-data - # fi + if [ -z "$(grep www-data /etc/passwd)" ]; then + useradd -M -s /usr/sbin/nologin www-data + fi # chown -R www-data.www-data /etc/ssl/caddy # ref https://github.com/caddyserver/caddy/tree/master/dist/init/linux-systemd mkdir -p /etc/caddy - # chown -R root:root /etc/caddy - # mkdir -p /etc/ssl/caddy - # chown -R root:www-data /etc/ssl/caddy - # chmod 0770 /etc/ssl/caddy + chown -R root:root /etc/caddy + mkdir -p /etc/ssl/caddy + chown -R root:www-data /etc/ssl/caddy + chmod 0770 /etc/ssl/caddy ## create sites dir mkdir -p /etc/caddy/sites diff --git a/v2ray.sh b/v2ray.sh index 75e68cd..18b8d3e 100644 --- a/v2ray.sh +++ b/v2ray.sh @@ -10,7 +10,7 @@ none='\e[0m' # Root [[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1 -_version="v3.15" +_version="v3.16" cmd="apt-get"