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
This commit is contained in:
Martin Trigaux 2019-02-14 16:40:51 +05:30
parent b1992b340e
commit c01bda038e
2 changed files with 22 additions and 9 deletions

View file

@ -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

View file

@ -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