mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-07-12 00:47:37 +00:00
BREAKING CHANGE: Fix PocketID for v1.0.0 (#4711)
This commit is contained in:
@ -13,94 +13,37 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
msg_info "Installing Dependencies"
|
||||
$STD apt-get install -y \
|
||||
gpg \
|
||||
caddy \
|
||||
gcc
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Setting up Node.js Repository"
|
||||
mkdir -p /etc/apt/keyrings
|
||||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
||||
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
|
||||
msg_ok "Set up Node.js Repository"
|
||||
|
||||
msg_info "Installing Node.js"
|
||||
$STD apt-get update
|
||||
$STD apt-get install -y nodejs
|
||||
msg_ok "Installed Node.js"
|
||||
|
||||
msg_info "Installing Golang"
|
||||
set +o pipefail
|
||||
temp_file=$(mktemp)
|
||||
golang_tarball=$(curl -fsSL https://go.dev/dl/ | grep -oP 'go[\d\.]+\.linux-amd64\.tar\.gz' | head -n 1)
|
||||
curl -fsSL "https://golang.org/dl/${golang_tarball}" -o "$temp_file"
|
||||
tar -C /usr/local -xzf "$temp_file"
|
||||
ln -sf /usr/local/go/bin/go /usr/local/bin/go
|
||||
rm -f "$temp_file"
|
||||
set -o pipefail
|
||||
msg_ok "Installed Golang"
|
||||
|
||||
read -r -p "${TAB3}What public URL do you want to use (e.g. pocketid.mydomain.com)? " public_url
|
||||
msg_info "Setup Pocket ID"
|
||||
cd /opt
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/pocket-id/pocket-id/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
curl -fsSL "https://github.com/pocket-id/pocket-id/archive/refs/tags/v${RELEASE}.zip" -o $(basename "https://github.com/pocket-id/pocket-id/archive/refs/tags/v${RELEASE}.zip")
|
||||
unzip -q v${RELEASE}.zip
|
||||
mv pocket-id-${RELEASE}/ /opt/pocket-id
|
||||
mkdir -p /opt/pocket-id
|
||||
curl -fsSL "https://github.com/pocket-id/pocket-id/releases/download/v${RELEASE}/pocket-id-linux-amd64" -o /opt/pocket-id/pocket-id
|
||||
chmod u+x /opt/pocket-id/pocket-id
|
||||
|
||||
cd /opt/pocket-id/backend
|
||||
cp .env.example .env
|
||||
sed -i "s/PUBLIC_APP_URL=http:\/\/localhost/PUBLIC_APP_URL=https:\/\/${public_url}/" .env
|
||||
cd cmd
|
||||
CGO_ENABLED=1
|
||||
GOOS=linux
|
||||
$STD go build -o ../pocket-id-backend
|
||||
|
||||
cd ../../frontend
|
||||
cp .env.example .env
|
||||
sed -i "s/PUBLIC_APP_URL=http:\/\/localhost/PUBLIC_APP_URL=https:\/\/${public_url}/" .env
|
||||
$STD npm install
|
||||
$STD npm run build
|
||||
|
||||
cd ..
|
||||
cp reverse-proxy/Caddyfile /etc/caddy/Caddyfile
|
||||
cat <<EOF >/opt/pocket-id/.env
|
||||
APP_ENV=production
|
||||
APP_URL=https://${public_url}
|
||||
TRUST_PROXY=false
|
||||
# MAXMIND_LICENSE_KEY=
|
||||
PORT=1411
|
||||
HOST=0.0.0.0
|
||||
EOF
|
||||
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
||||
msg_ok "Setup Pocket ID"
|
||||
|
||||
msg_info "Creating Service"
|
||||
cat <<EOF >/etc/systemd/system/pocketid-backend.service
|
||||
cat <<EOF >/etc/systemd/system/pocketid.service
|
||||
[Unit]
|
||||
Description=Pocket ID Backend
|
||||
Description=Pocket ID Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/opt/pocket-id/backend
|
||||
EnvironmentFile=/opt/pocket-id/backend/.env
|
||||
ExecStart=/opt/pocket-id/backend/pocket-id-backend
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat <<EOF >/etc/systemd/system/pocketid-frontend.service
|
||||
[Unit]
|
||||
Description=Pocket ID Frontend
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Group=root
|
||||
WorkingDirectory=/opt/pocket-id/frontend
|
||||
EnvironmentFile=/opt/pocket-id/frontend/.env
|
||||
ExecStart=/usr/bin/node build/index.js
|
||||
WorkingDirectory=/opt/pocket-id
|
||||
EnvironmentFile=/opt/pocket-id/.env
|
||||
ExecStart=/opt/pocket-id/pocket-id
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
@ -109,17 +52,14 @@ WantedBy=multi-user.target
|
||||
EOF
|
||||
msg_ok "Created Service"
|
||||
|
||||
msg_info "Starting Services"
|
||||
systemctl enable -q --now pocketid-backend
|
||||
systemctl enable -q --now pocketid-frontend
|
||||
systemctl restart caddy
|
||||
msg_info "Starting Service"
|
||||
systemctl enable -q --now pocketid
|
||||
msg_ok "Started Services"
|
||||
|
||||
motd_ssh
|
||||
customize
|
||||
|
||||
msg_info "Cleaning up"
|
||||
rm -f /opt/v${RELEASE}.zip
|
||||
$STD apt-get -y autoremove
|
||||
$STD apt-get -y autoclean
|
||||
msg_ok "Cleaned"
|
||||
|
Reference in New Issue
Block a user