From: Martin Trigaux Date: Thu, 14 Feb 2019 11:10:51 +0000 (+0530) Subject: Allow optional --ignore-root-warning X-Git-Tag: 2.3.7~4^2 X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=commitdiff_plain;h=c01bda038e84156ffcd8cdc21025e7f3f3892fcf Allow optional --ignore-root-warning Now both ./install prod --ignore-root-warning ./install --ignore-root-warning prod will work $1 was both used for the environment and the root flag Fixes wallabag/wallabag#3884 --- diff --git a/scripts/install.sh b/scripts/install.sh index 8b7ea03f..de1fb8f6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -5,9 +5,17 @@ IGNORE_ROOT_ARG="--ignore-root-warning" IGNORE_ROOT=0 -if [ "$1" == "$IGNORE_ROOT_ARG" ]; then - IGNORE_ROOT=1 -fi +while :; do + case $1 in + $IGNORE_ROOT_ARG) IGNORE_ROOT=1 + ;; + *[a-zA-Z]) ENV=$1 + ;; + *) break + ;; + esac + shift +done # Abort running this script if root if [ "$IGNORE_ROOT" -eq 0 ] && [ "$EUID" == "0" ]; then @@ -22,7 +30,6 @@ DIR="${BASH_SOURCE}" if [ ! -d "$DIR" ]; then DIR="$PWD/scripts"; fi . "$DIR/require.sh" -ENV=$1 TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) git checkout $TAG diff --git a/scripts/update.sh b/scripts/update.sh index c62d104a..e86a76db 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -5,9 +5,17 @@ IGNORE_ROOT_ARG="--ignore-root-warning" IGNORE_ROOT=0 -if [ "$1" == "$IGNORE_ROOT_ARG" ]; then - IGNORE_ROOT=1 -fi +while :; do + case $1 in + $IGNORE_ROOT_ARG) IGNORE_ROOT=1 + ;; + *[a-zA-Z]) ENV=$1 + ;; + *) break + ;; + esac + shift +done # Abort running this script if root if [ "$IGNORE_ROOT" -eq 0 ] && [ "$EUID" == "0" ]; then @@ -25,8 +33,6 @@ DIR="${BASH_SOURCE}" if [ ! -d "$DIR" ]; then DIR="$PWD/scripts"; fi . "$DIR/require.sh" -ENV=$1 - rm -rf var/cache/* git fetch origin git fetch --tags