rc.cgroup2unraid aktualisiert

This commit is contained in:
2024-09-18 12:40:57 +02:00
parent 1b237cb8a8
commit d0142ab64f

View File

@@ -7,28 +7,61 @@
# LimeTech - created for Unraid OS
# /etc/rc.d/rc.cgroup2unraid
DAEMON="unRAID cgroup2 cleanup daemon"
CGROUP2="/usr/local/sbin/cgroup2-unraid"
PID="/var/run/cgroup2-unraid.pid"
# run & log functions
. /etc/rc.d/rc.runlog
cgroup2daemon_running(){
sleep 0.1
[[ $(pgrep -cf $CGROUP2) -gt 0 ]]
}
case "$1" in
start)
echo "Starting unRAID cgroup2 cleanup daemon..."
/usr/local/sbin/cgroup2-unraid --daemon
echo $! > /var/run/cgroup2-unraid.pid
;;
stop)
echo "Stopping unRAID cgroup2 cleanup daemon..."
kill $(cat var/run/cgroup2-unraid.pid)
;;
status)
if kill -0 $(cat /var/run/cgroup2-unraid.pid 2>/dev/null) 2>/dev/null ; then
echo "unRAID cgroup2 cleanup daemon running"
if cgroup2daemon_running ; then
REPLY="Already started"
else
echo "unRAID cgroup2 cleanup daemon not running"
if [ -f /var/run/cgroup2-unraid.pid ]; then
rm -f /var/run/cgroup2-unraid.pid
$CGROUP2 --daemon
echo $(pgrep -f $CGROUP2) > $PID
if cgroup2daemon_running; then
REPLY="Started"
else
REPLY="Failed"
fi
fi
log "$DAEMON... $REPLY."
;;
stop)
if ! cgroup2daemon_running ; then
REPLY="Already stopped"
else
log "Stopping $DAEMON..."
kill $(cat $PID)
if cgroup2daemon_running; then
REPLY="Failed"
else
REPLY="Stopped"
fi
fi
log "$DAEMON... $REPLY."
;;
status)
if cgroup2daemon_running ; then
echo "$DAEMON running"
else
echo "$DAEMON not running"
if [ -f $PID ]; then
rm -f $PID
fi
fi
;;
run)
echo "Cleaning up cgroups..."
/usr/local/sbin/cgroup2-unraid
$CGROUP2
echo "Done!"
;;
restart)
@@ -39,4 +72,4 @@ case "$1" in
echo "Usage: $BASENAME start|stop|status|restart|run"
exit 1
esac
exit 0
exit 0