|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: MickLesk (Canbiz) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/documenso/documenso |
| 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 | + gpg \ |
| 19 | + curl \ |
| 20 | + sudo \ |
| 21 | + redis \ |
| 22 | + make \ |
| 23 | + mc \ |
| 24 | + postgresql |
| 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_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list |
| 31 | +msg_ok "Set up Node.js Repository" |
| 32 | + |
| 33 | +msg_info "Installing Node.js" |
| 34 | +$STD apt-get update |
| 35 | +$STD apt-get install -y nodejs |
| 36 | +$STD npm install -g pnpm |
| 37 | +msg_ok "Installed Node.js" |
| 38 | + |
| 39 | +msg_info "Setting up PostgreSQL" |
| 40 | +DB_NAME="docmost_db" |
| 41 | +DB_USER="docmost_user" |
| 42 | +DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)" |
| 43 | +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" |
| 44 | +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" |
| 45 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" |
| 46 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" |
| 47 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" |
| 48 | +{ |
| 49 | + echo "Docmost-Credentials" |
| 50 | + echo "Database Name: $DB_NAME" |
| 51 | + echo "Database User: $DB_USER" |
| 52 | + echo "Database Password: $DB_PASS" |
| 53 | +} >> ~/docmost.creds |
| 54 | +msg_ok "Set up PostgreSQL" |
| 55 | + |
| 56 | +msg_info "Installing Docmost (Patience)" |
| 57 | +temp_file=$(mktemp) |
| 58 | +RELEASE=$(curl -s https://api.github.com/repos/docmost/docmost/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
| 59 | +wget -q "https://github.com/docmost/docmost/archive/refs/tags/v${RELEASE}.tar.gz" -O "$temp_file" |
| 60 | +tar -xzf "$temp_file" |
| 61 | +mv docmost-${RELEASE} /opt/docmost |
| 62 | +cd /opt/docmost |
| 63 | +mv .env.example .env |
| 64 | +sed -i "s|APP_SECRET=.*|APP_SECRET=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)|" /opt/docmost/.env |
| 65 | +sed -i "s|DATABASE_URL=.*|DATABASE_URL=postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME|" /opt/docmost/.env |
| 66 | +export NODE_OPTIONS="--max-old-space-size=2048" |
| 67 | +$STD pnpm install --force |
| 68 | +$STD pnpm build |
| 69 | +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" |
| 70 | +msg_ok "Installed Docmost" |
| 71 | + |
| 72 | +msg_info "Creating Service" |
| 73 | +cat <<EOF >/etc/systemd/system/docmost.service |
| 74 | +[Unit] |
| 75 | +Description=Docmost Service |
| 76 | +After=network.target postgresql.service |
| 77 | +
|
| 78 | +[Service] |
| 79 | +WorkingDirectory=/opt/docmost |
| 80 | +ExecStart=/usr/bin/pnpm start |
| 81 | +Restart=always |
| 82 | +EnvironmentFile=/opt/docmost/.env |
| 83 | +
|
| 84 | +[Install] |
| 85 | +WantedBy=multi-user.target |
| 86 | +EOF |
| 87 | +systemctl enable -q --now docmost |
| 88 | +msg_ok "Created Service" |
| 89 | + |
| 90 | +motd_ssh |
| 91 | +customize |
| 92 | + |
| 93 | +msg_info "Cleaning up" |
| 94 | +rm -f "$temp_file" |
| 95 | +$STD apt-get -y autoremove |
| 96 | +$STD apt-get -y autoclean |
| 97 | +msg_ok "Cleaned" |
0 commit comments