2020-07-05 15:56:22 +00:00
|
|
|
#!/bin/bash
|
|
|
|
exe() {
|
|
|
|
echo "running $@"
|
|
|
|
$@
|
|
|
|
}
|
2020-07-07 12:15:08 +00:00
|
|
|
SITE_REPO_DEFAULT="https://git.chaospott.de/chaospott/site.git"
|
|
|
|
SITE_DOMAIN_DEFAULT="chaospott.de"
|
|
|
|
REDIRECT_DOMAIN_DEFAULT="www.chaospott.de"
|
2020-07-05 15:56:22 +00:00
|
|
|
echo "Where should the site store all volumes?"
|
2020-07-05 16:38:38 +00:00
|
|
|
read -p "PATH: " VOLUMES_PATH_RAW
|
2020-07-05 15:56:22 +00:00
|
|
|
read -p "Hook endpoint ID (just make something up):" ENDPOINT_ID
|
|
|
|
read -p "Hook endpoint Password:" ENDPOINT_PW
|
2020-07-05 16:38:38 +00:00
|
|
|
read -p "Hook Domain (NOT site domain):" HOOK_DOMAIN
|
2020-07-07 12:15:08 +00:00
|
|
|
read -p "Repo (Default: Repo for chaospott.de):" SITE_REPO
|
|
|
|
read -p "Domain (Default: chaospott.de):" SITE_DOMAIN
|
|
|
|
read -p "Domain(s) to redirect (Default: www.chaospott.de)" REDIRECT_DOMAIN
|
|
|
|
#set defaults
|
|
|
|
if [ -z "$SITE_REPO" ]; then SITE_REPO="$SITE_REPO_DEFAULT"; fi
|
|
|
|
if [ -z "$SITE_DOMAIN" ]; then SITE_DOMAIN="$SITE_DOMAIN_DEFAULT"; fi
|
|
|
|
if [ -z "$REDIRECT_DOMAIN" ]; then REDIRECT_DOMAIN="$REDIRECT_DOMAIN_DEFAULT"; fi
|
|
|
|
|
2020-07-05 16:38:38 +00:00
|
|
|
VOLUMES_PATH=$(echo $VOLUMES_PATH_RAW | sed 's/\/$//g')
|
2020-07-05 15:56:22 +00:00
|
|
|
echo "Creating volumes structure"
|
2020-07-05 16:52:04 +00:00
|
|
|
exe mkdir -p $VOLUMES_PATH/static
|
2020-07-05 15:56:22 +00:00
|
|
|
exe git clone $SITE_REPO $VOLUMES_PATH/repo
|
2020-07-05 16:22:00 +00:00
|
|
|
exe cp -rv configs/webhook $VOLUME
|
2020-07-05 15:56:22 +00:00
|
|
|
echo """[
|
|
|
|
{
|
|
|
|
\"id\": \"$ENDPOINT_ID\",
|
|
|
|
\"execute-command\": \"/webhook/reload.sh\",
|
|
|
|
\"command-working-directory\": \"/repo\",
|
|
|
|
\"match\":
|
|
|
|
{
|
|
|
|
\"secret\": \"$ENDPOINT_PW\"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]""" > $VOLUMES_PATH/webhook/hooks.json
|
2020-07-05 16:38:38 +00:00
|
|
|
echo """DATA_ROOT=$VOLUMES_PATH
|
2020-07-07 12:15:08 +00:00
|
|
|
WEBHOOK_DOMAIN=$HOOK_DOMAIN
|
|
|
|
DOMAIN=$SITE_DOMAIN
|
|
|
|
REDIRECT_DOMAIN=$REDIRECT_DOMAIN""" > .env
|
2020-07-05 16:04:13 +00:00
|
|
|
exe chmod 777 $VOLUMES_PATH -Rc
|
2020-07-05 16:38:38 +00:00
|
|
|
echo "configure your git with the following hook URL:"
|
|
|
|
echo "https://$HOOK_DOMAIN/hooks/$ENDPOINT_ID"
|