From 654bd1f0d50fea3baa42410953ec5a601fe2e40b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Fri, 1 Aug 2025 07:24:13 +0200 Subject: [PATCH] Refactor (#6424) --- ct/outline.sh | 20 ++++++++------------ install/outline-install.sh | 13 ++++--------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/ct/outline.sh b/ct/outline.sh index 2593c65f1..d186eb9e9 100644 --- a/ct/outline.sh +++ b/ct/outline.sh @@ -27,36 +27,32 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/outline/outline/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + if [[ ! -f ~/.outline ]] || [[ "${RELEASE}" != "$(cat ~/.outline)" ]]; then msg_info "Stopping Services" systemctl stop outline msg_ok "Services Stopped" - msg_info "Updating ${APP} to ${RELEASE}" - temp_file=$(mktemp) + msg_info "Creating backup" cp /opt/outline/.env /opt - rm -rf /opt/outline - curl -fsSL "https://github.com/outline/outline/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" - tar zxf "$temp_file" - mv outline-"${RELEASE}" /opt/outline + msg_ok "Backup created" + + fetch_and_deploy_gh_release "outline" "outline/outline" "tarball" + + msg_info "Updating ${APP} to ${RELEASE}" cd /opt/outline export NODE_ENV=development export NODE_OPTIONS="--max-old-space-size=3584" $STD yarn install --frozen-lockfile $STD yarn build mv /opt/.env /opt/outline - echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" msg_info "Starting Services" systemctl start outline msg_ok "Started Services" - msg_info "Cleaning Up" - rm -rf "$temp_file" - rm -rf "$HOME"/outline-"${RELEASE}" - msg_ok "Cleaned" msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at ${RELEASE}" diff --git a/install/outline-install.sh b/install/outline-install.sh index 1d83d1c22..15ca3832a 100644 --- a/install/outline-install.sh +++ b/install/outline-install.sh @@ -40,14 +40,11 @@ $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';" } >>~/outline.creds msg_ok "Set up PostgreSQL Database" -msg_info "Setup Outline (Patience)" +fetch_and_deploy_gh_release "outline" "outline/outline" "tarball" + +msg_info "Configuring Outline (Patience)" SECRET_KEY="$(openssl rand -hex 32)" -temp_file=$(mktemp) LOCAL_IP="$(hostname -I | awk '{print $1}')" -RELEASE=$(curl -fsSL https://api.github.com/repos/outline/outline/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -curl -fsSL "https://github.com/outline/outline/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" -tar zxf $temp_file -mv outline-${RELEASE} /opt/outline cd /opt/outline cp .env.sample .env export NODE_ENV=development @@ -62,8 +59,7 @@ export NODE_OPTIONS="--max-old-space-size=3584" $STD yarn build sed -i 's/NODE_ENV=development/NODE_ENV=production/g' /opt/outline/.env export NODE_ENV=production -echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" -msg_ok "Setup Outline" +msg_ok "Configured Outline" msg_info "Creating Service" cat </etc/systemd/system/outline.service @@ -89,7 +85,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf $temp_file $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"