From c0f7af2286016befe5b26e350f432512a6464c8c Mon Sep 17 00:00:00 2001 From: Loudbook Date: Fri, 6 Dec 2024 18:14:27 -0500 Subject: [PATCH] Create installation script --- install.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..fd04263 --- /dev/null +++ b/install.sh @@ -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 < .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}/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.\ 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 \ No newline at end of file