add packaging scripts

This commit is contained in:
2026-02-08 14:33:02 +08:00
parent 9b20887cc2
commit 6eb6ff6425
8 changed files with 152 additions and 0 deletions

42
packaging/ubuntu/postinst Normal file
View File

@@ -0,0 +1,42 @@
#!/bin/sh
set -e
mkdir -p /etc/bitoj /var/log/bitoj /var/lib/bitoj /usr/lib/bitoj/data
ln -sfn /etc/bitoj /usr/lib/bitoj/conf
ln -sfn /var/log/bitoj /usr/lib/bitoj/log
if [ ! -f /etc/bitoj/conf-default.py ]; then
if [ -f /usr/lib/bitoj/conf-demo.py ]; then
cp /usr/lib/bitoj/conf-demo.py /etc/bitoj/conf-default.py
else
touch /etc/bitoj/conf-default.py
fi
fi
if ! getent group oj >/dev/null 2>&1; then
groupadd --system oj
fi
if ! id -u oj >/dev/null 2>&1; then
useradd --system --no-create-home --gid oj --shell /usr/sbin/nologin oj
fi
if ! id -u ojrun01 >/dev/null 2>&1; then
/usr/lib/bitoj/utils/bitoj_adduser 1 10 || true
fi
chown -R oj:oj /var/lib/bitoj || true
chmod 755 /var/lib/bitoj /var/log/bitoj
if command -v systemctl >/dev/null 2>&1; then
systemctl daemon-reload
if command -v systemd-tmpfiles >/dev/null 2>&1; then
systemd-tmpfiles --create /usr/lib/tmpfiles.d/bitoj.conf || true
fi
systemctl enable bitoj.service >/dev/null 2>&1 || true
systemctl restart bitoj.service >/dev/null 2>&1 || true
fi
exit 0