2020-05-12 14:51:19 -07:00
|
|
|
#!/bin/bash
|
2020-10-26 13:34:42 -07:00
|
|
|
DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
|
2020-11-08 17:29:08 -08:00
|
|
|
echo $DIR
|
|
|
|
CID=${1:-937}
|
2020-05-12 14:51:19 -07:00
|
|
|
sudo userdel caddy
|
|
|
|
sudo groupadd caddy
|
2020-11-08 17:29:08 -08:00
|
|
|
# change CID to your liking. Best if same on all instances
|
|
|
|
sudo groupmod --gid $CID caddy
|
2020-10-27 10:09:20 -07:00
|
|
|
sudo mkdir -p $DIR/user
|
2020-05-12 14:51:19 -07:00
|
|
|
sudo useradd --system \
|
|
|
|
-m \
|
2020-11-08 17:29:08 -08:00
|
|
|
--uid $CID \
|
2020-05-12 14:51:19 -07:00
|
|
|
--gid caddy \
|
|
|
|
--create-home \
|
2020-10-27 10:09:20 -07:00
|
|
|
--home-dir "$DIR/user" \
|
2020-05-12 14:51:19 -07:00
|
|
|
--shell /bin/bash \
|
2020-10-27 10:09:20 -07:00
|
|
|
--comment "Caddy web server user" \
|
2020-05-12 14:51:19 -07:00
|
|
|
caddy
|
2020-11-08 17:29:08 -08:00
|
|
|
echo 'caddy:caddy' | sudo chpasswd
|
|
|
|
sudo chown -R caddy:caddy $DIR/user
|
|
|
|
echo adding current user $USER to caddy group for rw access
|
2020-07-01 07:52:41 -07:00
|
|
|
sudo usermod -a -G caddy $USER
|
2020-05-12 14:51:19 -07:00
|
|
|
cat /etc/passwd | grep caddy
|
2020-11-08 17:29:08 -08:00
|
|
|
PER="caddy ALL=NOPASSWD: ALL"
|
|
|
|
echo $PER | sudo tee /etc/sudoers.d/99_caddy
|
|
|
|
ls -la /etc/sudoers.d/*caddy
|
|
|
|
echo added: $(cat /etc/sudoers.d/99_caddy) to sudoers.d/99_caddy
|
|
|
|
echo checking file.... $(sudo visudo -cf /etc/sudoers.d/99_caddy)
|
|
|
|
# $DIR/scripts/own
|