@@ -20,64 +20,79 @@ color
2020catch_errors
2121
2222function update_script() {
23- header_info
24- check_container_storage
25- check_container_resources
26- if [[ ! -d /opt/kimai ]]; then
27- msg_error " No ${APP} Installation Found!"
28- exit
29- fi
30- RELEASE=$( curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
31- BACKUP_DIR=" /opt/kimai_backup"
23+ header_info
24+ check_container_storage
25+ check_container_resources
26+ if [[ ! -d /opt/kimai ]]; then
27+ msg_error " No ${APP} Installation Found!"
28+ exit
29+ fi
30+ CURRENT_PHP=$( php -v 2> /dev/null | awk ' /^PHP/{print $2}' | cut -d. -f1,2)
31+ if [[ " $CURRENT_PHP " != " 8.4" ]]; then
32+ msg_info " Migrating PHP $CURRENT_PHP to 8.4"
33+ $STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
34+ $STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
35+ $STD sh -c ' 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'
36+ $STD apt-get update
37+ $STD apt-get remove -y php" ${CURRENT_PHP// ./ } " *
38+ $STD apt-get install -y \
39+ php8.4 \
40+ php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl} \
41+ libapache2-mod-php8.4
42+ msg_ok " Migrated PHP $CURRENT_PHP to 8.4"
43+ fi
3244
33- if [[ ! -f /opt/${APP} _version.txt ]] || [[ " ${RELEASE} " != " $( cat /opt/${APP} _version.txt) " ]]; then
34- msg_info " Stopping Apache2"
35- systemctl stop apache2
36- msg_ok " Stopped Apache2"
45+ RELEASE=$( curl -fsSL https://api.github.com/repos/kimai/kimai/releases/latest | grep " tag_name" | awk ' {print substr($2, 2, length($2)-3) }' )
46+ BACKUP_DIR=" /opt/kimai_backup"
3747
38- msg_info " Backing up Kimai configuration and var directory"
39- mkdir -p " $BACKUP_DIR "
40- [ -d /opt/kimai/var ] && cp -r /opt/kimai/var " $BACKUP_DIR /"
41- [ -f /opt/kimai/.env ] && cp /opt/kimai/.env " $BACKUP_DIR /"
42- [ -f /opt/kimai/config/packages/local.yaml ] && cp /opt/kimai/config/packages/local.yaml " $BACKUP_DIR /"
43- msg_ok " Backup completed"
48+ if [[ ! -f /opt/${APP} _version.txt ]] || [[ " ${RELEASE} " != " $( cat /opt/${APP} _version.txt) " ]]; then
49+ msg_info " Stopping Apache2"
50+ systemctl stop apache2
51+ msg_ok " Stopped Apache2"
4452
45- msg_info " Updating ${APP} to ${RELEASE} "
46- rm -rf /opt/kimai
47- curl -fsSL " https://github.com/kimai/kimai/archive/refs/tags/${RELEASE} .zip" -o $( basename " https://github.com/kimai/kimai/archive/refs/tags/${RELEASE} .zip" )
48- unzip -q ${RELEASE} .zip
49- mv kimai-${RELEASE} /opt/kimai
50- [ -d " $BACKUP_DIR /var" ] && cp -r " $BACKUP_DIR /var" /opt/kimai/
51- [ -f " $BACKUP_DIR /.env" ] && cp " $BACKUP_DIR /.env" /opt/kimai/
52- [ -f " $BACKUP_DIR /local.yaml" ] && cp " $BACKUP_DIR /local.yaml" /opt/kimai/config/packages/
53- rm -rf " $BACKUP_DIR "
54- cd /opt/kimai
55- $STD composer install --no-dev --optimize-autoloader
56- $STD bin/console kimai:update
57- echo " ${RELEASE} " > /opt/${APP} _version.txt
58- msg_ok " Updated ${APP} to ${RELEASE} "
53+ msg_info " Backing up Kimai configuration and var directory"
54+ mkdir -p " $BACKUP_DIR "
55+ [ -d /opt/kimai/var ] && cp -r /opt/kimai/var " $BACKUP_DIR /"
56+ [ -f /opt/kimai/.env ] && cp /opt/kimai/.env " $BACKUP_DIR /"
57+ [ -f /opt/kimai/config/packages/local.yaml ] && cp /opt/kimai/config/packages/local.yaml " $BACKUP_DIR /"
58+ msg_ok " Backup completed"
5959
60- msg_info " Starting Apache2"
61- systemctl start apache2
62- msg_ok " Started Apache2"
60+ msg_info " Updating ${APP} to ${RELEASE} "
61+ rm -rf /opt/kimai
62+ curl -fsSL " https://github.com/kimai/kimai/archive/refs/tags/${RELEASE} .zip" -o $( basename " https://github.com/kimai/kimai/archive/refs/tags/${RELEASE} .zip" )
63+ unzip -q " ${RELEASE} " .zip
64+ mv kimai-" ${RELEASE} " /opt/kimai
65+ [ -d " $BACKUP_DIR /var" ] && cp -r " $BACKUP_DIR /var" /opt/kimai/
66+ [ -f " $BACKUP_DIR /.env" ] && cp " $BACKUP_DIR /.env" /opt/kimai/
67+ [ -f " $BACKUP_DIR /local.yaml" ] && cp " $BACKUP_DIR /local.yaml" /opt/kimai/config/packages/
68+ rm -rf " $BACKUP_DIR "
69+ cd /opt/kimai || exit
70+ $STD composer install --no-dev --optimize-autoloader
71+ $STD bin/console kimai:update
72+ echo " ${RELEASE} " > /opt/${APP} _version.txt
73+ msg_ok " Updated ${APP} to ${RELEASE} "
6374
64- msg_info " Setup Permissions"
65- chown -R :www-data /opt/*
66- chmod -R g+r /opt/*
67- chmod -R g+rw /opt/*
68- chown -R www-data:www-data /opt/*
69- chmod -R 777 /opt/*
70- msg_ok " Setup Permissions"
75+ msg_info " Starting Apache2"
76+ systemctl start apache2
77+ msg_ok " Started Apache2"
7178
72- msg_info " Cleaning Up"
73- rm -rf ${RELEASE} .zip
74- rm -rf " $BACKUP_DIR "
75- msg_ok " Cleaned"
76- msg_ok " Updated Successfully"
77- else
78- msg_ok " No update required. ${APP} is already at ${RELEASE} "
79- fi
80- exit
79+ msg_info " Setup Permissions"
80+ chown -R :www-data /opt/*
81+ chmod -R g+r /opt/*
82+ chmod -R g+rw /opt/*
83+ chown -R www-data:www-data /opt/*
84+ chmod -R 777 /opt/*
85+ msg_ok " Setup Permissions"
86+
87+ msg_info " Cleaning Up"
88+ rm -rf " ${RELEASE} " .zip
89+ rm -rf " $BACKUP_DIR "
90+ msg_ok " Cleaned"
91+ msg_ok " Updated Successfully"
92+ else
93+ msg_ok " No update required. ${APP} is already at ${RELEASE} "
94+ fi
95+ exit
8196}
8297
8398start
0 commit comments