reworking scripts

giskard
David Kebler 2020-10-26 13:34:42 -07:00
parent 5e7c0e94a0
commit da5d968a3a
9 changed files with 23 additions and 15 deletions

2
.gitignore vendored
View File

@ -6,7 +6,7 @@
env/AWS
env/aws.sh
.bash_history
/caddy
/bin/caddy
conf/238lights.conf
conf/645lights.conf
conf/trantor.conf

View File

@ -13,7 +13,7 @@ handle_errors {
}
}
https://example.<mydomain.com> {
https://example.kebler.net {
import r53
root * /opt/caddy/example-web
file_server

View File

@ -1,3 +1,4 @@
#!/bin/bash
DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
CONF=${1:-caddy}
/opt/caddy/caddy adapt --config /opt/caddy/$CONF.conf --adapter caddyfile > caddy.json
$DIR/bin/caddy adapt --config $DIR/conf/$CONF.conf --adapter caddyfile > caddy.json

View File

@ -96,11 +96,14 @@ echo Operating System $OS
echo Architecture $ARCH
echo Archive Type $ARCHIVE
BIN_DIR="$(dirname "$(readlink -f "$0")")"
REPO_DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
BIN_DIR="$REPO_DIR/bin"
BIN_NAME=${BIN_NAME:-caddy}
[ "$OS" == windows ] && BIN_NAME=$BIN_NAME.exe
BIN_PATH="$BIN_DIR/$BIN_NAME"
echo $BIN_PATH
if [ $LOCAL == true ]; then
echo "Using Local Binary <$BIN_DIR/$OS-$ARCH> if Available"
if [ -f "$BIN_DIR/$OS-$ARCH" ]; then

View File

@ -1,5 +1,5 @@
#!/bin/bash
#!/bin/bash
DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
sudo userdel caddy
sudo groupadd caddy
sudo groupmod --gid 937 caddy
@ -8,13 +8,14 @@ sudo useradd --system \
--uid 937 \
--gid caddy \
--create-home \
--home-dir /opt/caddy \
--home-dir "$DIR" \
--shell /bin/bash \
--comment "Caddy web server" \
caddy
sudo passwd caddy
sudo usermod -a -G caddy $USER
sudo chown -R caddy:caddy /opt/caddy
sudo chmod g+rw -R /opt/caddy
sudo chown -R caddy:caddy "$DIR"
sudo chmod g+rw -R "$DIR"
cat /etc/passwd | grep caddy
cat /etc/passwd | grep sysadmin
$DIR/scripts/own

View File

@ -1,3 +1,4 @@
#!/bin/bash
touch /opt/caddy/conf/$1.conf
sudo chown caddy:sysadmin /opt/caddy/conf/$1.conf
DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
touch $DIR/conf/$1.conf
sudo chown caddy:caddy $DIR/conf/$1.conf

View File

@ -1,4 +1,5 @@
#!/bin/bash
# reset ownership if need be. Assumes user is in caddy group
sudo chown -R caddy:caddy /opt/caddy
sudo chmod g+rwx -R /opt/caddy
# reset ownership if need be. User must be in caddy group
DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
sudo chown -R caddy:caddy $DIR
sudo chmod g+rwx -R $DIR

View File

@ -1,6 +1,7 @@
#!/bin/bash
# one off run command for testing without systemd
DIR=$(dirname "$(dirname "$(readlink -f "$0")")") || exit
CONF=${1:-caddy}
source /opt/caddy/env/aws.sh
$DIR/env/aws.sh
sudo -E /usr/bin/env | grep AWS
sudo -E /opt/caddy/caddy run --config /opt/caddy/conf/$CONF.conf --adapter caddyfile
sudo -E $DIR/bin/caddy run --config $DIR/conf/$CONF.conf --adapter caddyfile