This commit is contained in:
Slaviša Arežina 2025-07-30 15:19:33 +02:00 committed by GitHub
parent fb8c44b753
commit eada9f3ae8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 37 deletions

View File

@ -28,17 +28,18 @@ function update_script() {
exit exit
fi fi
RELEASE=$(curl -fsSL https://api.github.com/repos/benjaminjonard/koillection/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') RELEASE=$(curl -fsSL https://api.github.com/repos/benjaminjonard/koillection/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then if [[ ! -f ~/.koillection ]] || [[ "${RELEASE}" != "$(cat ~/.koillection)" ]]; then
msg_info "Stopping Service" msg_info "Stopping Service"
systemctl stop apache2 systemctl stop apache2
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Updating ${APP} to v${RELEASE}" msg_info "Creating a backup"
cd /opt
mv /opt/koillection/ /opt/koillection-backup mv /opt/koillection/ /opt/koillection-backup
curl -fsSL "https://github.com/benjaminjonard/koillection/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/benjaminjonard/koillection/archive/refs/tags/${RELEASE}.zip") msg_ok "Backup created"
$STD unzip "${RELEASE}.zip"
mv "/opt/koillection-${RELEASE}" /opt/koillection fetch_and_deploy_gh_release "koillection" "benjaminjonard/koillection"
msg_info "Updating ${APP} to v${RELEASE}"
cd /opt/koillection cd /opt/koillection
cp -r /opt/koillection-backup/.env.local /opt/koillection cp -r /opt/koillection-backup/.env.local /opt/koillection
cp -r /opt/koillection-backup/public/uploads/. /opt/koillection/public/uploads/ cp -r /opt/koillection-backup/public/uploads/. /opt/koillection/public/uploads/
@ -50,7 +51,6 @@ function update_script() {
$STD yarn install $STD yarn install
$STD yarn build $STD yarn build
chown -R www-data:www-data /opt/koillection/public/uploads chown -R www-data:www-data /opt/koillection/public/uploads
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP to v${RELEASE}" msg_ok "Updated $APP to v${RELEASE}"
msg_info "Starting Service" msg_info "Starting Service"
@ -58,9 +58,9 @@ function update_script() {
msg_ok "Started Service" msg_ok "Started Service"
msg_info "Cleaning up" msg_info "Cleaning up"
rm -r "/opt/${RELEASE}.zip"
rm -r /opt/koillection-backup rm -r /opt/koillection-backup
msg_ok "Cleaned" msg_ok "Cleaned"
msg_ok "Updated Successfully" msg_ok "Updated Successfully"
else else
msg_ok "No update required. ${APP} is already at v${RELEASE}" msg_ok "No update required. ${APP} is already at v${RELEASE}"

View File

@ -13,29 +13,10 @@ setting_up_container
network_check network_check
update_os update_os
msg_info "Installing Dependencies"
$STD apt-get install -y \
apache2 \
lsb-release
msg_ok "Installed Dependencies"
NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs
PG_VERSION="16" setup_postgresql PG_VERSION="16" setup_postgresql
PHP_VERSION="8.4" PHP_APACHE="YES" PHP_MODULE="apcu,ctype,dom,fileinfo,iconv,pgsql" setup_php
msg_info "Setup PHP8.4 Repository" setup_composer
$STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
$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'
$STD apt-get update
msg_ok "Setup PHP8.4 Repository"
msg_info "Setup PHP"
$STD apt-get install -y \
php8.4 \
php8.4-{apcu,ctype,curl,dom,fileinfo,gd,iconv,intl,mbstring,pgsql} \
libapache2-mod-php8.4 \
composer
msg_info "Setup PHP"
msg_info "Setting up PostgreSQL" msg_info "Setting up PostgreSQL"
DB_NAME=koillection DB_NAME=koillection
@ -51,12 +32,9 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMP
} >>~/koillection.creds } >>~/koillection.creds
msg_ok "Set up PostgreSQL" msg_ok "Set up PostgreSQL"
msg_info "Installing Koillection" fetch_and_deploy_gh_release "koillection" "benjaminjonard/koillection"
RELEASE=$(curl -fsSL https://api.github.com/repos/benjaminjonard/koillection/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
cd /opt msg_info "Configuring Koillection"
curl -fsSL "https://github.com/benjaminjonard/koillection/archive/refs/tags/${RELEASE}.zip" -o "/opt/${RELEASE}.zip"
$STD unzip "${RELEASE}.zip"
mv "/opt/koillection-${RELEASE}" /opt/koillection
cd /opt/koillection cd /opt/koillection
cp /opt/koillection/.env /opt/koillection/.env.local cp /opt/koillection/.env /opt/koillection/.env.local
APP_SECRET=$(openssl rand -base64 32) APP_SECRET=$(openssl rand -base64 32)
@ -76,7 +54,7 @@ $STD yarn install
$STD yarn build $STD yarn build
chown -R www-data:www-data /opt/koillection/public/uploads chown -R www-data:www-data /opt/koillection/public/uploads
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
msg_ok "Installed Koillection" msg_ok "Configured Koillection"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/apache2/sites-available/koillection.conf cat <<EOF >/etc/apache2/sites-available/koillection.conf
@ -107,7 +85,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf "/opt/${RELEASE}.zip"
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
msg_ok "Cleaned" msg_ok "Cleaned"