-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathupdate.sh
More file actions
63 lines (50 loc) · 1.53 KB
/
update.sh
File metadata and controls
63 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/bash
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
# Clear the caches
php artisan down
php artisan route:clear
php artisan cache:clear
php artisan config:clear
php artisan view:clear
php artisan optimize:clear
php artisan clear
# Try taking pull, if dont work then prompt for stash
if git pull; then
echo "${Green}Git pull successful! Continuing update..."
else
echo "${Yellow}Warning! You have local changes which will get lost. Type Y to continue, N to cancel update."
read continueUpdate
if [ $continueUpdate != 'Y' ]; then
php artisan up
echo "${Red}Update cancelled!"
exit 1
fi
git stash
git pull
fi
export COMPOSER_ALLOW_SUPERUSER=1 # not that important but it clears the root user request log from composer
yes | composer install
php artisan migrate --force --seed
php artisan queue:restart
chmod -R 775 storage/* bootstrap/cache
chown -R $USER:www-data .
# Build frontend assets if using a custom theme
APP_THEME=$(grep -oP '^APP_THEME=\K.*' .env 2>/dev/null || echo "default")
if [ "$APP_THEME" != "default" ]; then
echo "${Cyan}Custom theme detected ($APP_THEME). Building frontend assets..."
npm ci
npm run prod
else
echo "${Green}Using default theme (pre-built assets)."
fi
php artisan up
php artisan optimize
echo "Success! Your application is now up-to-date."