|
| 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 | + |
| 7 | +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" |
| 8 | +color |
| 9 | +verb_ip6 |
| 10 | +catch_errors |
| 11 | +setting_up_container |
| 12 | +network_check |
| 13 | +update_os |
| 14 | + |
| 15 | +msg_info "Installing Dependencies" |
| 16 | +$STD apt-get install -y \ |
| 17 | + nginx \ |
| 18 | + rabbitmq-server \ |
| 19 | + ca-certificates \ |
| 20 | + software-properties-common |
| 21 | +msg_ok "Installed Dependencies" |
| 22 | + |
| 23 | +PG_VERSION="16" setup_postgresql |
| 24 | + |
| 25 | +msg_info "Setup Database" |
| 26 | +DB_NAME=onlyoffice |
| 27 | +DB_USER=onlyoffice_user |
| 28 | +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) |
| 29 | +$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';" |
| 30 | +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" |
| 31 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';" |
| 32 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';" |
| 33 | +$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'" |
| 34 | +{ |
| 35 | + echo "ONLYOFFICE-Credentials" |
| 36 | + echo "ONLYOFFICE Database User: $DB_USER" |
| 37 | + echo "ONLYOFFICE Database Password: $DB_PASS" |
| 38 | + echo "ONLYOFFICE Database Name: $DB_NAME" |
| 39 | +} >>~/onlyoffice.creds |
| 40 | +msg_ok "Set up Database" |
| 41 | + |
| 42 | +msg_info "Adding ONLYOFFICE GPG Key" |
| 43 | +GPG_TMP="/tmp/onlyoffice.gpg" |
| 44 | +KEY_URL="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" |
| 45 | +TMP_KEY_CONTENT=$(mktemp) |
| 46 | +if curl -fsSL "$KEY_URL" -o "$TMP_KEY_CONTENT" && grep -q "BEGIN PGP PUBLIC KEY BLOCK" "$TMP_KEY_CONTENT"; then |
| 47 | + gpg --quiet --batch --yes --no-default-keyring --keyring "gnupg-ring:$GPG_TMP" --import "$TMP_KEY_CONTENT" >/dev/null 2>&1 |
| 48 | + chmod 644 "$GPG_TMP" |
| 49 | + chown root:root "$GPG_TMP" |
| 50 | + mv "$GPG_TMP" /usr/share/keyrings/onlyoffice.gpg |
| 51 | + echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] https://download.onlyoffice.com/repo/debian squeeze main" >/etc/apt/sources.list.d/onlyoffice.list |
| 52 | + $STD apt-get update |
| 53 | + msg_ok "GPG Key Added" |
| 54 | +else |
| 55 | + msg_error "Failed to download or verify GPG key from $KEY_URL" |
| 56 | + [[ -f "$TMP_KEY_CONTENT" ]] && rm -f "$TMP_KEY_CONTENT" |
| 57 | + exit 1 |
| 58 | +fi |
| 59 | +rm -f "$TMP_KEY_CONTENT" |
| 60 | + |
| 61 | +msg_info "Preconfiguring ONLYOFFICE Debconf Settings" |
| 62 | +RMQ_USER=onlyoffice_rmq |
| 63 | +RMQ_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) |
| 64 | +JWT_SECRET=$(openssl rand -hex 16) |
| 65 | + |
| 66 | +echo onlyoffice-documentserver onlyoffice/db-host string localhost | debconf-set-selections |
| 67 | +echo onlyoffice-documentserver onlyoffice/db-user string $DB_USER | debconf-set-selections |
| 68 | +echo onlyoffice-documentserver onlyoffice/db-pwd password $DB_PASS | debconf-set-selections |
| 69 | +echo onlyoffice-documentserver onlyoffice/db-name string $DB_NAME | debconf-set-selections |
| 70 | +echo onlyoffice-documentserver onlyoffice/rabbitmq-host string localhost | debconf-set-selections |
| 71 | +echo onlyoffice-documentserver onlyoffice/rabbitmq-user string $RMQ_USER | debconf-set-selections |
| 72 | +echo onlyoffice-documentserver onlyoffice/rabbitmq-pwd password $RMQ_PASS | debconf-set-selections |
| 73 | +echo onlyoffice-documentserver onlyoffice/jwt-enabled boolean true | debconf-set-selections |
| 74 | +echo onlyoffice-documentserver onlyoffice/jwt-secret password $JWT_SECRET | debconf-set-selections |
| 75 | + |
| 76 | +echo "RabbitMQ User: $RMQ_USER" >>~/onlyoffice.creds |
| 77 | +echo "RabbitMQ Password: $RMQ_PASS" >>~/onlyoffice.creds |
| 78 | +echo "JWT Secret: $JWT_SECRET" >>~/onlyoffice.creds |
| 79 | +{ |
| 80 | + echo "" |
| 81 | + echo "ONLYOFFICE RabbitMQ Credentials" |
| 82 | + echo "User: $RMQ_USER" |
| 83 | + echo "Password: $RMQ_PASS" |
| 84 | + echo "Secret: $JWT_SECRET" |
| 85 | +} >>~/onlyoffice.creds |
| 86 | +msg_ok "Debconf Preconfiguration Done" |
| 87 | + |
| 88 | +msg_info "Installing ttf-mscorefonts-installer" |
| 89 | +echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections |
| 90 | +$STD apt-get install -y ttf-mscorefonts-installer |
| 91 | +msg_ok "Installed Microsoft Core Fonts" |
| 92 | + |
| 93 | +msg_info "Installing ONLYOFFICE Docs" |
| 94 | +$STD apt-get install -y onlyoffice-documentserver |
| 95 | +msg_ok "ONLYOFFICE Docs Installed" |
| 96 | + |
| 97 | +motd_ssh |
| 98 | +customize |
| 99 | + |
| 100 | +msg_info "Cleaning up" |
| 101 | +$STD apt-get -y autoremove |
| 102 | +$STD apt-get -y autoclean |
| 103 | +msg_ok "Cleaned" |
0 commit comments