echo"Overwrite flag passed, but secrets.env not found. This script will refuse to execute an overwrite without secrets.env."
echo"If you are absolutely sure you want to overwrite your secrets with new secrets, copy the secrets.env.example file without modifying it's contents using command 'cp secrets.env.example secrets.env'."
echo"If you do not copy your existing secrets into secrets.env you WILL lose access to ALL of your files store in your Stoat instance."
exit1
fi
echo"Overwriting existing config."
echo"Renaming Revolt.toml to Revolt.toml.old"
mv Revolt.toml Revolt.toml.old
echo"Renaming livekit.yml to livekit.yml.old"
mv livekit.yml livekit.yml.old
echo"Renaming compose.override.yml to compose.override.yml.old"
mv compose.override.yml compose.override.yml.old
else
echo"Existing config found, in caution, this script will refuse to execute if you have existing config."
if["$SECRETS_FOUND" -eq "0"];then
echo"Please configure secrets.env with your existing secrets to prevent losing access to your saved files in your Stoat instance. You can see instructions on how to configure it by reading the file secrets.env.example. You can do this by running the command 'cat secrets.env.example'."
echo"Overwriting your existing config will result in you losing access to all current files stored on your Stoat instance unless you copy your old secrets into secrets.env."
else
echo"secrets.env found, please ensure it matches what is currently in your Revolt.toml."
fi
echo"This script will back up your old config if you choose to overwrite."
echo"To overwrite the existing config, run the script again with the --overwrite flag"
echo"$0$* --overwrite"
exit1
fi
fi
if["$SECRETS_FOUND" -eq "0"];then
cp secrets.env.example secrets.env
loadSecrets
fi
STOAT_HOSTNAME="https://$1"
read -rp "Would you like to place Stoat behind another reverse proxy? [y/N]: "
if["$REPLY"="y"]||["$REPLY"="Y"];then
echo"Yes received. Configuring for reverse proxy."
STOAT_HOSTNAME=':80'
echo"Writing compose.override.yml..."
echo"services:" > compose.override.yml
echo" caddy:" >> compose.override.yml
echo" ports: !override" >> compose.override.yml
echo" - \"8880:80\"" >> compose.override.yml
echo"caddy is configured to host on :8880. If you need a different port, modify the compose.override.yml."
else
echo"No received. Configuring with built in caddy as primary reverse proxy."
fi
# Generate secrets
echo"Generating secrets..."
if["$PUSHD_VAPID_PRIVATEKEY"=""];then
if["$PUSHD_VAPID_PUBLICKEY" !=""];then
echo"VAPID public key is defined when private key isn't?"
echo"Did you forget to copy the PUSHD_VAPID_PRIVATEKEY secret?"
echo"Try removing PUSHD_VAPID_PUBLICKEY if you do not have a private key."