Files
ProxmoxVE/install/pocketid-install.sh
T
MickLesk 3f0dd1b09b install: answer every prompt from the environment, survive a closed stdin
Every interactive prompt takes a var_<app>_<name> override and treats a
closed stdin like Enter (`|| true`), so an install keeps going after the
console that started it is gone. Values the script cannot do without end
with exit 64 and name the variable to set. Validation loops stop asking
when nobody can answer instead of spinning on an empty read.
2026-10-23 20:44:37 +02:00

63 lines
1.5 KiB
Bash

#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: Snarkenfaugister
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/pocket-id/pocket-id
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
public_url="${var_pocketid_url:-}"
[[ -n "$public_url" ]] || read -r -p "${TAB3}What public URL do you want to use (e.g. pocketid.mydomain.com)? " public_url || true
[[ -n "$public_url" ]] || { msg_error "No public URL given; set var_pocketid_url or answer the prompt"; exit 64; }
fetch_and_deploy_gh_release "pocket-id" "pocket-id/pocket-id" "singlefile" "latest" "/opt/pocket-id/" "pocket-id_linux_$(arch_resolve)"
msg_info "Configuring Pocket ID"
ENCRYPTION_KEY=$(openssl rand -base64 32)
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
ENCRYPTION_KEY=${ENCRYPTION_KEY}
EOF
msg_ok "Configured Pocket ID"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/pocketid.service
[Unit]
Description=Pocket ID Service
After=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/pocket-id
EnvironmentFile=/opt/pocket-id/.env
ExecStart=/opt/pocket-id/pocket-id
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
msg_ok "Created Service"
msg_info "Starting Service"
systemctl enable -q --now pocketid
msg_ok "Started Services"
motd_ssh
customize
cleanup_lxc