mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
add new-tribe and setup-remote management scripts
This commit is contained in:
parent
d876a473f6
commit
7ba0f97cb2
2 changed files with 67 additions and 0 deletions
46
tribes/new-tribe
Executable file
46
tribes/new-tribe
Executable file
|
|
@ -0,0 +1,46 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
wait_keypress() {
|
||||||
|
echo "Press Enter to proceed..."
|
||||||
|
read
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$#" -ne 2 ]; then
|
||||||
|
echo "Usage: $0 <instance domain> <uploader config>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
INSTANCE_DOMAIN="$1"
|
||||||
|
UPLOADER_CFG="$2"
|
||||||
|
INSTANCE_NAME="$(echo "$INSTANCE_DOMAIN" | cut -d '.' -f 1)"
|
||||||
|
GLOBAL_DOMAIN="$(echo "$INSTANCE_DOMAIN" | cut -d '.' -f 2-)"
|
||||||
|
|
||||||
|
if [ -z "${NSEC+x}" ]; then
|
||||||
|
echo "nsec not set; generating new nsec..."
|
||||||
|
NSEC="$(nak key generate | nak encode nsec)"
|
||||||
|
echo "New Ditto instance nsec is ${NSEC}. Note this down now!"
|
||||||
|
else
|
||||||
|
echo "nsec set; proceeding..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
wait_keypress
|
||||||
|
|
||||||
|
echo todo confirm options
|
||||||
|
wait_keypress
|
||||||
|
|
||||||
|
ssh -T "root@$GLOBAL_DOMAIN" << EOF
|
||||||
|
dokku apps:create $INSTANCE_NAME
|
||||||
|
dokku postgres:link dittodb $INSTANCE_NAME
|
||||||
|
dokku docker-options:add $INSTANCE_NAME build '--build-arg DITTO_NSEC="$NSEC"'
|
||||||
|
dokku docker-options:add $INSTANCE_NAME build '--build-arg DITTO_UPLOADER_CONFIG="$UPLOADER_CFG"'
|
||||||
|
dokku docker-options:add $INSTANCE_NAME build '--build-arg DITTO_DOMAIN="https://$INSTANCE_DOMAIN"'
|
||||||
|
EOF
|
||||||
|
|
||||||
|
REMOTE_NAME="tribes-$INSTANCE_NAME"
|
||||||
|
if ! git remote get-url "$REMOTE_NAME" > /dev/null 2>&1; then
|
||||||
|
git remote add "$REMOTE_NAME" "dokku@$GLOBAL_DOMAIN:$INSTANCE_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if git push $REMOTE_NAME ditto-as-a-service:main; then
|
||||||
|
ssh "root@$GLOBAL_DOMAIN" "dokku letsencrypt:enable $INSTANCE_NAME"
|
||||||
|
fi
|
||||||
21
tribes/setup-remote
Executable file
21
tribes/setup-remote
Executable file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ "$#" -ne 3 ]; then
|
||||||
|
echo "Usage: $0 <dokku server address> <global domain> <email for letsencrypt>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
REMOTE_ADDR="$1"
|
||||||
|
DOMAIN="$2"
|
||||||
|
LETSENCRYPT_EMAIL="$3"
|
||||||
|
DEPLOYMENT_PUBKEY="$(cat ~/.ssh/id_rsa.pub)"
|
||||||
|
|
||||||
|
ssh -T "root@$REMOTE_ADDR" << EOF
|
||||||
|
echo "$DEPLOYMENT_PUBKEY" | dokku ssh-keys:add admin
|
||||||
|
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
|
||||||
|
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
|
||||||
|
dokku postgres:create dittodb
|
||||||
|
dokku domains:set-global "$DOMAIN"
|
||||||
|
dokku letsencrypt:set --global email "$LETSENCRYPT_EMAIL"
|
||||||
|
dokku letsencrypt:cron-job --add
|
||||||
|
EOF
|
||||||
Loading…
Add table
Reference in a new issue