Skip to content

Commit 0139ead

Browse files
committed
Add a kiwix installer.
Kiwix serves offline Wikipedia, Project Gutenberg, and more from ZIM archives
1 parent 6529949 commit 0139ead

3 files changed

Lines changed: 175 additions & 0 deletions

File tree

ct/kiwix.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func)
3+
# Copyright (c) 2021-2026 community-scripts ORG
4+
# Author: tewalds
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/kiwix/kiwix-tools
7+
8+
APP="Kiwix"
9+
var_tags="${var_tags:-documentation;offline}"
10+
var_cpu="${var_cpu:-1}"
11+
var_ram="${var_ram:-512}"
12+
var_disk="${var_disk:-4}"
13+
var_os="${var_os:-debian}"
14+
var_version="${var_version:-13}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
27+
CURRENT_VER=$(/usr/local/bin/kiwix-serve --version 2>&1 | grep -oP '\d+\.\d+\.\d+' | head -1)
28+
29+
fetch_and_deploy_archive "https://download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-x86_64.tar.gz" /usr/local/bin/
30+
31+
NEW_VER=$(/usr/local/bin/kiwix-serve --version 2>&1 | grep -oP '\d+\.\d+\.\d+' | head -1)
32+
33+
if [[ "$CURRENT_VER" == "$NEW_VER" ]]; then
34+
msg_ok "Already on latest version: $CURRENT_VER"
35+
exit
36+
fi
37+
38+
systemctl restart kiwix-serve
39+
msg_ok "Updated from $CURRENT_VER to $NEW_VER!"
40+
exit
41+
}
42+
43+
start
44+
build_container
45+
46+
msg_info "Validating ZIM directory."
47+
if [[ -z "${ZIM_DIR:-}" ]]; then
48+
msg_error "ZIM_DIR cannot be empty. Please run with ZIM_DIR=/path/to/zims"
49+
exit 1
50+
fi
51+
if [[ ! -d "$ZIM_DIR" ]]; then
52+
msg_error "Directory '$ZIM_DIR' does not exist."
53+
exit 1
54+
fi
55+
if ! ls "${ZIM_DIR}"/*.zim >/dev/null 2>&1; then
56+
msg_error "No .zim files found in '$ZIM_DIR'"
57+
exit 1
58+
fi
59+
msg_ok "Using ZIM directory: ${ZIM_DIR}"
60+
61+
msg_info "Configuring Bind Mount"
62+
63+
if pct set $CTID -features mountidmap=1 2>/dev/null; then
64+
msg_info "Enabled ID-mapped mounts (ownership preserved)"
65+
pct set $CTID -mp0 "$ZIM_DIR,mp=/data,ro=1"
66+
msg_ok "Bind Mount Configured (read-only, ownership preserved)"
67+
else
68+
msg_info "ID-mapped mounts not available, using standard mount"
69+
msg_info "Note: Files will appear as nobody:nogroup inside container"
70+
msg_info "Ensure ZIM files are world-readable: chmod -R a+rX ${ZIM_DIR}"
71+
pct set $CTID -mp0 "$ZIM_DIR,mp=/data"
72+
msg_ok "Bind Mount Configured (read-write mount, read-only service)"
73+
fi
74+
75+
msg_info "Setting Container Options"
76+
pct set $CTID --onboot 1
77+
msg_ok "Container Options Set"
78+
79+
msg_ok "Completed Successfully!\n"
80+
IP=$(pct exec $CTID -- hostname -I | awk '{print $1}')
81+
echo -e "${TAB}${GATEWAY}${BGN}Web Interface:${CL} ${BL}http://${IP}:8080${CL}"
82+
echo -e "${TAB}${INFO}${BGN}ZIM Directory:${CL} ${ZIM_DIR} ${DGN}${CL} ${BGN}/data${CL}"

frontend/public/json/kiwix.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "Kiwix",
3+
"slug": "kiwix",
4+
"categories": [
5+
0
6+
],
7+
"date_created": "2026-02-11",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 8080,
12+
"documentation": "https://wiki.kiwix.org",
13+
"website": "https://www.kiwix.org",
14+
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/kiwix.webp",
15+
"description": "Offline content browser serving Wikipedia, Project Gutenberg, and more from ZIM archives",
16+
"config_path": "",
17+
"install_methods": [
18+
{
19+
"type": "default",
20+
"script": "ct/kiwix.sh",
21+
"resources": {
22+
"cpu": 1,
23+
"ram": 512,
24+
"hdd": 4,
25+
"os": "Debian",
26+
"version": "13"
27+
}
28+
}
29+
],
30+
"default_credentials": {
31+
"username": null,
32+
"password": null
33+
},
34+
"notes": [
35+
{
36+
"text": "Requires a bind-mounted directory with ZIM archives. Download some from https://library.kiwix.org to /your/zims. The installation command is then: `ZIM_DATA=/your/zims bash -c \"$(curl .../ct/kiwix.sh)\"`.",
37+
"type": "info"
38+
},
39+
{
40+
"text": "Ensure ZIM files are world-readable: chmod -R a+rX /your/zims",
41+
"type": "warning"
42+
}
43+
]
44+
}

install/kiwix-install.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2021-2026 community-scripts ORG
3+
# Author: tewalds
4+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
5+
# Source: https://github.com/kiwix/kiwix-tools
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 "Downloading Kiwix-Tools"
16+
fetch_and_deploy_archive "https://download.kiwix.org/release/kiwix-tools/kiwix-tools_linux-x86_64.tar.gz" /usr/local/bin/
17+
msg_ok "Installed Kiwix binaries"
18+
19+
msg_info "Creating Kiwix Service"
20+
cat <<'EOF' >/etc/systemd/system/kiwix-serve.service
21+
[Unit]
22+
Description=Kiwix ZIM Server
23+
After=network.target
24+
25+
[Service]
26+
Type=simple
27+
# Use shell expansion to serve all .zim files in /data
28+
ExecStart=/bin/sh -c 'exec /usr/local/bin/kiwix-serve --port 8080 /data/*.zim'
29+
Restart=always
30+
RestartSec=10
31+
Nice=15
32+
33+
# Security hardening
34+
NoNewPrivileges=true
35+
PrivateTmp=true
36+
ProtectSystem=strict
37+
ProtectHome=true
38+
ReadWritePaths=/data
39+
40+
[Install]
41+
WantedBy=multi-user.target
42+
EOF
43+
44+
systemctl enable -q --now kiwix-serve
45+
msg_ok "Created and Started Kiwix Service"
46+
47+
motd_ssh
48+
customize
49+
cleanup_lxc

0 commit comments

Comments
 (0)