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:
parent
2941398c07
commit
029733884b
@ -1,5 +1,5 @@
|
|||||||
config gitea 'main'
|
config gitea 'main'
|
||||||
option enabled '0'
|
option enabled '1'
|
||||||
option http_port '3000'
|
option http_port '3000'
|
||||||
option ssh_port '2222'
|
option ssh_port '2222'
|
||||||
option http_host '0.0.0.0'
|
option http_host '0.0.0.0'
|
||||||
|
|||||||
@ -8,6 +8,16 @@ USE_PROCD=1
|
|||||||
|
|
||||||
PROG=/usr/sbin/giteactl
|
PROG=/usr/sbin/giteactl
|
||||||
CONFIG=gitea
|
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() {
|
start_service() {
|
||||||
local enabled
|
local enabled
|
||||||
@ -15,10 +25,15 @@ start_service() {
|
|||||||
config_get enabled main enabled '0'
|
config_get enabled main enabled '0'
|
||||||
|
|
||||||
[ "$enabled" = "1" ] || {
|
[ "$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
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ! is_installed; then
|
||||||
|
echo "Gitea not installed. Run: giteactl install"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
procd_open_instance
|
procd_open_instance
|
||||||
procd_set_param command "$PROG" service-run
|
procd_set_param command "$PROG" service-run
|
||||||
procd_set_param respawn 3600 5 5
|
procd_set_param respawn 3600 5 5
|
||||||
@ -40,6 +55,18 @@ reload_service() {
|
|||||||
start
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
status() {
|
status_service() {
|
||||||
"$PROG" status
|
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
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user