From bd96decf1d957b043092d0ea606398e2774fabf5 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:54:43 +0100 Subject: [PATCH] 'Add new script' (#3205) Co-authored-by: app-header-generator[bot] <194485257+app-header-generator[bot]@users.noreply.github.com> --- cryptpad-install.sh | 88 +++++++++++++++++++++++++++++++++++++++++++++ cryptpad.json | 38 ++++++++++++++++++++ cryptpad.sh | 74 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 cryptpad-install.sh create mode 100644 cryptpad.json create mode 100644 cryptpad.sh diff --git a/cryptpad-install.sh b/cryptpad-install.sh new file mode 100644 index 000000000..634b4f464 --- /dev/null +++ b/cryptpad-install.sh @@ -0,0 +1,88 @@ +#!/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" + +read -p "Install OnlyOffice components instead of CKEditor? (Y/N): " onlyoffice + +msg_info "Setup ${APPLICATION}" +temp_file=$(mktemp) +RELEASE=$(curl -s https://api.github.com/repos/cryptpad/cryptpad/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +wget -q "https://github.com/cryptpad/cryptpad/archive/refs/tags/${RELEASE}.tar.gz" -O $temp_file +tar zxf $temp_file +mv cryptpad-$RELEASE /opt/cryptpad +cd /opt/cryptpad +$STD npm ci +$STD npm run install:components +$STD npm run build +cp config/config.example.js config/config.js +IP=$(hostname -I | awk '{print $1}') +sed -i "51s/localhost/${IP}/g" /opt/cryptpad/config/config.js +sed -i "80s#//httpAddress: 'localhost'#httpAddress: '0.0.0.0'#g" /opt/cryptpad/config/config.js +if [[ "$onlyoffice" =~ ^[Yy]$ ]]; then + $STD bash -c "./install-onlyoffice.sh --accept-license" +fi +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" +rm -f $temp_file +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/cryptpad.json b/cryptpad.json new file mode 100644 index 000000000..a75a2ba97 --- /dev/null +++ b/cryptpad.json @@ -0,0 +1,38 @@ +{ + "name": "CryptPad", + "slug": "cryptpad", + "categories": [ + 12 + ], + "date_created": "2025-03-11", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 3000, + "documentation": "https://docs.cryptpad.org/", + "website": "https://cryptpad.org/", + "logo": "https://raw.githubusercontent.com/cryptpad/cryptpad/refs/heads/main/customize.dist/CryptPad_logo.svg", + "description": "CryptPad is a collaboration suite that is end-to-end encrypted and open-source. It is designed to facilitate collaboration by synchronizing changes to documents in real time. Since all the user data is encrypted, in the event of a breach, attackers have no way of accessing the stored content", + "install_methods": [ + { + "type": "default", + "script": "ct/cryptpad.sh", + "resources": { + "cpu": 1, + "ram": 1024, + "hdd": 8, + "os": "Debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [ + { + "text": "After installation finishes, `systemctl status cryptpad.service` to get token URL which you can use to create admin account", + "type": "info" + } + } diff --git a/cryptpad.sh b/cryptpad.sh new file mode 100644 index 000000000..cb849a296 --- /dev/null +++ b/cryptpad.sh @@ -0,0 +1,74 @@ +#!/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: 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="8" +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}" + temp_dir=$(mktemp -d) + cp -f /opt/cryptpad/config/config.js /opt/config.js + wget -q "https://github.com/cryptpad/cryptpad/archive/refs/tags/${RELEASE}.tar.gz" -P $temp_dir + cd $temp_dir + tar zxf $RELEASE.tar.gz + cp -rf cryptpad-$RELEASE/* /opt/cryptpad + cd /opt/cryptpad + $STD npm ci + $STD npm run install:components + $STD npm run build + cp -f /opt/config.js /opt/cryptpad/config/config.js + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated $APP to ${RELEASE}" + + msg_info "Cleaning Up" + rm -rf $temp_dir + msg_ok "Cleanup Completed" + + 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}:3000${CL}"