|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: vhsdream |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/dotnetfactory/fluid-calendar |
| 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 | + curl \ |
| 19 | + sudo \ |
| 20 | + mc \ |
| 21 | + zip \ |
| 22 | + gnupg \ |
| 23 | + postgresql-common |
| 24 | +msg_ok "Installed Dependencies" |
| 25 | + |
| 26 | +msg_info "Installing Additional Dependencies" |
| 27 | +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg |
| 28 | +echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" >/etc/apt/sources.list.d/nodesource.list |
| 29 | +echo "YES" | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh &>/dev/null |
| 30 | +$STD apt-get install -y postgresql-17 nodejs |
| 31 | +msg_ok "Installed Additional Dependencies" |
| 32 | + |
| 33 | +msg_info "Setting up Postgresql Database" |
| 34 | +DB_NAME="fluiddb" |
| 35 | +DB_USER="fluiduser" |
| 36 | +DB_PASS="$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)" |
| 37 | +NEXTAUTH_SECRET="$(openssl rand -base64 44 | tr -dc 'a-zA-Z0-9' | cut -c1-32)" |
| 38 | +$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_PASS';" |
| 39 | +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" |
| 40 | +$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME to $DB_USER;" |
| 41 | +$STD sudo -u postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER;" |
| 42 | +{ |
| 43 | + echo "${APPLICATION} Credentials" |
| 44 | + echo "Database User: $DB_USER" |
| 45 | + echo "Database Password: $DB_PASS" |
| 46 | + echo "Database Name: $DB_NAME" |
| 47 | + echo "NextAuth Secret: $NEXTAUTH_SECRET" |
| 48 | +} >> ~/$APPLICATION.creds |
| 49 | +msg_ok "Set up Postgresql Database" |
| 50 | + |
| 51 | +msg_info "Setup ${APPLICATION}" |
| 52 | +tmp_file=$(mktemp) |
| 53 | +RELEASE=$(curl -s https://api.github.com/repos/dotnetfactory/fluid-calendar/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
| 54 | +wget -q "https://github.com/dotnetfactory/fluid-calendar/archive/refs/tags/v${RELEASE}.zip" -O $tmp_file |
| 55 | +unzip -q $tmp_file |
| 56 | +mv ${APPLICATION}-${RELEASE}/ /opt/${APPLICATION} |
| 57 | +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt |
| 58 | + |
| 59 | +cat <<EOF >/opt/fluid-calendar/.env |
| 60 | +DATABASE_URL="postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME}" |
| 61 | +
|
| 62 | +# For OAuth integration with Google Calendar |
| 63 | +# See https://console.cloud.google.com |
| 64 | +GOOGLE_CLIENT_ID="" |
| 65 | +GOOGLE_CLIENT_SECRET="" |
| 66 | +
|
| 67 | +# Change the URL below to your external URL |
| 68 | +NEXTAUTH_URL="http://localhost:3000" |
| 69 | +NEXTAUTH_SECRET="${NEXTAUTH_SECRET}" |
| 70 | +
|
| 71 | +# For optional Outlook Calendar Integration |
| 72 | +# Create at https://portal.azure.com |
| 73 | +AZURE_AD_CLIENT_ID="" |
| 74 | +AZURE_AD_CLIENT_SECRET="" |
| 75 | +AZURE_AD_TENANT_ID="" |
| 76 | +
|
| 77 | +# Logging configuration |
| 78 | +# Options: debug, none (check logger.js for more details) |
| 79 | +LOG_LEVEL="none" |
| 80 | +DEBUG_ENABLED=0 |
| 81 | +EOF |
| 82 | +export NEXT_TELEMETRY_DISABLED=1 |
| 83 | +cd /opt/fluid-calendar |
| 84 | +$STD npm run setup |
| 85 | +$STD npm run build |
| 86 | +msg_ok "Setup ${APPLICATION}" |
| 87 | + |
| 88 | +msg_info "Creating Service" |
| 89 | +cat <<EOF >/etc/systemd/system/fluid-calendar.service |
| 90 | +[Unit] |
| 91 | +Description=Fluid Calendar Application |
| 92 | +After=network.target postgresql.service |
| 93 | +
|
| 94 | +[Service] |
| 95 | +Restart=always |
| 96 | +WorkingDirectory=/opt/fluid-calendar |
| 97 | +ExecStart=/usr/bin/npm run start |
| 98 | +
|
| 99 | +[Install] |
| 100 | +WantedBy=multi-user.target |
| 101 | +EOF |
| 102 | +systemctl enable -q --now fluid-calendar.service |
| 103 | +msg_ok "Created Service" |
| 104 | + |
| 105 | +motd_ssh |
| 106 | +customize |
| 107 | + |
| 108 | +msg_info "Cleaning up" |
| 109 | +rm -f $tmp_file |
| 110 | +$STD apt-get -y autoremove |
| 111 | +$STD apt-get -y autoclean |
| 112 | +msg_ok "Cleaned" |
0 commit comments