Skip to content

Commit 1a53b74

Browse files
authored
Refactor (#5844)
1 parent f010461 commit 1a53b74

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

ct/firefly.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@ function update_script() {
2929
exit
3030
fi
3131
RELEASE=$(curl -fsSL https://api.github.com/repos/firefly-iii/firefly-iii/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
32-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32+
if [[ "${RELEASE}" != "$(cat ~/.firefly 2>/dev/null)" ]] || [[ ! -f ~/.firefly ]]; then
3333
msg_info "Stopping Apache2"
3434
systemctl stop apache2
3535
msg_ok "Stopped Apache2"
3636

37-
msg_info "Updating ${APP} to v${RELEASE}"
37+
msg_info "Backing up data"
3838
cp /opt/firefly/.env /opt/.env
3939
cp -r /opt/firefly/storage /opt/storage
40-
cd /opt
41-
curl -fsSL "https://github.com/firefly-iii/firefly-iii/releases/download/v${RELEASE}/FireflyIII-v${RELEASE}.tar.gz" -o $(basename "https://github.com/firefly-iii/firefly-iii/releases/download/v${RELEASE}/FireflyIII-v${RELEASE}.tar.gz")
42-
tar -xzf FireflyIII-v${RELEASE}.tar.gz -C /opt/firefly --exclude='storage'
40+
msg_ok "Backed up data"
41+
42+
fetch_and_deploy_gh_release "firefly" "firefly-iii/firefly-iii"
43+
44+
msg_info "Updating ${APP} to v${RELEASE}"
45+
rm -rf /opt/firefly/storage
4346
cp /opt/.env /opt/firefly/.env
4447
cp -r /opt/storage /opt/firefly/storage
4548
cd /opt/firefly
@@ -50,16 +53,12 @@ function update_script() {
5053
$STD php artisan view:clear
5154
$STD php artisan firefly-iii:upgrade-database
5255
$STD php artisan firefly-iii:laravel-passport-keys
53-
echo "${RELEASE}" >"/opt/${APP}_version.txt"
5456
msg_ok "Updated ${APP} to v${RELEASE}"
5557

5658
msg_info "Starting Apache2"
5759
systemctl start apache2
5860
msg_ok "Started Apache2"
5961

60-
msg_info "Cleaning up"
61-
rm -rf /opt/FireflyIII-v${RELEASE}.tar.gz
62-
msg_ok "Cleaned"
6362
msg_ok "Updated Successfully"
6463
else
6564
msg_ok "No update required. ${APP} is already at v${RELEASE}."

install/firefly-install.sh

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
18-
echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ bookworm main" >/etc/apt/sources.list.d/php.list
19-
$STD apt-get update
20-
$STD apt-get install -y \
21-
apache2 \
22-
libapache2-mod-php8.4 \
23-
php8.4-{bcmath,cli,intl,curl,zip,gd,xml,mbstring,mysql} \
24-
composer
17+
$STD apt-get install -y apache2
2518
msg_ok "Installed Dependencies"
2619

20+
PHP_VERSION="8.4" PHP_APACHE="YES" PHP_MODULE="mysql" setup_php
21+
setup_composer
2722
setup_mariadb
23+
fetch_and_deploy_gh_release "firefly" "firefly-iii/firefly-iii"
24+
LOCAL_IP=$(hostname -I | awk '{print $1}')
2825

2926
msg_info "Setting up database"
3027
DB_NAME=firefly
@@ -41,13 +38,7 @@ mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRI
4138
} >>~/firefly.creds
4239
msg_ok "Set up database"
4340

44-
msg_info "Installing Firefly III (Patience)"
45-
LOCAL_IP=$(hostname -I | awk '{print $1}')
46-
RELEASE=$(curl -fsSL https://api.github.com/repos/firefly-iii/firefly-iii/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
47-
cd /opt
48-
curl -fsSL "https://github.com/firefly-iii/firefly-iii/releases/download/v${RELEASE}/FireflyIII-v${RELEASE}.tar.gz" -o "FireflyIII-v${RELEASE}.tar.gz"
49-
mkdir -p /opt/firefly
50-
tar -xzf FireflyIII-v${RELEASE}.tar.gz -C /opt/firefly
41+
msg_info "Configuring Firefly III (Patience)"
5142
chown -R www-data:www-data /opt/firefly
5243
chmod -R 775 /opt/firefly/storage
5344
cd /opt/firefly
@@ -69,8 +60,7 @@ tar -xzf "DataImporter-v${IMPORTER_RELEASE}.tar.gz" -C /opt/firefly/dataimporter
6960
cp /opt/firefly/dataimporter/.env.example /opt/firefly/dataimporter/.env
7061
sed -i "s#FIREFLY_III_URL=#FIREFLY_III_URL=http://${LOCAL_IP}#g" /opt/firefly/dataimporter/.env
7162
chown -R www-data:www-data /opt/firefly
72-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
73-
msg_ok "Installed Firefly III"
63+
msg_ok "Configured Firefly III"
7464

7565
msg_info "Creating Service"
7666
cat <<EOF >/etc/apache2/sites-available/firefly.conf
@@ -112,7 +102,6 @@ motd_ssh
112102
customize
113103

114104
msg_info "Cleaning up"
115-
rm -rf "/opt/FireflyIII-v${RELEASE}.tar.gz"
116105
rm -rf "/opt/DataImporter-v${IMPORTER_RELEASE}.tar.gz"
117106
$STD apt-get -y autoremove
118107
$STD apt-get -y autoclean

0 commit comments

Comments
 (0)