caddy-retired/scripts/mkuser
David Kebler e24be310ae reworked caddy script - removed cmdline support for netbind
systemd service install now uses sed to insert the repo directory into the call service script before deploying.
renamed install script to fetch as to avoid confusion as it fetches the basic binary.
2020-11-27 15:52:32 -08:00

30 lines
923 B
Bash
Executable file

#!/bin/bash
DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
echo $DIR
CID=${1:-937}
sudo userdel caddy
sudo groupadd caddy
# change CID to your liking. Best if same on all instances
sudo groupmod --gid $CID caddy
sudo mkdir -p $DIR/user
sudo useradd --system \
-m \
--uid $CID \
--gid caddy \
--create-home \
--home-dir "$DIR/user" \
--shell /bin/bash \
--comment "Caddy web server user" \
caddy
echo 'caddy:caddy' | sudo chpasswd # user:password
echo "set caddy user password to \'caddy\'"
sudo chown -R caddy:caddy $DIR/user
echo adding current user $USER to caddy group for rw access
sudo usermod -a -G caddy $USER
cat /etc/passwd | grep caddy
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