From 5a72b1e523aa7a95fb45bab48179b914c9bf1c61 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 18 Feb 2025 17:51:44 +0100 Subject: [PATCH] New Script: Docmost (#2472) * New Script: Docmost LXC * fix path * add redis --- ct/docmost.sh | 70 +++++++++++++++++++++++++++ install/docmost-install.sh | 97 ++++++++++++++++++++++++++++++++++++++ json/docmost.json | 34 +++++++++++++ 3 files changed, 201 insertions(+) create mode 100644 ct/docmost.sh create mode 100644 install/docmost-install.sh create mode 100644 json/docmost.json diff --git a/ct/docmost.sh b/ct/docmost.sh new file mode 100644 index 000000000..75e1f9363 --- /dev/null +++ b/ct/docmost.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://docmost.com/ + +APP="Docmost" +var_tags="documents" +var_cpu="3" +var_ram="3072" +var_disk="7" +var_os="debian" +var_version="12" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/docmost ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/docmost/docmost/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 ${APP}" + systemctl stop docmost + msg_ok "${APP} Stopped" + + msg_info "Updating ${APP} to v${RELEASE}" + cp /opt/docmost/.env /opt/ + rm -rf /opt/docmost + temp_file=$(mktemp) + wget -q "https://github.com/docmost/docmost/archive/refs/tags/v${RELEASE}.tar.gz" -O "$temp_file" + tar -xzf "$temp_file" + mv docmost-${RELEASE} /opt/docmost + cd /opt/docmost + mv /opt/.env /opt/docmost/.env + pnpm install --force &>/dev/null + pnpm build &>/dev/null + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP}" + + msg_info "Starting ${APP}" + systemctl start docmost + msg_ok "Started ${APP}" + + msg_info "Cleaning Up" + rm -f ${temp_file} + msg_ok "Cleaned" + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi + exit +} + +start +build_container +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}" diff --git a/install/docmost-install.sh b/install/docmost-install.sh new file mode 100644 index 000000000..85e3a01c7 --- /dev/null +++ b/install/docmost-install.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (Canbiz) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/documenso/documenso + +source /dev/stdin <<< "$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + gpg \ + curl \ + sudo \ + redis \ + make \ + mc \ + postgresql +msg_ok "Installed Dependencies" + +msg_info "Setting up Node.js Repository" +mkdir -p /etc/apt/keyrings +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +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 +msg_ok "Set up Node.js Repository" + +msg_info "Installing Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +$STD npm install -g pnpm +msg_ok "Installed Node.js" + +msg_info "Setting up PostgreSQL" +DB_NAME="docmost_db" +DB_USER="docmost_user" +DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)" +$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';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" +{ + echo "Docmost-Credentials" + echo "Database Name: $DB_NAME" + echo "Database User: $DB_USER" + echo "Database Password: $DB_PASS" +} >> ~/docmost.creds +msg_ok "Set up PostgreSQL" + +msg_info "Installing Docmost (Patience)" +temp_file=$(mktemp) +RELEASE=$(curl -s https://api.github.com/repos/docmost/docmost/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +wget -q "https://github.com/docmost/docmost/archive/refs/tags/v${RELEASE}.tar.gz" -O "$temp_file" +tar -xzf "$temp_file" +mv docmost-${RELEASE} /opt/docmost +cd /opt/docmost +mv .env.example .env +sed -i "s|APP_SECRET=.*|APP_SECRET=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)|" /opt/docmost/.env +sed -i "s|DATABASE_URL=.*|DATABASE_URL=postgres://$DB_USER:$DB_PASS@localhost:5432/$DB_NAME|" /opt/docmost/.env +export NODE_OPTIONS="--max-old-space-size=2048" +$STD pnpm install --force +$STD pnpm build +echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt" +msg_ok "Installed Docmost" + +msg_info "Creating Service" +cat </etc/systemd/system/docmost.service +[Unit] +Description=Docmost Service +After=network.target postgresql.service + +[Service] +WorkingDirectory=/opt/docmost +ExecStart=/usr/bin/pnpm start +Restart=always +EnvironmentFile=/opt/docmost/.env + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now docmost +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -f "$temp_file" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/json/docmost.json b/json/docmost.json new file mode 100644 index 000000000..92a4c907a --- /dev/null +++ b/json/docmost.json @@ -0,0 +1,34 @@ +{ + "name": "Docmost", + "slug": "docmost", + "categories": [ + 12 + ], + "date_created": "2025-02-18", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": "https://docmost.com/docs/installation", + "website": "https://docmost.com/", + "logo": "https://raw.githubusercontent.com/docmost/docmost/refs/heads/main/apps/client/public/favicon-32x32.png", + "description": "Open-source collaborative wiki and documentation software Create, collaborate, and share knowledge seamlessly with Docmost. Ideal for managing your wiki, knowledge-base, documentation and a lot more.", + "install_methods": [ + { + "type": "default", + "script": "ct/docmost.sh", + "resources": { + "cpu": 3, + "ram": 3072, + "hdd": 7, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} \ No newline at end of file