use www-data user run caddy

pull/17/merge
233boy 7 years ago
parent fa9fd183fe
commit 5878357a3e
  1. 16
      install.sh
  2. 14
      v2ray.sh

@ -705,18 +705,26 @@ install_caddy() {
echo -e "$red 安装 Caddy 出错!" && exit 1 echo -e "$red 安装 Caddy 出错!" && exit 1
fi fi
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
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
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 chmod +x /etc/init.d/caddy
update-rc.d -f caddy defaults update-rc.d -f caddy defaults
fi fi
mkdir -p /etc/ssl/caddy 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/ mkdir -p /etc/caddy/
rm -rf $caddy_tmp rm -rf $caddy_tmp
caddy_config caddy_config
@ -761,9 +769,9 @@ install_v2ray() {
# $cmd install -y lrzsz git zip unzip curl wget qrencode bind-utils iptables-services # $cmd install -y lrzsz git zip unzip curl wget qrencode bind-utils iptables-services
# fi # fi
if [[ $cmd == "apt-get" ]]; then 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 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 fi
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

@ -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="v1.56" _version="v1.57"
cmd="apt-get" cmd="apt-get"
@ -1318,18 +1318,26 @@ install_caddy() {
echo -e "$red 安装 Caddy 出错!" && exit 1 echo -e "$red 安装 Caddy 出错!" && exit 1
fi fi
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
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
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 chmod +x /etc/init.d/caddy
update-rc.d -f caddy defaults update-rc.d -f caddy defaults
fi fi
mkdir -p /etc/ssl/caddy 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/ mkdir -p /etc/caddy/
rm -rf $caddy_tmp rm -rf $caddy_tmp

Loading…
Cancel
Save