|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright (c) 2021-2026 community-scripts ORG |
| 4 | +# Author: Slaviša Arežina (tremor021) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/teelur/budget-board |
| 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 install -y nginx |
| 18 | +setup_deb822_repo \ |
| 19 | + "microsoft" \ |
| 20 | + "https://packages.microsoft.com/keys/microsoft-2025.asc" \ |
| 21 | + "https://packages.microsoft.com/debian/13/prod/" \ |
| 22 | + "trixie" |
| 23 | +$STD apt install -y dotnet-sdk-10.0 |
| 24 | +msg_ok "Installed Dependencies" |
| 25 | + |
| 26 | +NODE_VERSION=25 setup_nodejs |
| 27 | +PG_VERSION=16 setup_postgresql |
| 28 | +PG_DB_NAME=budget_board_db PG_DB_USER=budget_board setup_postgresql_db |
| 29 | + |
| 30 | +fetch_and_deploy_gh_release "budget-board" "teelur/budget-board" "tarball" |
| 31 | + |
| 32 | +msg_info "Configuring Budget Board Backend" |
| 33 | +cd /opt/budget-board/server |
| 34 | +$STD dotnet restore "BudgetBoard.WebAPI/BudgetBoard.WebAPI.csproj" |
| 35 | +export configuration=Release |
| 36 | +$STD dotnet publish "BudgetBoard.WebAPI/BudgetBoard.WebAPI.csproj" -c $configuration -o /opt/budget-board/publish /p:UseAppHost=false --no-restore |
| 37 | + |
| 38 | +cat <<EOF >/opt/budget-board/budget-board.env |
| 39 | +Logging__LogLevel__Default=Information |
| 40 | +CLIENT_ADDRESS=$LOCAL_IP |
| 41 | +POSTGRES_HOST=localhost |
| 42 | +POSTGRES_PORT=5432 |
| 43 | +POSTGRES_DATABASE=$PG_DB_NAME |
| 44 | +POSTGRES_USER=$PG_DB_USER |
| 45 | +POSTGRES_PASSWORD=$PG_DB_PASS |
| 46 | +OIDC_ENABLED=false |
| 47 | +OIDC_ISSUER= |
| 48 | +OIDC_CLIENT_ID= |
| 49 | +OIDC_CLIENT_SECRET= |
| 50 | +EMAIL_SENDER= |
| 51 | +EMAIL_SENDER_USERNAME= |
| 52 | +EMAIL_SENDER_PASSWORD= |
| 53 | +EMAIL_SMTP_HOST= |
| 54 | +EMAIL_SMTP_PORT=587 |
| 55 | +DISABLE_NEW_USERS=false |
| 56 | +DISABLE_LOCAL_AUTH=false |
| 57 | +AUTO_UPDATE_DB=true |
| 58 | +DISABLE_AUTO_SYNC=false |
| 59 | +SYNC_INTERVAL_HOURS=8 |
| 60 | +TZ=UTC |
| 61 | +
|
| 62 | +ASPNETCORE_URLS=http://127.0.0.1:6253 |
| 63 | +PORT=6253 |
| 64 | +VITE_SERVER_ADDRESS=${LOCAL_IP} |
| 65 | +VITE_OIDC_ENABLED=false |
| 66 | +VITE_OIDC_PROVIDER= |
| 67 | +VITE_OIDC_CLIENT_ID= |
| 68 | +VITE_DISABLE_NEW_USERS=false |
| 69 | +VITE_DISABLE_LOCAL_AUTH=false |
| 70 | +EOF |
| 71 | +msg_ok "Configured Budget Board Backend" |
| 72 | + |
| 73 | +msg_info "Configuring Budget Board Frontend" |
| 74 | +cd /opt/budget-board/client |
| 75 | +export COREPACK_ENABLE_DOWNLOAD_PROMPT=0 |
| 76 | +$STD yarn config set --home enableTelemetry 0 |
| 77 | +$STD npm install --global corepack@latest |
| 78 | +$STD corepack enable |
| 79 | +$STD yarn install |
| 80 | +$STD yarn run build |
| 81 | +cp -r dist/. /var/www/html/ |
| 82 | +msg_ok "Configured Budget Board Frontend" |
| 83 | + |
| 84 | +msg_info "Creating services" |
| 85 | +cat <<EOF >/etc/systemd/system/budget-board.service |
| 86 | +[Unit] |
| 87 | +Description=Budget Board Service |
| 88 | +After=network.target |
| 89 | +
|
| 90 | +[Service] |
| 91 | +WorkingDirectory=/opt/budget-board/publish |
| 92 | +ExecStart=dotnet BudgetBoard.WebAPI.dll |
| 93 | +Restart=always |
| 94 | +EnvironmentFile=/opt/budget-board/budget-board.env |
| 95 | +
|
| 96 | +[Install] |
| 97 | +WantedBy=multi-user.target |
| 98 | +EOF |
| 99 | +systemctl enable -q --now budget-board |
| 100 | + |
| 101 | +cat <<'EOF' >/etc/nginx/sites-available/budget-board.conf |
| 102 | +server { |
| 103 | + listen 80 default_server; |
| 104 | + server_name _; |
| 105 | + root /var/www/html; |
| 106 | + index index.html; |
| 107 | +
|
| 108 | + location /api/ { |
| 109 | + proxy_pass http://127.0.0.1:6253; |
| 110 | + proxy_http_version 1.1; |
| 111 | + proxy_set_header Host $host; |
| 112 | + proxy_set_header X-Real-IP $remote_addr; |
| 113 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 114 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 115 | + } |
| 116 | +
|
| 117 | + location / { |
| 118 | + try_files $uri $uri/ /index.html; |
| 119 | + } |
| 120 | +} |
| 121 | +EOF |
| 122 | +ln -sf /etc/nginx/sites-available/budget-board.conf /etc/nginx/sites-enabled/budget-board.conf |
| 123 | +rm -f /etc/nginx/sites-enabled/default |
| 124 | +systemctl reload nginx |
| 125 | +msg_ok "Created services" |
| 126 | + |
| 127 | +motd_ssh |
| 128 | +customize |
| 129 | +cleanup_lxc |
0 commit comments