在alpine linux内运行1panel, /usr/local/bin/systemctl将 systemctl 转译为 OpenRC, /etc/init.d/1panel-core和/etc/init.d/1panel-agent为init脚本, 感谢@lkj0417, 已完成编译的库https://github.com/zypluckyphoenix/1panel
/usr/local/bin/systemctl
#!/bin/sh
action=${1}
service=$(echo ${2} | sed 's/\.\(service\|socket\)//g')
# Helper function to print usage
print_usage() {
echo "Unsupported systemctl command: ${action}"
echo "Supported commands: start, stop, restart, reload, status, enable, disable, is-enabled, is-active, show, list-units"
exit 1
}
case "${action}" in
start)
rc-service "${service}" start
;;
stop)
rc-service "${service}" stop
;;
restart)
rc-service "${service}" restart
;;
reload)
rc-service "${service}" reload || echo "Service ${service} does not support reload; attempting restart" && rc-service "${service}" restart
;;
daemon-reload)
return 0
;;
status)
if rc-service "${service}" status | grep -q "started"; then
echo "Active: active (running) "
else
echo "Active: inactive (dead) "
exit 1
fi
;;
enable)
rc-update add "${service}"
;;
disable)
rc-update del "${service}"
;;
is-enabled)
if rc-update show | grep -q "^[[:space:]]*${service}"; then
echo "enabled"
else
echo "disabled"
exit 1
fi
;;
is-active)
if rc-service "${service}" status | grep -q "started"; then
echo "active"
else
echo "inactive"
exit 1
fi
;;
show)
echo "OpenRC does not support 'show' directly. Check service files in /etc/init.d or /etc/conf.d."
;;
list-units)
rc-update show
;;
*)
print_usage "${action}"
;;
esac
/etc/init.d/1panel-core
#!/sbin/openrc-run
directory=$(grep BASE_DIR= /usr/local/bin/1pctl 2>/dev/null | awk -F= '{print $2"/1panel"}')
directory=${directory:-/opt/1panel}
command="/usr/bin/1panel-core"
command_background=true
description="1Panel, a modern open source linux panel"
rc_ulimit="-n 50000"
rc_cgroup_cleanup="yes"
required_dirs=${directory}
required_files=${command}
pidfile="/var/run/${RC_SVCNAME}.pid"
depend() {
want net-online
need net
use logger dns
after firewall syslog
}
/etc/init.d/1panel-agent
#!/sbin/openrc-run
directory=$(grep BASE_DIR= /usr/local/bin/1pctl 2>/dev/null | awk -F= '{print $2"/1panel"}')
directory=${directory:-/opt/1panel}
command="/usr/bin/1panel-agent"
command_background=true
description="1Panel, a modern open source linux panel"
rc_ulimit="-n 50000"
rc_cgroup_cleanup="yes"
required_dirs=${directory}
required_files=${command}
pidfile="/var/run/${RC_SVCNAME}.pid"
depend() {
want net-online
need net
use logger dns
after firewall syslog
}
支持 毕竟1panel主打docker 希望早日支持alpine