1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-04-26 23:50:18 +00:00

Add option for multiple accounts and generate JWT secret (#3132)

This commit is contained in:
Slaviša Arežina 2025-03-17 08:28:37 +01:00 committed by GitHub
parent a2ad5f1268
commit 705cad87e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,6 +33,7 @@ $STD apt-get install -y nodejs
msg_ok "Installed Node.js"
msg_info "Installing ByteStash"
JWT_SECRET=$(openssl rand -base64 32 | tr -d '/+=')
temp_file=$(mktemp)
RELEASE=$(curl -s https://api.github.com/repos/jordan-dalby/ByteStash/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q "https://github.com/jordan-dalby/ByteStash/archive/refs/tags/v${RELEASE}.tar.gz" -O $temp_file
@ -45,6 +46,8 @@ $STD npm install
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
msg_ok "Installed ByteStash"
read -p "Do you want to allow registration of multiple accounts? [y/n]: " allowreg
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/bytestash-backend.service
[Unit]
@ -55,10 +58,16 @@ After=network.target
WorkingDirectory=/opt/bytestash/server
ExecStart=/usr/bin/node src/app.js
Restart=always
Environment=JWT_SECRET=$JWT_SECRET
[Install]
WantedBy=multi-user.target
EOF
if [[ "$allowreg" =~ ^[Yy]$ ]]; then
sed -i '8i\Environment=ALLOW_NEW_ACCOUNTS=true' /etc/systemd/system/bytestash-backend.service
fi
cat <<EOF >/etc/systemd/system/bytestash-frontend.service
[Unit]
Description=ByteStash Frontend Service
@ -72,6 +81,7 @@ Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now bytestash-backend
systemctl enable -q --now bytestash-frontend
msg_ok "Created Service"