Skip to content

Commit eada9f3

Browse files
authored
Refactor (#6373)
1 parent fb8c44b commit eada9f3

2 files changed

Lines changed: 14 additions & 37 deletions

File tree

ct/koillection.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ function update_script() {
2828
exit
2929
fi
3030
RELEASE=$(curl -fsSL https://api.github.com/repos/benjaminjonard/koillection/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
31+
if [[ ! -f ~/.koillection ]] || [[ "${RELEASE}" != "$(cat ~/.koillection)" ]]; then
3232
msg_info "Stopping Service"
3333
systemctl stop apache2
3434
msg_ok "Stopped Service"
3535

36-
msg_info "Updating ${APP} to v${RELEASE}"
37-
cd /opt
36+
msg_info "Creating a backup"
3837
mv /opt/koillection/ /opt/koillection-backup
39-
curl -fsSL "https://github.com/benjaminjonard/koillection/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/benjaminjonard/koillection/archive/refs/tags/${RELEASE}.zip")
40-
$STD unzip "${RELEASE}.zip"
41-
mv "/opt/koillection-${RELEASE}" /opt/koillection
38+
msg_ok "Backup created"
39+
40+
fetch_and_deploy_gh_release "koillection" "benjaminjonard/koillection"
41+
42+
msg_info "Updating ${APP} to v${RELEASE}"
4243
cd /opt/koillection
4344
cp -r /opt/koillection-backup/.env.local /opt/koillection
4445
cp -r /opt/koillection-backup/public/uploads/. /opt/koillection/public/uploads/
@@ -50,17 +51,16 @@ function update_script() {
5051
$STD yarn install
5152
$STD yarn build
5253
chown -R www-data:www-data /opt/koillection/public/uploads
53-
echo "${RELEASE}" >/opt/${APP}_version.txt
5454
msg_ok "Updated $APP to v${RELEASE}"
5555

5656
msg_info "Starting Service"
5757
systemctl start apache2
5858
msg_ok "Started Service"
5959

6060
msg_info "Cleaning up"
61-
rm -r "/opt/${RELEASE}.zip"
6261
rm -r /opt/koillection-backup
6362
msg_ok "Cleaned"
63+
6464
msg_ok "Updated Successfully"
6565
else
6666
msg_ok "No update required. ${APP} is already at v${RELEASE}"

install/koillection-install.sh

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,10 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Dependencies"
17-
$STD apt-get install -y \
18-
apache2 \
19-
lsb-release
20-
msg_ok "Installed Dependencies"
21-
2216
NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs
2317
PG_VERSION="16" setup_postgresql
24-
25-
msg_info "Setup PHP8.4 Repository"
26-
$STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
27-
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
28-
$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'
29-
$STD apt-get update
30-
msg_ok "Setup PHP8.4 Repository"
31-
32-
msg_info "Setup PHP"
33-
$STD apt-get install -y \
34-
php8.4 \
35-
php8.4-{apcu,ctype,curl,dom,fileinfo,gd,iconv,intl,mbstring,pgsql} \
36-
libapache2-mod-php8.4 \
37-
composer
38-
msg_info "Setup PHP"
18+
PHP_VERSION="8.4" PHP_APACHE="YES" PHP_MODULE="apcu,ctype,dom,fileinfo,iconv,pgsql" setup_php
19+
setup_composer
3920

4021
msg_info "Setting up PostgreSQL"
4122
DB_NAME=koillection
@@ -51,12 +32,9 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMP
5132
} >>~/koillection.creds
5233
msg_ok "Set up PostgreSQL"
5334

54-
msg_info "Installing Koillection"
55-
RELEASE=$(curl -fsSL https://api.github.com/repos/benjaminjonard/koillection/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
56-
cd /opt
57-
curl -fsSL "https://github.com/benjaminjonard/koillection/archive/refs/tags/${RELEASE}.zip" -o "/opt/${RELEASE}.zip"
58-
$STD unzip "${RELEASE}.zip"
59-
mv "/opt/koillection-${RELEASE}" /opt/koillection
35+
fetch_and_deploy_gh_release "koillection" "benjaminjonard/koillection"
36+
37+
msg_info "Configuring Koillection"
6038
cd /opt/koillection
6139
cp /opt/koillection/.env /opt/koillection/.env.local
6240
APP_SECRET=$(openssl rand -base64 32)
@@ -76,7 +54,7 @@ $STD yarn install
7654
$STD yarn build
7755
chown -R www-data:www-data /opt/koillection/public/uploads
7856
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
79-
msg_ok "Installed Koillection"
57+
msg_ok "Configured Koillection"
8058

8159
msg_info "Creating Service"
8260
cat <<EOF >/etc/apache2/sites-available/koillection.conf
@@ -107,7 +85,6 @@ motd_ssh
10785
customize
10886

10987
msg_info "Cleaning up"
110-
rm -rf "/opt/${RELEASE}.zip"
11188
$STD apt-get -y autoremove
11289
$STD apt-get -y autoclean
11390
msg_ok "Cleaned"

0 commit comments

Comments
 (0)