Skip to content

Commit

Permalink
Allow optional --ignore-root-warning
Browse files Browse the repository at this point in the history
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#3884
  • Loading branch information
mart-e committed Feb 14, 2019
1 parent b1992b3 commit c01bda0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
15 changes: 11 additions & 4 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 11 additions & 5 deletions scripts/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c01bda0

Please sign in to comment.