:: [devuan-dev] bug#776: low-memory-mo…
Inizio della pagina
Delete this message
Reply to this message
Autore: Mark Hindley
Data:  
To: Kristopher John Gamrat
CC: 776
Oggetto: [devuan-dev] bug#776: low-memory-monitor missing init script
Control: tags -1 patch

Kristopher,

On Mon, Aug 28, 2023 at 04:29:16PM +0000, Kristopher John Gamrat wrote:
> > Do you have a working initscript?
> >
> > Thanks
> >
> > Mark
>
> Sorry for the delayed response.
>
> I have attached an init script.


Great, thanks. Can you submit that to Debian BTS asking for it to be included?

Mark
#!/bin/sh
#
### BEGIN INIT INFO
# Provides:          low-memory-monitory
# Required-Start:    $remote_fs $local_fs
# Required-Stop:     $remote_fs $local_fs
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Monitors memory usage
# Description:       Monitors memory usage and notifies the kernel
#                    and dbus-enable applications when memory is
#                    running low.
### END INIT INFO


PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/libexec
DAEMON=/usr/libexec/low-memory-monitor
NAME=low-memory-monitor
PIDFILE=/run/low-memory-monitor.pid

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
    start)
        if pidofproc -p $PIDFILE $DAEMON >/dev/null; then
            log_warning_msg "$NAME is already running"
            exit 0
        fi
        log_daemon_msg "Starting $NAME"
        # low-memory-monitor does not fork or create it's own
        # pidfile, so we have to do these manually
        start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON
        log_end_msg $?
        ;;
    stop)
        if pidofproc -p $PIDFILE $DAEMON >/dev/null; then
            log_daemon_msg "Stopping $NAME"
            # low-memory-monitor does not remove it's own
            # pidfile, so we have to do this manually
            start-stop-daemon --stop --quiet --oknodo --remove-pidfile --pidfile $PIDFILE --exec $DAEMON 
            log_end_msg $?
        else
            log_daemon_msg "$NAME is not running"
            log_end_msg 1
        fi
        ;;
    restart|force-restart|reload|force-reload)
        log_daemon_msg "Restarting $NAME"
        if pidofproc -p $PIDFILE $DAEMON>/dev/null; then
            start-stop-daemon --stop --quiet --oknodo --remove-pidfile --pidfile $PIDFILE --exec $DAEMON 
        fi
        start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON 
        log_end_msg $?
        ;;
    status)
        status_of_proc -p $PIDFILE $DAEMON "$NAME" || exit $?
        ;;
    *)
        log_failure_msg "Usage: /etc/init.d/low-memory-monitor {start|stop|restart|force-restart|reload|force-reload|status}"
        exit 1
        ;;
esac