Private
Public Access
1
0
Files
linux_patch_api/configs/linux-patch-api-openrc
Echo ce27a3c090
Some checks failed
CI/CD Pipeline / Code Format (push) Successful in 12s
CI/CD Pipeline / Build Debian Package (push) Successful in 1m55s
CI/CD Pipeline / Build RPM Package (push) Successful in 3m24s
CI/CD Pipeline / Build Alpine Package (push) Failing after 0s
CI/CD Pipeline / Build Arch Package (push) Successful in 2m15s
Add Alpine/OpenRC compatibility for init system support
- Updated SPEC.md: Changed systemd requirements to distribution-dependent init system
- Updated ARCHITECTURE.md: Added OpenRC hardening options and init script locations
- Updated build-alpine.sh: Replaced systemd-dev with openrc, use /etc/init.d
- Created configs/linux-patch-api-openrc: Full OpenRC init script
- Added Dockerfile.rpm for RPM build container

Init system support:
- systemd: Debian, Ubuntu, RHEL, CentOS, Fedora
- OpenRC: Alpine Linux

Binary remains init-system agnostic - no Rust code changes required.
2026-04-13 20:16:10 +00:00

73 lines
2.0 KiB
Plaintext

#!/sbin/openrc-run
# OpenRC init script for linux-patch-api
# Used on Alpine Linux and other OpenRC-based systems
name="linux_patch_api"
command="/usr/bin/linux-patch-api"
command_args="--config /etc/linux_patch_api/config.yaml"
command_background=true
pidfile="/run/linux-patch-api/linux-patch-api.pid"
output_log="/var/log/linux_patch_api/linux-patch-api.log"
error_log="/var/log/linux_patch_api/linux-patch-api.err"
# Required dependencies
depend() {
use net logger
}
# Create required directories before starting
start_pre() {
checkpath --directory --owner linux-patch-api:linux-patch-api --mode 0755 \
/run/linux-patch-api \
/var/log/linux-patch-api \
/var/lib/linux-patch-api \
/etc/linux_patch_api/certs
# Ensure config files exist
if [ ! -f "/etc/linux_patch_api/config.yaml" ]; then
eerror "Configuration file missing: /etc/linux_patch_api/config.yaml"
eerror "Please create config.yaml before starting the service"
return 1
fi
if [ ! -f "/etc/linux_patch_api/whitelist.yaml" ]; then
eerror "Whitelist file missing: /etc/linux_patch_api/whitelist.yaml"
eerror "Please create whitelist.yaml before starting the service"
return 1
fi
}
# Verify service started successfully
start_post() {
sleep 2
if [ -f "$pidfile" ]; then
einfo "linux-patch-api started successfully (PID: $(cat $pidfile))"
else
ewarn "linux-patch-api may not have started correctly - pidfile not found"
fi
}
# Clean shutdown
stop_pre() {
einfo "Stopping linux-patch-api service..."
}
# Verify service stopped
stop_post() {
if [ -f "$pidfile" ]; then
rm -f "$pidfile"
fi
einfo "linux-patch-api stopped"
}
# Service status
status() {
if [ -f "$pidfile" ] && kill -0 $(cat "$pidfile") 2>/dev/null; then
einfo "linux-patch-api is running (PID: $(cat $pidfile))"
return 0
else
eerror "linux-patch-api is not running"
return 1
fi
}