diff --git a/ct/koillection.sh b/ct/koillection.sh index d77df8ae5..d24a94632 100644 --- a/ct/koillection.sh +++ b/ct/koillection.sh @@ -28,17 +28,18 @@ function update_script() { exit fi 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" systemctl stop apache2 msg_ok "Stopped Service" - msg_info "Updating ${APP} to v${RELEASE}" - cd /opt + msg_info "Creating a 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") - $STD unzip "${RELEASE}.zip" - mv "/opt/koillection-${RELEASE}" /opt/koillection + msg_ok "Backup created" + + fetch_and_deploy_gh_release "koillection" "benjaminjonard/koillection" + + msg_info "Updating ${APP} to v${RELEASE}" cd /opt/koillection cp -r /opt/koillection-backup/.env.local /opt/koillection cp -r /opt/koillection-backup/public/uploads/. /opt/koillection/public/uploads/ @@ -50,7 +51,6 @@ function update_script() { $STD yarn install $STD yarn build chown -R www-data:www-data /opt/koillection/public/uploads - echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated $APP to v${RELEASE}" msg_info "Starting Service" @@ -58,9 +58,9 @@ function update_script() { msg_ok "Started Service" msg_info "Cleaning up" - rm -r "/opt/${RELEASE}.zip" rm -r /opt/koillection-backup msg_ok "Cleaned" + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at v${RELEASE}" diff --git a/install/koillection-install.sh b/install/koillection-install.sh index ca2bddd38..e19ef3d50 100644 --- a/install/koillection-install.sh +++ b/install/koillection-install.sh @@ -13,29 +13,10 @@ setting_up_container network_check 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 PG_VERSION="16" setup_postgresql - -msg_info "Setup PHP8.4 Repository" -$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" +PHP_VERSION="8.4" PHP_APACHE="YES" PHP_MODULE="apcu,ctype,dom,fileinfo,iconv,pgsql" setup_php +setup_composer msg_info "Setting up PostgreSQL" DB_NAME=koillection @@ -51,12 +32,9 @@ $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER TEMP } >>~/koillection.creds msg_ok "Set up PostgreSQL" -msg_info "Installing 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 -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 +fetch_and_deploy_gh_release "koillection" "benjaminjonard/koillection" + +msg_info "Configuring Koillection" cd /opt/koillection cp /opt/koillection/.env /opt/koillection/.env.local APP_SECRET=$(openssl rand -base64 32) @@ -76,7 +54,7 @@ $STD yarn install $STD yarn build chown -R www-data:www-data /opt/koillection/public/uploads echo "${RELEASE}" >/opt/${APPLICATION}_version.txt -msg_ok "Installed Koillection" +msg_ok "Configured Koillection" msg_info "Creating Service" cat </etc/apache2/sites-available/koillection.conf @@ -107,7 +85,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf "/opt/${RELEASE}.zip" $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"