site-deploy/init.sh

33 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
exe() {
echo "running $@"
$@
}
SITE_REPO="https://git.chaospott.de/chaospott/site.git"
echo "Where should the site store all volumes?"
read -p "PATH: " VOLUMES_PATH_RAW
read -p "Hook endpoint ID (just make something up):" ENDPOINT_ID
read -p "Hook endpoint Password:" ENDPOINT_PW
read -p "Hook Domain (NOT site domain):" HOOK_DOMAIN
VOLUMES_PATH=$(echo $VOLUMES_PATH_RAW | sed 's/\/$//g')
echo "Creating volumes structure"
exe mkdir -p $VOLUMES_PATH/static
exe git clone $SITE_REPO $VOLUMES_PATH/repo
exe cp -rv configs/webhook $VOLUME
echo """[
{
\"id\": \"$ENDPOINT_ID\",
\"execute-command\": \"/webhook/reload.sh\",
\"command-working-directory\": \"/repo\",
\"match\":
{
\"secret\": \"$ENDPOINT_PW\"
}
}
]""" > $VOLUMES_PATH/webhook/hooks.json
echo """DATA_ROOT=$VOLUMES_PATH
WEBHOOK_DOMAIN=$HOOK_DOMAIN""" > .env
exe chmod 777 $VOLUMES_PATH -Rc
echo "configure your git with the following hook URL:"
echo "https://$HOOK_DOMAIN/hooks/$ENDPOINT_ID"