|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: Slaviša Arežina (tremor021) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/outline/outline |
| 7 | + |
| 8 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
| 9 | +color |
| 10 | +verb_ip6 |
| 11 | +catch_errors |
| 12 | +setting_up_container |
| 13 | +network_check |
| 14 | +update_os |
| 15 | + |
| 16 | +msg_info "Installing Dependencies" |
| 17 | +$STD apt-get install -y \ |
| 18 | +curl \ |
| 19 | +sudo \ |
| 20 | +mc \ |
| 21 | +gnupg \ |
| 22 | +mkcert \ |
| 23 | +git \ |
| 24 | +redis |
| 25 | +msg_ok "Installed Dependencies" |
| 26 | + |
| 27 | +msg_info "Setting up Node.js Repository" |
| 28 | +mkdir -p /etc/apt/keyrings |
| 29 | +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg |
| 30 | +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list |
| 31 | +msg_ok "Set up Node.js Repository" |
| 32 | + |
| 33 | +msg_info "Setting up PostgreSQL Repository" |
| 34 | +curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg |
| 35 | +echo "deb https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" >/etc/apt/sources.list.d/pgdg.list |
| 36 | +msg_ok "Set up PostgreSQL Repository" |
| 37 | + |
| 38 | +msg_info "Installing Node.js" |
| 39 | +$STD apt-get update |
| 40 | +$STD apt-get install -y nodejs |
| 41 | +$STD npm install -g yarn |
| 42 | +msg_ok "Installed Node.js" |
| 43 | + |
| 44 | +msg_info "Install/Set up PostgreSQL Database" |
| 45 | +$STD apt-get install -y postgresql-16 |
| 46 | +DB_NAME="outline" |
| 47 | +DB_USER="outline" |
| 48 | +DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)" |
| 49 | +SECRET_KEY="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)" |
| 50 | +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" |
| 51 | +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" |
| 52 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" |
| 53 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" |
| 54 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';" |
| 55 | +msg_ok "Set up PostgreSQL" |
| 56 | + |
| 57 | +msg_info "Setup Outline (Patience)" |
| 58 | +temp_file=$(mktemp) |
| 59 | +LOCAL_IP="$(hostname -I | awk '{print $1}')" |
| 60 | +RELEASE=$(curl -s https://api.github.com/repos/outline/outline/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
| 61 | +wget -q "https://github.com/outline/outline/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file |
| 62 | +tar zxf $temp_file |
| 63 | +mv outline-${RELEASE} /opt/outline |
| 64 | +cd /opt/outline |
| 65 | +cp .env.sample .env |
| 66 | +sed -i 's/NODE_ENV=production/NODE_ENV=development/g' /opt/outline/.env |
| 67 | +sed -i "s/generate_a_new_key/${SECRET_KEY}/g" /opt/outline/.env |
| 68 | +sed -i "s/user:pass@postgres/${DB_USER}:${DB_PASS}@localhost/g" /opt/outline/.env |
| 69 | +sed -i 's/redis:6379/localhost:6379/g' /opt/outline/.env |
| 70 | +sed -i "32s#URL=#URL=http://${LOCAL_IP}#g" /opt/outline/.env |
| 71 | +sed -i 's/FORCE_HTTPS=true/FORCE_HTTPS=false/g' /opt/outline/.env |
| 72 | +$STD yarn install --frozen-lockfile |
| 73 | +export NODE_OPTIONS="--max-old-space-size=3584" |
| 74 | +$STD yarn build |
| 75 | +sed -i 's/NODE_ENV=development/NODE_ENV=production/g' /opt/outline/.env |
| 76 | +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" |
| 77 | +msg_ok "Setup Outline" |
| 78 | + |
| 79 | +msg_info "Creating Service" |
| 80 | +cat <<EOF >/etc/systemd/system/outline.service |
| 81 | +[Unit] |
| 82 | +Description=Outline Service |
| 83 | +After=network.target |
| 84 | +
|
| 85 | +[Service] |
| 86 | +Type=simple |
| 87 | +User=root |
| 88 | +WorkingDirectory=/opt/outline |
| 89 | +ExecStart=/usr/bin/node ./build/server/index.js |
| 90 | +Restart=always |
| 91 | +EnvironmentFile=/opt/outline/.env |
| 92 | +
|
| 93 | +[Install] |
| 94 | +WantedBy=multi-user.target |
| 95 | +EOF |
| 96 | +systemctl enable -q --now outline |
| 97 | +msg_ok "Created Service" |
| 98 | + |
| 99 | +motd_ssh |
| 100 | +customize |
| 101 | + |
| 102 | +msg_info "Cleaning up" |
| 103 | +rm -rf $temp_file |
| 104 | +$STD apt-get -y autoremove |
| 105 | +$STD apt-get -y autoclean |
| 106 | +msg_ok "Cleaned" |
0 commit comments