Skip to content

Instantly share code, notes, and snippets.

@eyedeekay
Last active November 23, 2021 01:03
Show Gist options
  • Save eyedeekay/3f79d0d830cac67385b7a6fd8f913573 to your computer and use it in GitHub Desktop.
Save eyedeekay/3f79d0d830cac67385b7a6fd8f913573 to your computer and use it in GitHub Desktop.
Script to assist with updating news server while I am away from my desk
#! /usr/bin/env sh
#
# This script is peculiar to my newsxml setup.
# When I build my news, I build on my laptop first, then transfer the files over to the server using scp.
# This way, the keys which are used to sign the news never leave the device where I do the signing.
# They don't live on the server.
# The SSH tunel server on my news server is down right now and I can't access it, so I need to copy the files another way.
# I've asked someone with physical access to the server to run this script which will set up the newsfeed without the need me to use SSH.
#
# Copy-and-Paste the following line:
# ssh [email protected] bash -c 'wget -qO - https://gist.github.com/eyedeekay/3f79d0d830cac67385b7a6fd8f913573/raw/ccb6dab09a51ec5d99ef19fc910a50c168a1fb9e/newsxml-script.sh | sh -'
echo ""
echo "PHASE 1: preparing the newsfeed directory"
echo ""
sleep 3s
cd "$HOME"
rm -rf "i2p.newsxml.bak"
echo "removed old backup"
cp -rv "$HOME/i2p.newsxml" i2p.newsxml.bak #|| echo "Error copying old news files to backup" && exit 1
echo "copied dir to backup"
rm -rf "$HOME/i2p.newsxml" #|| echo "Error deleting live newsfeed" && exit 1
echo "removed live newsfeed"
wget -O "$HOME/i2p.newsxml.zip" "https://github.com/eyedeekay/i2p.newsxml/releases/download/workaround-11-22-21/i2p.newsxml.zip" #|| echo "Error downloading updated newsfeed from the site" && exit 1
echo "downloaded new newsfeed"
unzip "$HOME/i2p.newsxml.zip" #|| echo "Error unzipping updated newsfeed" && exit 1
echo "unpacked new newsfeed"
cd "$HOME/i2p.newsxml" #|| echo "Error changing directory to i2p.newsxml" && exit 1
echo "moved to newsxml dir"
echo ""
echo "PHASE 2: building and running site"
echo ""
sleep 3s
docker build -t i2p.newsxml . #|| echo "Error building docker container" && exit 1
docker rm -f newsxml #|| echo "error removing docker container" && exit 1
docker run -d --restart=always --name newsxml -p 127.0.0.1:3000:3000 i2p.newsxml #|| echo "error running the local server" && exit 1
echo "SUCCESS!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment