Files
instance-setup-stuff/ghost_server-setup

53 lines
1.9 KiB
Bash

#!/bin/bash
# shellcheck source=ghost_server-env
. "${HOME}"/"${USER}"-env
email_address=hello@knravish.me
echo -e "\n[+] setting up ghost\n\n-------\n"
echo "[+] node and companions"
# ghost doesn't play well with nvm for some reason, probably because of installation location and sudo access
# Download and import the Nodesource GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20 # Use a supported version
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs -y
echo "[+] getting ready..."
ghost_cli_ver="1.28.4"
sudo npm i -g ghost-cli@${ghost_cli_ver}
sudo mkdir -p "${BLOG_PATH}"
sudo chown "${USER}":"${USER}" "${BLOG_PATH}"
sudo chmod 775 "${BLOG_PATH}"
# ghost really needs to update to newer nginx versions and conventions...
sudo mkdir -p /etc/nginx/sites-available/ /etc/nginx/sites-enabled/ /etc/nginx/snippets/
echo "[+] ooh, interactive stuff"
# currently track manually, maybe automate
ghost_ver="5.130.6"
cd "${BLOG_PATH}" && ghost install ${ghost_ver} --no-setup
sudo cp "${HOME}"/"${USER}"-config.production.json "${BLOG_PATH}"/
sudo chown "${USER}":"${USER}" "${BLOG_PATH}"/"${USER}"-config.production.json
mv "${BLOG_PATH}"/"${USER}"-config.production.json "${BLOG_PATH}"/config.production.json
cd "${BLOG_PATH}" && ghost setup --auto --sslemail ${email_address}
echo "[+] restoring backup data"
sudo rm -r "${BLOG_PATH}"/content/*
rclone copyto "${BUCKET_PATH}" "${BLOG_PATH}"/ghostBackup.zip
sudo unzip "${BLOG_PATH}"/ghostBackup.zip -d "${BLOG_PATH}"/content/
sudo chown -R ghost:ghost "${BLOG_PATH}"/content/
echo -e "\n-----\nIMPORTANT\n-----\n[X] modify the nginx default config file to include the sites-enabled directory\n"