@@ -5,13 +5,6 @@ if [[ $EUID -ne 0 ]]; then
55 exit 1
66fi
77
8- function exitInstall {
9- cd " $install_dir "
10- php artisan up
11- echo " Panel is out of maintenance mode."
12- exit $1
13- }
14-
158read -p " Enter the directory for the panel location [/var/www/pelican]: " install_dir
169install_dir=${install_dir:-/ var/ www/ pelican}
1710
@@ -35,15 +28,7 @@ group=$(stat -c '%G' "$install_dir" || echo "www-data")
3528read -p " Enter the group of the files (www-data, apache, nginx) [$group ]: " group
3629group=${group:- www-data}
3730
38- cd " $install_dir "
39- php artisan down
40- if [ $? -ne 0 ]; then
41- echo " Failed to put the panel into maintenance mode."
42- exitInstall 1
43- fi
44- echo " Panel is now in maintenance mode."
45-
46- db_connection=$( grep " ^DB_CONNECTION=" " $env_file " | cut -d ' =' -f 2)
31+ db_connection=$( grep " ^DB_CONNECTION=" " $env_file " | cut -d ' =' -f 2 | tr -d " \" '" )
4732
4833if [ -z " $db_connection " ]; then
4934 db_connection=' sqlite'
@@ -56,29 +41,33 @@ read -p "Do you want to create a backup? (y/n) [y]: " backup_confirm
5641backup_confirm=${backup_confirm:- y}
5742if [ " $backup_confirm " != " y" ]; then
5843 echo " Backup canceled."
59- exitInstall 0
44+ exit 1
6045fi
6146
6247backup_dir=" $install_dir /backup"
6348mkdir -p " $backup_dir /storage/app"
49+ if [ $? -ne 0 ]; then
50+ echo " Failed to create backup directory $backup_dir , aborting"
51+ exit 1
52+ fi
6453
6554cp -a " $env_file " " $backup_dir /.env.backup"
6655if [ $? -ne 0 ]; then
6756 echo " Failed to backup .env file, aborting"
68- exitInstall 1
57+ exit 1
6958fi
7059echo " Backed up .env file successfully."
7160
7261if [ -d " $install_dir /storage/app/public" ]; then
7362 cp -a " $install_dir /storage/app/public" " $backup_dir /storage/app/"
7463 if [ $? -ne 0 ]; then
7564 echo " Failed to backup avatars & fonts files, aborting"
76- exitInstall 1
65+ exit 1
7766 fi
7867fi
7968
8069if [ " $db_connection " = " sqlite" ]; then
81- db_database=$( grep " ^DB_DATABASE=" " $env_file " | cut -d ' =' -f 2)
70+ db_database=$( grep " ^DB_DATABASE=" " $env_file " | cut -d ' =' -f 2 | tr -d " \" ' " )
8271
8372 if [ -z " $db_database " ]; then
8473 uses_default=true
@@ -97,14 +86,14 @@ if [ "$db_connection" = "sqlite" ]; then
9786 cp -a " $install_dir /database/$db_database " " $backup_dir /$db_database .backup"
9887 if [ $? -ne 0 ]; then
9988 echo " Failed to backup $db_database file, aborting"
100- exitInstall 1
89+ exit 1
10190 fi
10291else
10392 read -p " NOTE: THIS WILL NOT BACKUP MySQL/MariaDB DATABASES!!! You should pause now and make your own backup!! You've been warned! Continue? (y/n) [y]: " database_confirm
10493 database_confirm=${database_confirm:- y}
10594 if [ " $database_confirm " != " y" ]; then
10695 echo " Update Canceled."
107- exitInstall 0
96+ exit 1
10897 fi
10998fi
11099
@@ -118,62 +107,50 @@ if [[ -z "$expected_checksum" || -z "$calculated_checksum" || "$expected_checksu
118107 checksum_confirm=${checksum_confirm:- y}
119108 if [ " $checksum_confirm " != " y" ]; then
120109 echo " Update Canceled."
121- exitInstall 1
110+ exit 1
122111 fi
112+ else
113+ echo " Checksum verified."
123114fi
124115
125- echo " Checksum verified."
126116read -p " Do you want to delete all files and folders in $install_dir except the backup folder? (y/n) [y]: " delete_confirm
127117delete_confirm=${delete_confirm:- y}
128118if [ " $delete_confirm " != " y" ]; then
129119 echo " Deletion canceled."
130- exitInstall 0
120+ exit 1
131121fi
132122
133- find " $install_dir " -mindepth 1 -maxdepth 1 ! -name ' backup' ! -name ' panel.tar.gz' ! -name ' artisan ' -exec rm -rf {} +
123+ find " $install_dir " -mindepth 1 -maxdepth 1 ! -name ' backup' ! -name ' panel.tar.gz' -exec rm -rf {} +
134124if [ $? -ne 0 ]; then
135125 echo " Failed to delete old files, aborting"
136- exitInstall 1
126+ exit 1
137127fi
138128echo " Deleted all files and folders in $install_dir except the backup folder."
139129
140130echo " Extracting tarball."
141131tar -xzf panel.tar.gz -C " $install_dir "
142132if [ $? -ne 0 ]; then
143133 echo " Failed to extract tarball, aborting"
144- exitInstall 1
134+ exit 1
145135fi
146136rm panel.tar.gz
147137if [ $? -ne 0 ]; then
148138 echo " Failed to delete leftover tarball, continuing."
149139fi
150140
151- echo " Installing Composer"
152- COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader --no-interaction
153- if [ $? -ne 0 ]; then
154- echo " Failed to run composer, aborting"
155- exitInstall 1
156- fi
157-
158- php artisan down
159- if [ $? -ne 0 ]; then
160- echo " Failed to put the panel into maintenance mode."
161- exitInstall 1
162- fi
163-
164141echo " Restoring .env"
165142cp -a " $backup_dir /.env.backup" " $install_dir /.env"
166143if [ $? -ne 0 ]; then
167144 echo " Failed to restore the .env file, aborting"
168- exitInstall 1
145+ exit 1
169146fi
170147
171148if [ -d " $backup_dir /storage/app/public" ]; then
172149 echo " Restoring avatars & fonts"
173150 cp -a " $backup_dir /storage/app/public" " $install_dir /storage/app/"
174151 if [ $? -ne 0 ]; then
175152 echo " Failed to restore avatars & fonts files, aborting"
176- exitInstall 1
153+ exit 1
177154 fi
178155fi
179156
@@ -182,10 +159,19 @@ if [ -f "$backup_dir/$db_database.backup" ]; then
182159 cp -a " $backup_dir /$db_database .backup" " $install_dir /database/$db_database "
183160 if [ $? -ne 0 ]; then
184161 echo " Failed to restore the database, aborting"
185- exitInstall 1
162+ exit 1
186163 fi
187164fi
188165
166+ cd $install_dir
167+
168+ echo " Installing Composer"
169+ COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader --no-interaction
170+ if [ $? -ne 0 ]; then
171+ echo " Failed to run composer, aborting"
172+ exit 1
173+ fi
174+
189175echo " Optimizing"
190176php artisan optimize:clear
191177php artisan filament:optimize
@@ -211,8 +197,6 @@ if [ $? -ne 0 ]; then
211197fi
212198
213199php artisan queue:restart
214- php artisan up
215200
216- echo " Panel is now live and out of maintenance mode."
217201echo " Panel Updated!"
218202exit 0
0 commit comments