@@ -20,79 +20,79 @@ color
2020catch_errors
2121
2222function update_script() {
23- header_info
24- check_container_storage
25- check_container_resources
26-
27- # Check if installation is present | -f for file, -d for folder
28- if [[ ! -d " /opt/2fauth" ]]; then
29- msg_error " No ${APP} Installation Found!"
30- exit
23+ header_info
24+ check_container_storage
25+ check_container_resources
26+
27+ # Check if installation is present | -f for file, -d for folder
28+ if [[ ! -d " /opt/2fauth" ]]; then
29+ msg_error " No ${APP} Installation Found!"
30+ exit
31+ fi
32+
33+ # Crawling the new version and checking whether an update is required
34+ RELEASE=$( curl -fsSL https://api.github.com/repos/Bubka/2FAuth/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
35+ if [[ " ${RELEASE} " != " $( cat /opt/2fauth_version.txt) " ]] || [[ ! -f /opt/2fauth_version.txt ]]; then
36+ msg_info " Updating $APP to ${RELEASE} "
37+
38+ $STD apt-get update
39+ $STD apt-get -y upgrade
40+
41+ # Creating Backup
42+ msg_info " Creating Backup"
43+ mv " /opt/2fauth" " /opt/2fauth-backup"
44+ if ! dpkg -l | grep -q ' php8.3' ; then
45+ cp /etc/nginx/conf.d/2fauth.conf /etc/nginx/conf.d/2fauth.conf.bak
46+ fi
47+ msg_ok " Backup Created"
48+
49+ # Upgrade PHP
50+ if ! dpkg -l | grep -q ' php8.3' ; then
51+ $STD apt-get install -y \
52+ lsb-release \
53+ gpg
54+ curl -fsSL https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /usr/share/keyrings/deb.sury.org-php.gpg
55+ echo " deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $( lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
56+ $STD apt-get update
57+ $STD apt-get install -y php8.3-{bcmath,common,ctype,curl,fileinfo,fpm,gd,mbstring,mysql,xml,cli,intl}
58+ sed -i ' s/php8.2/php8.3/g' /etc/nginx/conf.d/2fauth.conf
3159 fi
3260
33- # Crawling the new version and checking whether an update is required
34- RELEASE=$( curl -fsSL https://api.github.com/repos/Bubka/2FAuth/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
35- if [[ " ${RELEASE} " != " $( cat /opt/2fauth_version.txt) " ]] || [[ ! -f /opt/2fauth_version.txt ]]; then
36- msg_info " Updating $APP to ${RELEASE} "
37-
38- $STD apt-get update
39- $STD apt-get -y upgrade
40-
41- # Creating Backup
42- msg_info " Creating Backup"
43- mv " /opt/2fauth" " /opt/2fauth-backup"
44- if ! dpkg -l | grep -q ' php8.3' ; then
45- cp /etc/nginx/conf.d/2fauth.conf /etc/nginx/conf.d/2fauth.conf.bak
46- fi
47- msg_ok " Backup Created"
48-
49- # Upgrade PHP
50- if ! dpkg -l | grep -q ' php8.3' ; then
51- $STD apt-get install -y \
52- lsb-release \
53- gpg
54- curl -fsSL https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /usr/share/keyrings/deb.sury.org-php.gpg
55- echo " deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $( lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
56- $STD apt-get update
57- $STD apt-get install -y php8.3-{bcmath,common,ctype,curl,fileinfo,fpm,gd,mbstring,mysql,xml,cli,intl}
58- sed -i ' s/php8.2/php8.3/g' /etc/nginx/conf.d/2fauth.conf
59- fi
60-
61- # Execute Update
62- curl -fsSL -o " ${RELEASE} .zip" " https://github.com/Bubka/2FAuth/archive/refs/tags/${RELEASE} .zip"
63- unzip -q " ${RELEASE} .zip"
64- mv " 2FAuth-${RELEASE// v/ } /" " /opt/2fauth"
65- mv " /opt/2fauth-backup/.env" " /opt/2fauth/.env"
66- mv " /opt/2fauth-backup/storage" " /opt/2fauth/storage"
67- cd " /opt/2fauth" || return
68-
69- chown -R www-data: " /opt/2fauth"
70- chmod -R 755 " /opt/2fauth"
71-
72- export COMPOSER_ALLOW_SUPERUSER=1
73- $STD composer install --no-dev --prefer-source
74-
75- php artisan 2fauth:install
76-
77- $STD systemctl restart nginx
78-
79- # Cleaning up
80- msg_info " Cleaning Up"
81- rm -rf " v${RELEASE} .zip"
82- if dpkg -l | grep -q ' php8.2' ; then
83- $STD apt-get remove --purge -y php8.2*
84- fi
85- $STD apt-get -y autoremove
86- $STD apt-get -y autoclean
87- msg_ok " Cleanup Completed"
88-
89- # Last Action
90- echo " ${RELEASE} " > /opt/2fauth_version.txt
91- msg_ok " Updated $APP to ${RELEASE} "
92- else
93- msg_ok " No update required. ${APP} is already at ${RELEASE} "
61+ # Execute Update
62+ curl -fsSL -o " ${RELEASE} .zip" " https://github.com/Bubka/2FAuth/archive/refs/tags/${RELEASE} .zip"
63+ $STD unzip " ${RELEASE} .zip"
64+ mv " 2FAuth-${RELEASE// v/ } /" " /opt/2fauth"
65+ mv " /opt/2fauth-backup/.env" " /opt/2fauth/.env"
66+ mv " /opt/2fauth-backup/storage" " /opt/2fauth/storage"
67+ cd " /opt/2fauth" || return
68+
69+ chown -R www-data: " /opt/2fauth"
70+ chmod -R 755 " /opt/2fauth"
71+
72+ export COMPOSER_ALLOW_SUPERUSER=1
73+ $STD composer install --no-dev --prefer-source
74+
75+ php artisan 2fauth:install
76+
77+ $STD systemctl restart nginx
78+
79+ # Cleaning up
80+ msg_info " Cleaning Up"
81+ rm -rf " v${RELEASE} .zip"
82+ if dpkg -l | grep -q ' php8.2' ; then
83+ $STD apt-get remove --purge -y php8.2*
9484 fi
95- exit
85+ $STD apt-get -y autoremove
86+ $STD apt-get -y autoclean
87+ msg_ok " Cleanup Completed"
88+
89+ # Last Action
90+ echo " ${RELEASE} " > /opt/2fauth_version.txt
91+ msg_ok " Updated $APP to ${RELEASE} "
92+ else
93+ msg_ok " No update required. ${APP} is already at ${RELEASE} "
94+ fi
95+ exit
9696}
9797
9898start
@@ -102,4 +102,4 @@ description
102102msg_ok " Completed Successfully!\n"
103103echo -e " ${CREATING}${GN}${APP} setup has been successfully initialized!${CL} "
104104echo -e " ${INFO}${YW} Access it using the following URL:${CL} "
105- echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :80${CL} "
105+ echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :80${CL} "
0 commit comments