|
| 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://rxresu.me |
| 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 | + gnupg \ |
| 19 | + unzip \ |
| 20 | + postgresql-common |
| 21 | +msg_ok "Installed Dependencies" |
| 22 | + |
| 23 | +msg_info "Installing Additional Dependencies" |
| 24 | +mkdir -p /etc/apt/keyrings |
| 25 | +curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg |
| 26 | +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 |
| 27 | +echo "YES" | /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh &>/dev/null |
| 28 | +$STD apt-get install -y postgresql-16 nodejs |
| 29 | +cd /tmp |
| 30 | +curl -fsSL https://dl.min.io/server/minio/release/linux-amd64/minio.deb -o minio.deb |
| 31 | +$STD dpkg -i minio.deb |
| 32 | + |
| 33 | +msg_info "Setting up Database" |
| 34 | +DB_USER="rxresume" |
| 35 | +DB_NAME="rxresume" |
| 36 | +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) |
| 37 | +$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH ENCRYPTED PASSWORD '$DB_PASS';" |
| 38 | +$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;" |
| 39 | +$STD sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME to $DB_USER;" |
| 40 | +$STD sudo -u postgres psql -c "ALTER USER $DB_USER WITH SUPERUSER;" |
| 41 | +msg_ok "Set up Database" |
| 42 | + |
| 43 | +msg_info "Installing ${APPLICATION}" |
| 44 | +MINIO_PASS=$(openssl rand -base64 48) |
| 45 | +ACCESS_TOKEN=$(openssl rand -base64 48) |
| 46 | +REFRESH_TOKEN=$(openssl rand -base64 48) |
| 47 | +CHROME_TOKEN=$(openssl rand -hex 32) |
| 48 | +LOCAL_IP=$(hostname -I | awk '{print $1}') |
| 49 | +TAG=$(curl -fsSL https://api.github.com/repos/browserless/browserless/tags?per_page=1 | grep "name" | awk '{print substr($2, 3, length($2)-4) }') |
| 50 | +RELEASE=$(curl -fsSL https://api.github.com/repos/AmruthPillai/Reactive-Resume/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
| 51 | +curl -fsSL "https://github.com/AmruthPillai/Reactive-Resume/archive/refs/tags/v${RELEASE}.zip" -o v${RELEASE}.zip |
| 52 | +unzip -q v${RELEASE}.zip |
| 53 | +mv ${APPLICATION}-${RELEASE}/ /opt/${APPLICATION} |
| 54 | +cd /opt/${APPLICATION} |
| 55 | +corepack enable |
| 56 | +export CI="true" |
| 57 | +export PUPPETEER_SKIP_DOWNLOAD="true" |
| 58 | +export NODE_ENV="production" |
| 59 | +export NEXT_TELEMETRY_DISABLED=1 |
| 60 | +$STD pnpm install --frozen-lockfile |
| 61 | +$STD pnpm run build |
| 62 | +$STD pnpm install --prod --frozen-lockfile |
| 63 | +$STD pnpm run prisma:generate |
| 64 | +msg_ok "Installed ${APPLICATION}" |
| 65 | + |
| 66 | +msg_info "Installing Browserless (Patience)" |
| 67 | +cd /tmp |
| 68 | +curl -fsSL https://github.com/browserless/browserless/archive/refs/tags/v${TAG}.zip -o v${TAG}.zip |
| 69 | +unzip -q v${TAG}.zip |
| 70 | +mv browserless-${TAG} /opt/browserless |
| 71 | +cd /opt/browserless |
| 72 | +$STD npm install |
| 73 | +rm -rf src/routes/{chrome,edge,firefox,webkit} |
| 74 | +$STD node_modules/playwright-core/cli.js install --with-deps chromium |
| 75 | +$STD npm run build |
| 76 | +$STD npm run build:function |
| 77 | +$STD npm prune production |
| 78 | +msg_ok "Installed Browserless" |
| 79 | + |
| 80 | +msg_info "Configuring applications" |
| 81 | +mkdir -p /opt/minio |
| 82 | +cat <<EOF >/opt/minio/.env |
| 83 | +MINIO_ROOT_USER="storageadmin" |
| 84 | +MINIO_ROOT_PASSWORD="${MINIO_PASS}" |
| 85 | +MINIO_VOLUMES=/opt/minio |
| 86 | +MINIO_OPTS="--address :9000 --console-address 127.0.0.1:9001" |
| 87 | +EOF |
| 88 | +cat <<EOF >/opt/${APPLICATION}/.env |
| 89 | +NODE_ENV=production |
| 90 | +PORT=3000 |
| 91 | +PUBLIC_URL=http://${LOCAL_IP}:3000 |
| 92 | +STORAGE_URL=http://${LOCAL_IP}:9000/rxresume |
| 93 | +DATABASE_URL=postgresql://${DB_USER}:${DB_PASS}@localhost:5432/${DB_NAME}?schema=public |
| 94 | +ACCESS_TOKEN_SECRET=${ACCESS_TOKEN} |
| 95 | +REFRESH_TOKEN_SECRET=${REFRESH_TOKEN} |
| 96 | +CHROME_PORT=8080 |
| 97 | +CHROME_TOKEN=${CHROME_TOKEN} |
| 98 | +CHROME_URL=ws://localhost:8080 |
| 99 | +CHROME_IGNORE_HTTPS_ERRORS=true |
| 100 | +MAIL_FROM=noreply@locahost |
| 101 | +# SMTP_URL=smtp://username:[email protected]:587 # |
| 102 | +STORAGE_ENDPOINT=localhost |
| 103 | +STORAGE_PORT=9000 |
| 104 | +STORAGE_REGION=us-east-1 |
| 105 | +STORAGE_BUCKET=rxresume |
| 106 | +STORAGE_ACCESS_KEY=storageadmin |
| 107 | +STORAGE_SECRET_KEY=${MINIO_PASS} |
| 108 | +STORAGE_USE_SSL=false |
| 109 | +STORAGE_SKIP_BUCKET_CHECK=false |
| 110 | +
|
| 111 | +# GitHub (OAuth, Optional) |
| 112 | +# GITHUB_CLIENT_ID= |
| 113 | +# GITHUB_CLIENT_SECRET= |
| 114 | +# GITHUB_CALLBACK_URL=http://localhost:5173/api/auth/github/callback |
| 115 | +
|
| 116 | +# Google (OAuth, Optional) |
| 117 | +# GOOGLE_CLIENT_ID= |
| 118 | +# GOOGLE_CLIENT_SECRET= |
| 119 | +# GOOGLE_CALLBACK_URL=http://localhost:5173/api/auth/google/callback |
| 120 | +EOF |
| 121 | +cat <<EOF >/opt/browserless/.env |
| 122 | +DEBUG=browserless*,-**:verbose |
| 123 | +HOST=localhost |
| 124 | +PORT=8080 |
| 125 | +TOKEN=${CHROME_TOKEN} |
| 126 | +EOF |
| 127 | +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt |
| 128 | +{ |
| 129 | + echo "${APPLICATION} Credentials" |
| 130 | + echo "Database User: $DB_USER" |
| 131 | + echo "Database Password: $DB_PASS" |
| 132 | + echo "Database Name: $DB_NAME" |
| 133 | + echo "Minio Root Password: ${MINIO_PASS}" |
| 134 | +} >>~/${APPLICATION}.creds |
| 135 | +msg_ok "Configured applications" |
| 136 | + |
| 137 | +msg_info "Creating Services" |
| 138 | +mkdir -p /etc/systemd/system/minio.service.d/ |
| 139 | +cat <<EOF >/etc/systemd/system/minio.service.d/override.conf |
| 140 | +[Service] |
| 141 | +User=root |
| 142 | +Group=root |
| 143 | +WorkingDirectory=/usr/local/bin |
| 144 | +EnvironmentFile=/opt/minio/.env |
| 145 | +EOF |
| 146 | + |
| 147 | +cat <<EOF >/etc/systemd/system/${APPLICATION}.service |
| 148 | +[Unit] |
| 149 | +Description=${APPLICATION} Service |
| 150 | +After=network.target postgresql.service minio.service |
| 151 | +Wants=postgresql.service minio.service |
| 152 | +
|
| 153 | +[Service] |
| 154 | +WorkingDirectory=/opt/${APPLICATION} |
| 155 | +EnvironmentFile=/opt/${APPLICATION}/.env |
| 156 | +ExecStart=/usr/bin/pnpm run start |
| 157 | +Restart=always |
| 158 | +
|
| 159 | +[Install] |
| 160 | +WantedBy=multi-user.target |
| 161 | +EOF |
| 162 | + |
| 163 | +cat <<EOF >/etc/systemd/system/browserless.service |
| 164 | +[Unit] |
| 165 | +Description=Browserless service |
| 166 | +After=network.target ${APPLICATION}.service |
| 167 | +
|
| 168 | +[Service] |
| 169 | +WorkingDirectory=/opt/browserless |
| 170 | +EnvironmentFile=/opt/browserless/.env |
| 171 | +ExecStart=/usr/bin/npm run start |
| 172 | +Restart=unless-stopped |
| 173 | +
|
| 174 | +[Install] |
| 175 | +WantedBy=multi-user.target |
| 176 | +EOF |
| 177 | +systemctl daemon-reload |
| 178 | +systemctl enable -q --now minio.service ${APPLICATION}.service browserless.service |
| 179 | +msg_ok "Created Services" |
| 180 | + |
| 181 | +motd_ssh |
| 182 | +customize |
| 183 | + |
| 184 | +msg_info "Cleaning up" |
| 185 | +rm -f /tmp/v${RELEASE}.zip |
| 186 | +rm -f /tmp/v${TAG}.zip |
| 187 | +rm -f /tmp/minio.deb |
| 188 | +$STD apt-get -y autoremove |
| 189 | +$STD apt-get -y autoclean |
| 190 | +msg_ok "Cleaned" |
0 commit comments