]> git.immae.eu Git - github/wallabag/wallabag.git/blob - scripts/update.sh
Merge pull request #4009 from wallabag/fix/check-git-directory
[github/wallabag/wallabag.git] / scripts / update.sh
1 #!/usr/bin/env bash
2 # You can execute this file to update wallabag
3 # eg: `sh update.sh prod`
4
5 IGNORE_ROOT_ARG="--ignore-root-warning"
6 IGNORE_ROOT=0
7
8 while :; do
9 case $1 in
10 $IGNORE_ROOT_ARG) IGNORE_ROOT=1
11 ;;
12 *[a-zA-Z]) ENV=$1
13 ;;
14 *) break
15 ;;
16 esac
17 shift
18 done
19
20 # Abort running this script if root
21 if [ "$IGNORE_ROOT" -eq 0 ] && [ "$EUID" == "0" ]; then
22 echo "Do not run this script as root!" >&2
23 echo "Use $IGNORE_ROOT_ARG to ignore this error." >&2
24 exit 1
25 fi
26
27 set -e
28 set -u
29
30 COMPOSER_COMMAND='composer'
31 REQUIRE_FILE='scripts/require.sh'
32
33 if [ ! -f "$REQUIRE_FILE" ]; then
34 echo "Cannot find $REQUIRE_FILE"
35 exit 1
36 fi
37
38 . "$REQUIRE_FILE"
39
40 # Check for wallabag .git folder
41 if [ ! -d .git ]; then
42 echo "Can not update because wallabag wasn't installed using git (see https://doc.wallabag.org/en/admin/upgrade.html#upgrade-on-a-shared-hosting). Aborting.";
43 exit 2;
44 fi
45
46 rm -rf var/cache/*
47 git fetch origin
48 git fetch --tags
49 TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
50 git checkout $TAG --force
51 SYMFONY_ENV=$ENV $COMPOSER_COMMAND install --no-dev -o --prefer-dist
52 php bin/console doctrine:migrations:migrate --no-interaction --env=$ENV
53 php bin/console cache:clear --env=$ENV