Skip to content

Commit b05858c

Browse files
dave-yaptremor021bvdberg01MickLeskmichelroegl-brunner
authored
New Script: Zitadel (#2141)
* Create zitadel-install.sh * Create zitadel.json * Create zitadel.sh * Update zitadel.sh Edit reference back to upstream build.func * Update zitadel.json Co-authored-by: Slaviša Arežina <[email protected]> * Update zitadel.sh Co-authored-by: Slaviša Arežina <[email protected]> * Update zitadel.sh Co-authored-by: Slaviša Arežina <[email protected]> * Update zitadel.sh Co-authored-by: Slaviša Arežina <[email protected]> * Update zitadel.sh Co-authored-by: Slaviša Arežina <[email protected]> * Update zitadel.sh * Update zitadel-install.sh Co-authored-by: Slaviša Arežina <[email protected]> * Update zitadel-install.sh Co-authored-by: Slaviša Arežina <[email protected]> * Update zitadel.sh Co-authored-by: bvdberg01 <[email protected]> * Update zitadel.json Co-authored-by: bvdberg01 <[email protected]> * Use declared variables in config files * Remove other architectures * Update to fit changes requested Include mc for install; removal of variable ARCH and put into direct links; correct the default resources required * Update zitadel.sh Co-authored-by: bvdberg01 <[email protected]> * Update zitadel-install.sh Co-authored-by: bvdberg01 <[email protected]> * Update zitadel-install.sh Co-authored-by: bvdberg01 <[email protected]> * Made changes to fit suggestions * Update zitadel-install.sh correct version output * Update zitadel-install.sh * Update path for version.txt * Set update part default to our project defaults * Update zitadel.sh, Remove v befor ${RELEASE} * Update zitadel-install.sh --------- Co-authored-by: Slaviša Arežina <[email protected]> Co-authored-by: bvdberg01 <[email protected]> Co-authored-by: CanbiZ <[email protected]> Co-authored-by: Michel Roegl-Brunner <[email protected]>
1 parent a481e89 commit b05858c

File tree

3 files changed

+268
-0
lines changed

3 files changed

+268
-0
lines changed

ct/zitadel.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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: dave-yap (dave-yap)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://zitadel.com/
7+
8+
# App Default Values
9+
APP="Zitadel"
10+
var_tags="identity-provider"
11+
var_cpu="1"
12+
var_ram="1024"
13+
var_disk="8"
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+
if [[ ! -f /etc/systemd/system/zitadel.service ]]; then
32+
msg_error "No ${APP} Installation Found!"
33+
exit
34+
fi
35+
RELEASE=$(curl -si https://github.com/zitadel/zitadel/releases/latest | grep location: | cut -d '/' -f 8 | tr -d '\r')
36+
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt | grep -oP '\d+\.\d+\.\d+')" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
37+
msg_info "Stopping $APP"
38+
systemctl stop zitadel
39+
msg_ok "Stopped $APP"
40+
41+
msg_info "Updating $APP to ${RELEASE}"
42+
cd /tmp
43+
wget -qc https://github.com/zitadel/zitadel/releases/download/$RELEASE/zitadel-linux-amd64.tar.gz -O - | tar -xz
44+
mv zitadel-linux-amd64/zitadel /usr/local/bin
45+
zitadel setup --masterkeyFile /opt/zitadel/.masterkey --config /opt/zitadel/config.yaml --init-projections=true &>/dev/null
46+
echo "${RELEASE}" >/opt/${APP}_version.txt
47+
msg_ok "Updated $APP to ${RELEASE}"
48+
49+
msg_info "Starting $APP"
50+
systemctl start zitadel
51+
msg_ok "Started $APP"
52+
53+
msg_info "Cleaning Up"
54+
rm -rf /tmp/zitadel-linux-amd64
55+
msg_ok "Cleanup Completed"
56+
msg_ok "Update Successful"
57+
else
58+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
59+
fi
60+
exit
61+
}
62+
63+
start
64+
build_container
65+
description
66+
67+
msg_ok "Completed Successfully!\n"
68+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
69+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
70+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080/ui/console${CL}"

install/zitadel-install.sh

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: dave-yap
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
7+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
8+
color
9+
verb_ip6
10+
catch_errors
11+
setting_up_container
12+
network_check
13+
update_os
14+
15+
msg_info "Installing Dependencies (Patience)"
16+
$STD apt-get install -y \
17+
curl \
18+
sudo \
19+
mc \
20+
ca-certificates \
21+
wget
22+
msg_ok "Installed Dependecies"
23+
24+
msg_info "Installing Postgresql"
25+
$STD apt-get install -y postgresql postgresql-common
26+
DB_NAME="zitadel"
27+
DB_USER="zitadel"
28+
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)
29+
DB_ADMIN_USER="root"
30+
DB_ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)
31+
systemctl start postgresql
32+
$STD sudo -u postgres psql -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';"
33+
$STD sudo -u postgres psql -c "CREATE USER $DB_ADMIN_USER WITH PASSWORD '$DB_ADMIN_PASS' SUPERUSER;"
34+
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME OWNER $DB_ADMIN_USER;"
35+
{
36+
echo "Application Credentials"
37+
echo "DB_NAME: $DB_NAME"
38+
echo "DB_USER: $DB_USER"
39+
echo "DB_PASS: $DB_PASS"
40+
echo "DB_ADMIN_USER: $DB_ADMIN_USER"
41+
echo "DB_ADMIN_PASS: $DB_ADMIN_PASS"
42+
} >> ~/zitadel.creds
43+
msg_ok "Installed PostgreSQL"
44+
45+
msg_info "Installing Zitadel"
46+
RELEASE=$(curl -si https://github.com/zitadel/zitadel/releases/latest | grep location: | cut -d '/' -f 8 | tr -d '\r')
47+
wget -qc https://github.com/zitadel/zitadel/releases/download/$RELEASE/zitadel-linux-amd64.tar.gz -O - | tar -xz
48+
mv zitadel-linux-amd64/zitadel /usr/local/bin
49+
echo "${RELEASE}" >"/opt/zitadel_version.txt"
50+
msg_ok "Installed Zitadel"
51+
52+
msg_info "Setting up Zitadel Environments"
53+
mkdir -p /opt/zitadel
54+
echo "/opt/zitadel/config.yaml" > "/opt/zitadel/.config"
55+
head -c 32 < <(openssl rand -base64 48 | tr -dc 'a-zA-Z0-9') > "/opt/zitadel/.masterkey"
56+
{
57+
echo "Config location: $(cat "/opt/zitadel/.config")"
58+
echo "Masterkey: $(cat "/opt/zitadel/.masterkey")"
59+
} >> ~/zitadel.creds
60+
cat <<EOF >/opt/zitadel/config.yaml
61+
Port: 8080
62+
ExternalPort: 8080
63+
ExternalDomain: localhost
64+
ExternalSecure: false
65+
TLS:
66+
Enabled: false
67+
KeyPath: ""
68+
Key: ""
69+
CertPath: ""
70+
Cert: ""
71+
72+
Database:
73+
postgres:
74+
Host: localhost
75+
Port: 5432
76+
Database: ${DB_NAME}
77+
User:
78+
Username: ${DB_USER}
79+
Password: ${DB_PASS}
80+
SSL:
81+
Mode: disable
82+
RootCert: ""
83+
Cert: ""
84+
Key: ""
85+
Admin:
86+
Username: ${DB_ADMIN_USER}
87+
Password: ${DB_ADMIN_PASS}
88+
SSL:
89+
Mode: disable
90+
RootCert: ""
91+
Cert: ""
92+
Key: ""
93+
EOF
94+
msg_ok "Installed Zitadel Enviroments"
95+
96+
msg_info "Creating Services"
97+
cat <<EOF >/etc/systemd/system/zitadel.service
98+
[Unit]
99+
Description=ZITADEL Identiy Server
100+
After=network.target postgresql.service
101+
Wants=postgresql.service
102+
103+
[Service]
104+
Type=simple
105+
User=zitadel
106+
Group=zitadel
107+
ExecStart=/usr/local/bin/zitadel start --masterkeyFile "/opt/zitadel/.masterkey" --config "/opt/zitadel/config.yaml"
108+
Restart=always
109+
RestartSec=5
110+
TimeoutStartSec=0
111+
112+
# Security Hardening options
113+
ProtectSystem=full
114+
ProtectHome=true
115+
PrivateTmp=true
116+
NoNewPrivileges=true
117+
118+
[Install]
119+
WantedBy=multi-user.target
120+
EOF
121+
systemctl enable -q zitadel.service
122+
msg_ok "Created Services"
123+
124+
msg_info "Zitadel initial setup"
125+
zitadel start-from-init --masterkeyFile /opt/zitadel/.masterkey --config /opt/zitadel/config.yaml &>/dev/null &
126+
sleep 60
127+
kill $(lsof -i | awk '/zitadel/ {print $2}' | head -n1)
128+
useradd zitadel
129+
echo -e "$(zitadel -v | grep -oP 'v\d+\.\d+\.\d+')" > /opt/Zitadel_version.txt
130+
msg_ok "Zitadel initialized"
131+
132+
msg_info "Set ExternalDomain to current IP and restart Zitadel"
133+
IP=$(ip a s dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1)
134+
sed -i "0,/localhost/s/localhost/${IP}/" /opt/zitadel/config.yaml
135+
systemctl stop -q zitadel.service
136+
zitadel setup --masterkeyFile /opt/zitadel/.masterkey --config /opt/zitadel/config.yaml &>/dev/null
137+
systemctl restart -q zitadel.service
138+
msg_ok "Zitadel restarted with ExternalDomain set to current IP"
139+
140+
msg_info "Create zitadel-rerun.sh"
141+
cat <<EOF >~/zitadel-rerun.sh
142+
systemctl stop zitadel.service
143+
timeout --kill-after=5s 15s zitadel setup --masterkeyFile /opt/zitadel/.masterkey --config /opt/zitadel/config.yaml
144+
systemctl restart zitadel.service
145+
EOF
146+
msg_ok "Bash script for rerunning Zitadel after changing Zitadel config.yaml"
147+
148+
motd_ssh
149+
customize
150+
151+
msg_info "Cleaning up"
152+
rm -rf ~/zitadel-linux-amd64
153+
$STD apt-get -y autoremove
154+
$STD apt-get -y autoclean
155+
msg_ok "Cleaned"

json/zitadel.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "Zitadel",
3+
"slug": "Zitadel",
4+
"categories": [
5+
6
6+
],
7+
"date_created": "2025-02-07",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 8080,
12+
"documentation": "https://zitadel.com/docs/guides/overview",
13+
"website": "https://zitadel.com",
14+
"logo": "https://zitadel.com/zitadel-logo-dark.svg",
15+
"description": "Zitadel is an open-source identity and access management (IAM) solution designed to provide secure authentication, authorization, and user management for modern applications and services. Built with a focus on flexibility, scalability, and security, Zitadel offers a comprehensive set of features for developers and organizations looking to implement robust identity management.",
16+
"install_methods": [
17+
{
18+
"type": "default",
19+
"script": "ct/zitadel.sh",
20+
"resources": {
21+
"cpu": 1,
22+
"ram": 1024,
23+
"hdd": 8,
24+
"os": "debian",
25+
"version": "12"
26+
}
27+
}
28+
],
29+
"default_credentials": {
30+
"username": "[email protected]",
31+
"password": "Password1!"
32+
},
33+
"notes": [
34+
{
35+
"text": "Application credentials: `cat ~/zitadel.creds`",
36+
"type": "info"
37+
},
38+
{
39+
"text": "Change the ExternalDomain value in `/opt/zitadel/config.yaml` to your domain/hostname/IP and run `bash zitadel-rerun.sh`",
40+
"type": "info"
41+
}
42+
]
43+
}

0 commit comments

Comments
 (0)