Skip to content

Instantly share code, notes, and snippets.

@syhily
Last active November 20, 2019 06:43
Show Gist options
  • Save syhily/608c2b2193a403f860b181f3851b88b2 to your computer and use it in GitHub Desktop.
Save syhily/608c2b2193a403f860b181f3851b88b2 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Read the update version for this wiki.js
if [ $# -lt 1 ]
then
echo "Usage: $0 [wiki.js release version]"
echo "Example: $0 2.0.1"
exit 1
fi
WIKIJS_INSTALL_DIR="/opt/wiki"
WIKIJS_VERSION=$1
echo "Upgrade the wiki.js to ${WIKIJS_VERSION}"
echo "Download the desired wiki.js package"
wget -c https://github.com/Requarks/wiki/releases/download/${WIKIJS_VERSION}/wiki-js.tar.gz
echo "Stop the wiki.js daemon"
systemctl stop wiki
echo "Backup the wiki.js configuration"
\cp -rf ${WIKIJS_INSTALL_DIR}/config.yml ${WIKIJS_INSTALL_DIR}/../config.yml.bak
echo "Extract and install new version"
rm -rf ${WIKIJS_INSTALL_DIR}/*
tar xzf wiki-js.tar.gz -C ${WIKIJS_INSTALL_DIR}
echo "Restore the wiki.js configration file"
\cp -rf ${WIKIJS_INSTALL_DIR}/../config.yml.bak ${WIKIJS_INSTALL_DIR}/config.yml
chown wikijs:wikijs -R ${WIKIJS_INSTALL_DIR}
echo "Start wiki.js daemon"
systemctl start wiki
echo "Congratulations, the wiki.js has been updated to ${WIKIJS_VERSION}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment