From 442bb5176001137028fb661443450b21d03bf43e Mon Sep 17 00:00:00 2001 From: tremor021 Date: Thu, 13 Mar 2025 12:04:40 +0100 Subject: [PATCH] Add CryptPad script for testing --- ct/cryptpad.sh | 64 ++++++++++++++++++++++++++++++ install/cryptpad-install.sh | 79 +++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 ct/cryptpad.sh create mode 100644 install/cryptpad-install.sh diff --git a/ct/cryptpad.sh b/ct/cryptpad.sh new file mode 100644 index 0000000..659d447 --- /dev/null +++ b/ct/cryptpad.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/cryptpad/cryptpad + +APP="CryptPad" +var_tags="docs;office" +var_cpu="1" +var_ram="1024" +var_disk="6" +var_os="debian" +var_version="12" +var_unprivileged="1" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d "/opt/cryptpad" ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + RELEASE=$(curl -s https://api.github.com/repos/cryptpad/cryptpad/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + msg_info "Stopping $APP" + systemctl stop cryptpad + msg_ok "Stopped $APP" + + msg_info "Updating $APP to ${RELEASE}" + cd /opt/cryptpad + $STD git fetch origin --tags + $STD git checkout $RELEASE + $STD npm ci + $STD npm run install:components + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP to ${RELEASE}" + + msg_info "Starting $APP" + systemctl start cryptpad + msg_ok "Started $APP" + + msg_ok "Update Successful" + 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}:8000${CL}" diff --git a/install/cryptpad-install.sh b/install/cryptpad-install.sh new file mode 100644 index 0000000..0b57872 --- /dev/null +++ b/install/cryptpad-install.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: Slaviša Arežina (tremor021) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/cryptpad/cryptpad + +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 \ + curl \ + sudo \ + mc \ + gnupg \ + git +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 "Setup Node.js" +$STD apt-get update +$STD apt-get install -y nodejs +msg_ok "Setup Node.js" + +msg_info "Setup ${APPLICATION}" +RELEASE=$(curl -s https://api.github.com/repos/cryptpad/cryptpad/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +cd /opt +$STD git clone https://github.com/cryptpad/cryptpad.git cryptpad +cd cryptpad +$STD git checkout $RELEASE +$STD npm ci +$STD npm run install:components +$STD bash -c ./install-onlyoffice.sh +cp config/config.example.js config/config.js +sed -i '80s/localhost/0.0.0.0/g' /opt/cryptpad/config/config.js +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Setup ${APPLICATION}" + +msg_info "Creating Service" +cat </etc/systemd/system/cryptpad.service +[Unit] +Description=CryptPad Service +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/cryptpad +ExecStart=/usr/bin/node server +Environment='PWD="/opt/cryptpad"' +StandardOutput=journal +StandardError=journal+console +LimitNOFILE=1000000 +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now cryptpad +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"