#!/bin/bash ######################################################################## # A shell script to install / upgrade SimpleHelp on a Linux system. # # Configure the installation directory below. This script will always # download the latest public release of SimpleHelp. If an existing # installation is detected ######################################################################## # Installation directory install="/opt/SimpleHelp" if [ ! -z "$1" ]; then install="$1" fi # Check permissions parentdir="$(dirname "$install")" if [ ! -w "$parentdir" ]; then echo "[ERROR] Insufficient permissions to write installation files in $parentdir" >&2 exit 1 fi if [ -d "$install" ]; then if [ ! -w "$parentdir" ]; then echo "[ERROR] Insufficient permissions to write installation files in $install" >&2 exit 1 fi fi echo "--- Managing SimpleHelp installation in $install" # Generate a timestamp now=$(date +"%Y%m%d_%H%M%S") # Keep track of the initial directory initial_dir="$PWD" # Stop the server if [ -d "$install" ]; then echo "--- Stopping SimpleHelp installation in $install" cd "$install" sh serverstop.sh >/dev/null 2>&1 sleep 10 cd .. echo "--- Backing up the SimpleHelp installation to SimpleHelp_backup_$now" mv "$install" "SimpleHelp_backup_$now" fi # Fetch the new version echo "--- Downloading the latest version" uname_out=`uname -m` case "$uname_out" in *aarch64*|*arm64*) echo "--- Using the Linux ARM 64bit Release" sh_binary="SimpleHelp-linux-arm64.tar.gz" sh_url="https://simple-help.com/releases/SimpleHelp-linux-arm64.tar.gz" ;; *aarch*|*arm*) echo "--- Using the Linux ARM 32bit Release" sh_binary="SimpleHelp-linux-arm32.tar.gz" sh_url="https://simple-help.com/releases/SimpleHelp-linux-arm32.tar.gz" ;; *64*) echo "--- Using the Linux Intel 64bit Release" sh_binary="SimpleHelp-linux-amd64.tar.gz" sh_url="https://simple-help.com/releases/SimpleHelp-linux-amd64.tar.gz" ;; *) echo "--- Using the Linux Intel 32bit Release" sh_binary="SimpleHelp-linux.tar.gz" sh_url="https://simple-help.com/releases/SimpleHelp-linux.tar.gz" ;; esac rm -f $sh_binary echo "--- Downloading..." wget -q $sh_url echo "--- Extracting..." tar -xzf $sh_binary if [ "$install" != "$PWD/SimpleHelp" ]; then echo "--- Moving install to $install" mv SimpleHelp "$install" fi # Copy across the old configuration folder if [ -d "SimpleHelp_backup_$now" ]; then echo "--- Copying across configuration files" cp -R $install/../SimpleHelp_backup_$now/configuration/* $install/configuration fi # Start the new server echo "--- Starting your new SimpleHelp server" cd "$install" sh serverstart.sh cd $initial_dir