From 5fbdf869180f8d042257c55f8c49446494b370c8 Mon Sep 17 00:00:00 2001 From: 233boy <31657650+233boy@users.noreply.github.com> Date: Tue, 24 Sep 2019 12:02:45 +0800 Subject: [PATCH] ...fix caddy running issue. mdzz --- src/download-caddy.sh | 78 +++++++++++++++++++++++++++++-------------- v2ray.sh | 2 +- 2 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/download-caddy.sh b/src/download-caddy.sh index ef803c2..5191e8d 100644 --- a/src/download-caddy.sh +++ b/src/download-caddy.sh @@ -1,33 +1,61 @@ _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 if [[ ! -f /usr/local/bin/caddy ]]; then echo -e "$red 安装 Caddy 出错!" && 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/ - # 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 + # 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 + + #### 。。。。。 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 + + [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 systemctl enable caddy else cp -f ${caddy_tmp}init/linux-sysvinit/caddy /etc/init.d/caddy @@ -36,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 61ceaba..75e68cd 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.14" +_version="v3.15" cmd="apt-get"