Skip to content

Commit 2b1b517

Browse files
New Script: Pocket ID (#1779)
* Add pocket-id scripts * replace whiptail with read * remove git dependency * Add missing sed * fix indentation * remove assert replace after source update
1 parent 7c297d3 commit 2b1b517

File tree

3 files changed

+268
-0
lines changed

3 files changed

+268
-0
lines changed

ct/pocketid.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Snarkenfaugister
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/stonith404/pocket-id
7+
8+
# App Default Values
9+
APP="PocketID"
10+
TAGS="identity-provider"
11+
var_cpu="2"
12+
var_ram="2048"
13+
var_disk="4"
14+
var_os="debian"
15+
var_version="12"
16+
var_unprivileged="1"
17+
18+
# App Output & Base Settings
19+
header_info "$APP"
20+
base_settings
21+
22+
# Core
23+
variables
24+
color
25+
catch_errors
26+
27+
function update_script() {
28+
header_info
29+
check_container_storage
30+
check_container_resources
31+
32+
if [[ ! -d /opt/pocket-id ]]; then
33+
msg_error "No ${APP} Installation Found!"
34+
exit
35+
fi
36+
37+
RELEASE=$(curl -fsSL https://api.github.com/repos/stonith404/pocket-id/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
38+
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
39+
msg_info "Updating $APP"
40+
41+
msg_info "Stopping $APP"
42+
systemctl stop pocketid-backend.service
43+
systemctl stop pocketid-frontend.service
44+
systemctl stop caddy.service
45+
msg_ok "Stopped $APP"
46+
47+
msg_info "Updating $APP to v${RELEASE}"
48+
cd /opt
49+
cp -r /opt/pocket-id/backend/data /opt/data
50+
cp /opt/pocket-id/backend/.env /opt/backend.env
51+
cp /opt/pocket-id/frontend/.env /opt/frontend.env
52+
rm -r /opt/pocket-id
53+
wget -q "https://github.com/stonith404/pocket-id/archive/refs/tags/v${RELEASE}.zip"
54+
unzip -q v${RELEASE}.zip
55+
mv pocket-id-${RELEASE} /opt/pocket-id
56+
mv /opt/data /opt/pocket-id/backend/data
57+
mv /opt/backend.env /opt/pocket-id/backend/.env
58+
mv /opt/frontend.env /opt/pocket-id/frontend/.env
59+
60+
cd /opt/pocket-id/backend/cmd
61+
go build -o ../pocket-id-backend
62+
cd ../../frontend
63+
npm install
64+
npm run build
65+
msg_ok "Updated $APP to ${RELEASE}"
66+
67+
msg_info "Starting $APP"
68+
systemctl start pocketid-backend.service
69+
systemctl start pocketid-frontend.service
70+
systemctl start caddy.service
71+
sleep 2
72+
msg_ok "Started $APP"
73+
74+
# Cleaning up
75+
msg_info "Cleaning Up"
76+
rm -f /opt/v${RELEASE}.zip
77+
msg_ok "Cleanup Completed"
78+
79+
echo "${RELEASE}" >/opt/${APP}_version.txt
80+
msg_ok "Update Successful"
81+
else
82+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
83+
fi
84+
exit
85+
}
86+
87+
start
88+
build_container
89+
description
90+
91+
msg_ok "Completed Successfully!\n"
92+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
93+
echo -e "${INFO}${YW} Configure your reverse proxy to point to:${BGN} ${IP}:80${CL}"
94+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
95+
echo -e "${TAB}${GATEWAY}${BGN}https://{PUBLIC_URL}/login/setup${CL}"

install/pocketid-install.sh

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Snarkenfaugister
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/stonith404/pocket-id
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-get install -y \
18+
curl \
19+
sudo \
20+
mc \
21+
gpg \
22+
caddy \
23+
gcc
24+
msg_ok "Installed Dependencies"
25+
26+
msg_info "Setting up Node.js Repository"
27+
mkdir -p /etc/apt/keyrings
28+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
29+
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
30+
msg_ok "Set up Node.js Repository"
31+
32+
msg_info "Installing Node.js"
33+
$STD apt-get update
34+
$STD apt-get install -y nodejs
35+
msg_ok "Installed Node.js"
36+
37+
msg_info "Installing Golang"
38+
cd /tmp
39+
set +o pipefail
40+
GO_RELEASE=$(curl -s https://go.dev/dl/ | grep -o -m 1 "go.*\linux-amd64.tar.gz")
41+
wget -q https://golang.org/dl/${GO_RELEASE}
42+
tar -xzf ${GO_RELEASE} -C /usr/local
43+
ln -s /usr/local/go/bin/go /usr/bin/go
44+
set -o pipefail
45+
msg_ok "Installed Golang"
46+
47+
read -r -p "What public URL do you want to use (e.g. pocketid.mydomain.com)? " public_url
48+
msg_info "Setup Pocket ID"
49+
cd /opt
50+
RELEASE=$(curl -s https://api.github.com/repos/stonith404/pocket-id/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
51+
wget -q "https://github.com/stonith404/pocket-id/archive/refs/tags/v${RELEASE}.zip"
52+
unzip -q v${RELEASE}.zip
53+
mv pocket-id-${RELEASE}/ /opt/pocket-id
54+
55+
cd /opt/pocket-id/backend
56+
cp .env.example .env
57+
sed -i "s/PUBLIC_APP_URL=http:\/\/localhost/PUBLIC_APP_URL=https:\/\/${public_url}/" .env
58+
cd cmd
59+
CGO_ENABLED=1
60+
GOOS=linux
61+
$STD go build -o ../pocket-id-backend
62+
63+
cd ../../frontend
64+
cp .env.example .env
65+
sed -i "s/PUBLIC_APP_URL=http:\/\/localhost/PUBLIC_APP_URL=https:\/\/${public_url}/" .env
66+
$STD npm install
67+
$STD npm run build
68+
69+
cd ..
70+
cp reverse-proxy/Caddyfile /etc/caddy/Caddyfile
71+
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
72+
msg_ok "Setup Pocket ID"
73+
74+
msg_info "Creating Service"
75+
cat <<EOF >/etc/systemd/system/pocketid-backend.service
76+
[Unit]
77+
Description=Pocket ID Backend
78+
After=network.target
79+
80+
[Service]
81+
Type=simple
82+
User=root
83+
Group=root
84+
WorkingDirectory=/opt/pocket-id/backend
85+
EnvironmentFile=/opt/pocket-id/backend/.env
86+
ExecStart=/opt/pocket-id/backend/pocket-id-backend
87+
Restart=always
88+
RestartSec=10
89+
90+
[Install]
91+
WantedBy=multi-user.target
92+
EOF
93+
94+
cat <<EOF >/etc/systemd/system/pocketid-frontend.service
95+
[Unit]
96+
Description=Pocket ID Frontend
97+
After=network.target
98+
99+
[Service]
100+
Type=simple
101+
User=root
102+
Group=root
103+
WorkingDirectory=/opt/pocket-id/frontend
104+
EnvironmentFile=/opt/pocket-id/frontend/.env
105+
ExecStart=/usr/bin/node build/index.js
106+
Restart=always
107+
RestartSec=10
108+
109+
[Install]
110+
WantedBy=multi-user.target
111+
EOF
112+
msg_ok "Created Service"
113+
114+
msg_info "Starting Services"
115+
systemctl enable -q --now pocketid-backend
116+
systemctl enable -q --now pocketid-frontend
117+
systemctl restart caddy
118+
msg_ok "Started Services"
119+
120+
motd_ssh
121+
customize
122+
123+
msg_info "Cleaning up"
124+
rm -f /opt/v${RELEASE}.zip
125+
$STD apt-get -y autoremove
126+
$STD apt-get -y autoclean
127+
msg_ok "Cleaned"
128+
129+
motd_ssh
130+
customize

json/pocketid.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "Pocket ID",
3+
"slug": "pocketid",
4+
"categories": [
5+
6
6+
],
7+
"date_created": "2025-01-27",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 80,
12+
"documentation": "https://stonith404.github.io/pocket-id/introduction",
13+
"website": "https://github.com/stonith404/pocket-id",
14+
"logo": "https://github.com/stonith404/pocket-id/blob/main/docs/static/img/pocket-id.png",
15+
"description": "Pocket ID is a simple OIDC provider that allows users to authenticate with their passkeys to your services.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/pocketid.sh",
20+
"resources": {
21+
"cpu": 2,
22+
"ram": 2048,
23+
"hdd": 4,
24+
"os": "Debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": null,
31+
"password": null
32+
},
33+
"notes": [
34+
{
35+
"text": "Pocket ID requires https to work.",
36+
"type": "warning"
37+
},
38+
{
39+
"text": "Configuration Path: `/opt/pocket-id/backend/.env`, `/opt/pocket-id/frontend/.env`.",
40+
"type": "info"
41+
}
42+
]
43+
}

0 commit comments

Comments
 (0)