Skip to content

Commit

Permalink
use www-data user run caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
233boy committed Apr 3, 2018
1 parent fa9fd18 commit 5878357
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
16 changes: 12 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -705,18 +705,26 @@ install_caddy() {
echo -e "$red 安装 Caddy 出错!" && exit 1
fi

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 "s/www-data/root/g" /lib/systemd/system/caddy.service
systemctl enable caddy
else
cp -f ${caddy_tmp}init/linux-sysvinit/caddy /etc/init.d/caddy
sed -i "s/www-data/root/g" /etc/init.d/caddy
# sed -i "s/www-data/root/g" /etc/init.d/caddy
chmod +x /etc/init.d/caddy
update-rc.d -f caddy defaults
fi

mkdir -p /etc/ssl/caddy

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

mkdir -p /etc/caddy/
rm -rf $caddy_tmp
caddy_config
Expand Down Expand Up @@ -761,9 +769,9 @@ install_v2ray() {
# $cmd install -y lrzsz git zip unzip curl wget qrencode bind-utils iptables-services
# fi
if [[ $cmd == "apt-get" ]]; then
$cmd install -y lrzsz git zip unzip curl wget qrencode
$cmd install -y lrzsz git zip unzip curl wget qrencode libcap2-bin
else
$cmd install -y lrzsz git zip unzip curl wget qrencode iptables-services
$cmd install -y lrzsz git zip unzip curl wget qrencode libcap iptables-services
fi
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Expand Down
14 changes: 11 additions & 3 deletions v2ray.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ none='\e[0m'
# Root
[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1

_version="v1.56"
_version="v1.57"

cmd="apt-get"

Expand Down Expand Up @@ -1318,18 +1318,26 @@ install_caddy() {
echo -e "$red 安装 Caddy 出错!" && exit 1
fi

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 "s/www-data/root/g" /lib/systemd/system/caddy.service
systemctl enable caddy
else
cp -f ${caddy_tmp}init/linux-sysvinit/caddy /etc/init.d/caddy
sed -i "s/www-data/root/g" /etc/init.d/caddy
# sed -i "s/www-data/root/g" /etc/init.d/caddy
chmod +x /etc/init.d/caddy
update-rc.d -f caddy defaults
fi

mkdir -p /etc/ssl/caddy

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

mkdir -p /etc/caddy/
rm -rf $caddy_tmp

Expand Down

0 comments on commit 5878357

Please sign in to comment.