From c24135577cac5893c39211e9733935dc8d58a83b Mon Sep 17 00:00:00 2001 From: rhtenhove Date: Tue, 20 Nov 2018 22:54:58 +0100 Subject: [PATCH] Useless and error prone VERSION file removed & warn use of root (#989) * Don't create unused VERSION file It will throw an error if the script is run from a non-writable directory * Warn user if running as root This will write files as root:root * Clearer root warning --- Joplin_install_and_update.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Joplin_install_and_update.sh b/Joplin_install_and_update.sh index 54e00e0306..8cd09bdfad 100755 --- a/Joplin_install_and_update.sh +++ b/Joplin_install_and_update.sh @@ -11,6 +11,14 @@ echo " | | " echo " |_| " echo "" +# Check and warn if running as root. +if [[ $EUID = 0 ]] ; then + if [[ $* != *--allow-root* ]] ; then + echo "It is not recommended (nor necessary) to run this script as root. To do so anyway, please use '--allow-root'" + exit 1 + fi +fi + #----------------------------------------------------- # Download Joplin #----------------------------------------------------- @@ -19,7 +27,6 @@ echo "" version=$(curl --silent "https://api.github.com/repos/laurent22/joplin/releases/latest" | grep -Po '"tag_name": "v\K.*?(?=")') # Check if it's in the latest version -touch VERSION if [[ $(< ~/.joplin/VERSION) != "$version" ]]; then # Delete previous version