From cabcdc272eaa7b8c151aa3980beacb7be6b5ed36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Tue, 15 Apr 2025 13:03:51 +0200 Subject: [PATCH] Installation and update fixes (#3895) --- ct/outline.sh | 81 ++++++++++++++++++++------------------ install/outline-install.sh | 14 ++++--- 2 files changed, 50 insertions(+), 45 deletions(-) diff --git a/ct/outline.sh b/ct/outline.sh index 68c06a215..9fc38bc7d 100644 --- a/ct/outline.sh +++ b/ct/outline.sh @@ -20,45 +20,48 @@ color catch_errors function update_script() { - header_info - check_container_storage - check_container_resources - if [[ ! -d /opt/outline ]]; then - 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 - msg_info "Stopping Services" - systemctl stop outline - msg_ok "Services Stopped" - - msg_info "Updating ${APP} to ${RELEASE}" - temp_file=$(mktemp) - rm -rf /opt/outline/node_modules -curl -fsSL "https://github.com/outline/outline/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" - tar zxf $temp_file - cp -rf outline-${RELEASE}/* /opt/outline - cd /opt/outline - export NODE_OPTIONS="--max-old-space-size=3584" - $STD yarn install --frozen-lockfile - $STD yarn build - 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}" - fi + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/outline ]]; then + 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 + msg_info "Stopping Services" + systemctl stop outline + msg_ok "Services Stopped" + + msg_info "Updating ${APP} to ${RELEASE}" + temp_file=$(mktemp) + 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 + cd /opt/outline || exit + 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}" + fi + exit } start @@ -68,4 +71,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" diff --git a/install/outline-install.sh b/install/outline-install.sh index 236b7b14e..541b2e1d1 100644 --- a/install/outline-install.sh +++ b/install/outline-install.sh @@ -15,10 +15,10 @@ update_os msg_info "Installing Dependencies" $STD apt-get install -y \ - gnupg \ - mkcert \ - git \ - redis + gnupg \ + mkcert \ + git \ + redis msg_ok "Installed Dependencies" msg_info "Setting up Node.js Repository" @@ -43,7 +43,6 @@ $STD apt-get install -y postgresql-16 DB_NAME="outline" DB_USER="outline" DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)" -SECRET_KEY="$(openssl rand -hex 32)" $STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" $STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" @@ -52,6 +51,7 @@ $STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';" msg_ok "Set up PostgreSQL" msg_info "Setup 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) }') @@ -60,6 +60,7 @@ tar zxf $temp_file mv outline-${RELEASE} /opt/outline cd /opt/outline cp .env.sample .env +export NODE_ENV=development sed -i 's/NODE_ENV=production/NODE_ENV=development/g' /opt/outline/.env sed -i "s/generate_a_new_key/${SECRET_KEY}/g" /opt/outline/.env sed -i "s/user:pass@postgres/${DB_USER}:${DB_PASS}@localhost/g" /opt/outline/.env @@ -70,6 +71,7 @@ $STD yarn install --frozen-lockfile 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" @@ -83,7 +85,7 @@ After=network.target Type=simple User=root WorkingDirectory=/opt/outline -ExecStart=/usr/bin/node ./build/server/index.js +ExecStart=/usr/bin/yarn start Restart=always EnvironmentFile=/opt/outline/.env