forked from community-scripts/ProxmoxVED
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaintainerr-install.sh
More file actions
116 lines (100 loc) · 3.09 KB
/
Copy pathmaintainerr-install.sh
File metadata and controls
116 lines (100 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: tumeden
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
# Source: https://github.com/Maintainerr/Maintainerr
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
build-essential \
python3
msg_ok "Installed Dependencies"
fetch_and_deploy_gh_release "maintainerr" "Maintainerr/Maintainerr" "tarball"
NODE_VERSION="24" setup_nodejs
msg_info "Preparing Build Runtime"
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
$STD corepack enable
if [[ -f /opt/maintainerr/package.json ]]; then
if command -v jq >/dev/null 2>&1; then
yarn_spec=$(jq -r '.packageManager // empty' /opt/maintainerr/package.json 2>/dev/null || true)
if [[ -n "$yarn_spec" && "$yarn_spec" == yarn@* ]]; then
yarn_ver="${yarn_spec#yarn@}"
yarn_ver="${yarn_ver%%+*}"
$STD corepack prepare "yarn@${yarn_ver}" --activate || true
fi
fi
fi
mkdir -p /opt/data/logs /etc/maintainerr
ln -sfnT /opt/maintainerr /opt/app
msg_ok "Prepared Build Runtime"
msg_info "Building Maintainerr (Patience)"
cd /opt/maintainerr
cat <<EOF >/opt/maintainerr/apps/ui/.env
VITE_BASE_PATH=/__PATH_PREFIX__
EOF
export NODE_OPTIONS="--max-old-space-size=4096"
$STD yarn install --immutable --network-timeout 99999999
$STD yarn turbo build
$STD yarn workspaces focus --all --production
mkdir -p /opt/maintainerr/apps/server/dist/ui
cp -a /opt/maintainerr/apps/ui/dist/. /opt/maintainerr/apps/server/dist/ui/
msg_ok "Built Maintainerr"
msg_info "Creating Start Script"
cat <<'EOF' >/opt/maintainerr/start.sh
#!/usr/bin/env bash
set -euo pipefail
BASE_PATH_REPLACE="${BASE_PATH:-}"
UI_DIST_DIR="/opt/maintainerr/apps/server/dist/ui"
if [[ ! -d "$UI_DIST_DIR" ]]; then
echo "Missing UI build directory: $UI_DIST_DIR" >&2
exit 1
fi
if grep -R -q -- '/__PATH_PREFIX__' "$UI_DIST_DIR"; then
ESCAPED_BASE_PATH="${BASE_PATH_REPLACE//\\/\\\\}"
ESCAPED_BASE_PATH="${ESCAPED_BASE_PATH//&/\\&}"
if ! find "$UI_DIST_DIR" -type f -not -path '*/node_modules/*' -print0 | xargs -0 sed -i "s,/__PATH_PREFIX__,$ESCAPED_BASE_PATH,g"; then
echo "Failed to rewrite UI base paths under $UI_DIST_DIR" >&2
exit 1
fi
fi
exec npm run --prefix /opt/maintainerr/apps/server start
EOF
chmod +x /opt/maintainerr/start.sh
msg_ok "Created Start Script"
msg_info "Configuring Maintainerr"
cat <<EOF >/etc/maintainerr/maintainerr.conf
UI_PORT=6246
UI_HOSTNAME=0.0.0.0
VERSION_TAG=stable
DEBUG=false
BASE_PATH=
EOF
msg_ok "Configured Maintainerr"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/maintainerr.service
[Unit]
Description=Maintainerr Service
Wants=network-online.target
After=network-online.target
[Service]
EnvironmentFile=/etc/maintainerr/maintainerr.conf
Environment=NODE_ENV=production
Type=simple
Restart=on-failure
RestartSec=5
WorkingDirectory=/opt/maintainerr
ExecStart=/opt/maintainerr/start.sh
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now maintainerr
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc