fix(gitea): Improve init.d status feedback and enable by default

- Add is_installed() and is_running() checks to init.d
- Show reason when service not running (disabled/not installed)
- Enable gitea by default in UCI config
- Require installation before starting

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-01-24 10:58:37 +01:00
parent 2941398c07
commit 029733884b
2 changed files with 31 additions and 4 deletions

View File

@ -1,5 +1,5 @@
config gitea 'main'
option enabled '0'
option enabled '1'
option http_port '3000'
option ssh_port '2222'
option http_host '0.0.0.0'

View File

@ -8,6 +8,16 @@ USE_PROCD=1
PROG=/usr/sbin/giteactl
CONFIG=gitea
LXC_NAME="gitea"
LXC_PATH="/srv/lxc"
is_installed() {
[ -f "$LXC_PATH/$LXC_NAME/config" ] && [ -d "$LXC_PATH/$LXC_NAME/rootfs" ]
}
is_running() {
lxc-info -n "$LXC_NAME" -s 2>/dev/null | grep -q "RUNNING"
}
start_service() {
local enabled
@ -15,10 +25,15 @@ start_service() {
config_get enabled main enabled '0'
[ "$enabled" = "1" ] || {
echo "Gitea is disabled. Enable with: uci set gitea.main.enabled=1"
echo "Gitea is disabled. Enable with: uci set gitea.main.enabled=1 && uci commit gitea"
return 0
}
if ! is_installed; then
echo "Gitea not installed. Run: giteactl install"
return 1
fi
procd_open_instance
procd_set_param command "$PROG" service-run
procd_set_param respawn 3600 5 5
@ -40,6 +55,18 @@ reload_service() {
start
}
status() {
"$PROG" status
status_service() {
if is_running; then
echo "running"
return 0
else
echo "not running"
# Show why
local enabled
config_load "$CONFIG"
config_get enabled main enabled '0'
[ "$enabled" = "1" ] || echo " (disabled in config)"
is_installed || echo " (not installed - run: giteactl install)"
return 1
fi
}