-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
install_packages() { | ||
echo | ||
echo "Installing packages..." | ||
echo | ||
apt-get update | ||
apt-get install -y curl nginx certbot python3-certbot-nginx | ||
echo | ||
echo "Packages have been installed." | ||
echo | ||
} | ||
|
||
download_docker_compose() { | ||
echo | ||
echo "Downloading docker-compose.yml..." | ||
echo | ||
curl -sSL https://raw.githubusercontent.com/Loudbooks/PasteBook/refs/heads/master/docker-compose.yml -o docker-compose.yml | ||
echo | ||
echo "docker-compose.yml has been created." | ||
echo | ||
} | ||
|
||
create_env_file() { | ||
echo | ||
echo "Creating .env file..." | ||
echo | ||
read -p "Enter the title to be used for PasteBook (leave blank for default): " TITLE | ||
read -p "Enter the description to be used for the home page of PasteBook (leave blank for default): " DESCRIPTION | ||
|
||
cat <<EOL > .env | ||
TITLE=${TITLE} | ||
DESCRIPTION=${DESCRIPTION} | ||
EOL | ||
echo | ||
echo ".env file has been created." | ||
echo | ||
} | ||
|
||
download_and_configure_nginx() { | ||
echo | ||
echo "Downloading default Nginx configuration..." | ||
echo | ||
|
||
curl -sSL https://raw.githubusercontent.com/Loudbooks/PasteBook/refs/heads/master/pastebook.conf -o /etc/nginx/sites-available/pastebook.conf | ||
|
||
read -p "Enter your domain name (e.g., pastebook.dev): " DOMAIN | ||
sed -i "s/<DOMAIN>/${DOMAIN}/g" /etc/nginx/sites-available/pastebook.conf | ||
|
||
ln -s /etc/nginx/sites-available/pastebook.conf /etc/nginx/sites-enabled/ | ||
echo | ||
echo "Nginx configuration completed." | ||
echo | ||
|
||
echo | ||
echo Have you added an A record for your domain pointing to this server\'s IP address, and an A record for api.\<your-domain\> pointing to the same IP address? | ||
read -p "Press Enter to continue..." | ||
|
||
echo "Setting up SSL with Certbot..." | ||
sudo certbot --nginx -d ${DOMAIN} -d api.${DOMAIN} | ||
echo | ||
echo "SSL setup completed." | ||
echo | ||
|
||
systemctl restart nginx | ||
} | ||
|
||
ready() { | ||
echo | ||
echo PasteBook is ready! | ||
echo You can start PasteBook by running: | ||
echo docker compose up -d | ||
echo | ||
} | ||
|
||
install_packages | ||
download_docker_compose | ||
create_env_file | ||
download_and_configure_nginx | ||
ready |