Skip to content

Commit 8522928

Browse files
authored
firefly: refactor update_script and add dataimporter update (#9178)
* firefly: refactor update_script and add dataimporter update Refactor update_script function to improve clarity and organization. Added checks for data importer installation and streamlined permission settings. * Remove empty line before update_script function * Add update messages for Firefly and Importer
1 parent 65b8180 commit 8522928

File tree

1 file changed

+44
-19
lines changed

1 file changed

+44
-19
lines changed

ct/firefly.sh

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,65 @@ function update_script() {
2828
msg_error "No ${APP} Installation Found!"
2929
exit
3030
fi
31+
3132
if check_for_gh_release "firefly" "firefly-iii/firefly-iii"; then
32-
msg_info "Stopping Apache2"
3333
systemctl stop apache2
34-
msg_ok "Stopped Apache2"
35-
36-
msg_info "Backing up data"
3734
cp /opt/firefly/.env /opt/.env
3835
cp -r /opt/firefly/storage /opt/storage
39-
msg_ok "Backed up data"
36+
37+
if [[ -d /opt/firefly/dataimporter ]]; then
38+
cp /opt/firefly/dataimporter/.env /opt/dataimporter.env
39+
IMPORTER_INSTALLED=1
40+
fi
4041

4142
fetch_and_deploy_gh_release "firefly" "firefly-iii/firefly-iii" "prebuild" "latest" "/opt/firefly" "FireflyIII-*.zip"
4243
setup_composer
4344

44-
msg_info "Updating ${APP}"
45+
msg_info "Updating Firefly"
4546
rm -rf /opt/firefly/storage
46-
cp /opt/.env /opt/firefly/.env
4747
cp -r /opt/storage /opt/firefly/storage
48+
cp /opt/.env /opt/firefly/.env
4849

4950
chown -R www-data:www-data /opt/firefly
50-
find /opt/firefly/storage -type d -exec chmod 775 {} \;
51-
find /opt/firefly/storage -type f -exec chmod 664 {} \;
52-
mkdir -p /opt/firefly/storage/framework/{cache/data,sessions,views}
53-
$STD sudo -u www-data php /opt/firefly/artisan cache:clear
51+
chmod -R 775 /opt/firefly/storage
52+
mkdir -p /opt/firefly/storage/framework/cache/data
53+
mkdir -p /opt/firefly/storage/framework/sessions
54+
mkdir -p /opt/firefly/storage/framework/views
55+
mkdir -p /opt/firefly/storage/logs
56+
mkdir -p /opt/firefly/bootstrap/cache
57+
chown -R www-data:www-data /opt/firefly/{storage,bootstrap/cache}
5458
cd /opt/firefly
55-
$STD php artisan migrate --seed --force
56-
$STD php artisan cache:clear
57-
$STD php artisan view:clear
58-
$STD php artisan firefly-iii:upgrade-database
59-
$STD php artisan firefly-iii:laravel-passport-keys
60-
msg_ok "Updated ${APP}"
59+
$STD runuser -u www-data -- composer install --no-dev --optimize-autoloader
60+
$STD runuser -u www-data -- composer dump-autoload -o
61+
62+
$STD runuser -u www-data -- php artisan cache:clear
63+
$STD runuser -u www-data -- php artisan config:clear
64+
$STD runuser -u www-data -- php artisan route:clear
65+
$STD runuser -u www-data -- php artisan view:clear
66+
67+
$STD runuser -u www-data -- php artisan migrate --seed --force
68+
$STD runuser -u www-data -- php artisan firefly-iii:upgrade-database
69+
$STD runuser -u www-data -- php artisan firefly-iii:laravel-passport-keys
70+
71+
$STD runuser -u www-data -- php artisan storage:link || true
72+
$STD runuser -u www-data -- php artisan optimize
73+
msg_ok "Updated Firefly"
6174

62-
msg_info "Starting Apache2"
75+
if [[ "${IMPORTER_INSTALLED:-0}" -eq 1 ]]; then
76+
msg_info "Updating Firefly Importer"
77+
IMPORTER_RELEASE=$(curl -fsSL https://api.github.com/repos/firefly-iii/data-importer/releases/latest | grep tag_name | cut -d '"' -f 4 | sed 's/v//')
78+
rm -rf /opt/firefly/dataimporter
79+
mkdir -p /opt/firefly/dataimporter
80+
curl -fsSL "https://github.com/firefly-iii/data-importer/releases/download/v${IMPORTER_RELEASE}/DataImporter-v${IMPORTER_RELEASE}.tar.gz" -o "/opt/DataImporter.tar.gz"
81+
tar -xzf /opt/DataImporter.tar.gz -C /opt/firefly/dataimporter
82+
if [[ -f /opt/dataimporter.env ]]; then
83+
cp /opt/dataimporter.env /opt/firefly/dataimporter/.env
84+
fi
85+
chown -R www-data:www-data /opt/firefly/dataimporter
86+
rm -f /opt/DataImporter.tar.gz
87+
msg_ok "Updated Firefly Importer"
88+
fi
6389
systemctl start apache2
64-
msg_ok "Started Apache2"
6590
msg_ok "Updated successfully!"
6691
fi
6792
exit

0 commit comments

Comments
 (0)