nsvc(8)

NAME
nsvc - control ninit

SYNOPSIS
nsvc [ -Sservice ] [ -[uodgpchaitkorRDCLHVWZE] ] service [...]
nsvc -Ppid service

DESCRIPTION
nsvc is the management interface to ninit. service is the service directory name relative to /etc/ninit. You can also include /etc/ninit/ in the service name.

Each service directory contains control files. They are described on http://riemann.fmi.uni-sofia.bg/ninit/

It is possible to make nsvc SUID.

    chown root.root /bin/nsvc
    chmod 4711 /bin/nsvc

Then nsvc opens the pipes /etc/ninit/in, /etc/ninit/out and switches to real UID. If UID is nonzero only limited set of operation are allowed.

OPTIONS
If no options are given, nsvc will just print a diagnostic message to stdout, saying if the service is up, down or finished, which PID it has if it is up, and for how long it has been in this state. Only the service name ALL means all services.

-Sservice
    Skip service. Apply this option immediately after nsvc. Don't insert space between S and service. Examples:
    nsvc -Sngetty -Ssshd -Slogger -d ALL
    nsvc -Sngetty -W3 ALL || nsvc -Sngetty -k ALL

-u -uNumber
    Up. If the service is not running, start it. If the service stops, restart it. If Number is nonzero and the service is down start it after Number seconds.

-o -oNumber
    Once. If the service is down, start it. If the service stops, do not restart it. If Number is nonzero and the service is down, start it after Number seconds; if it is up, restart it later.

-d  Down. If the service is running, send it a TERM signal and then a CONT signal. After it stops, do not restart it.

-r  Stop respawn. Set respawn flag to OFF. This does not start/stop the service.

-R  Start respawn. Set respawn flag to ON. This does not start/stop the service.

-p  Pause. Send the service a STOP signal.

-c  Continue. Send the service a CONT signal.

-h  Hangup. Send the service a HUP signal.

-a  Alarm. Send the service an ALRM signal.

-i  Interrupt. Send the service an INT signal.

-t  Terminate. Send the service a TERM signal.

-k  Terminate. Send the service a KILL signal.

-g  Get. Output just the PID.

-Ppid service
    Set pid of service.

-D service
    Print dependencies. This will print all the names of all the services that were started because this services depended on them. Example:
    nsvc -D default

-D  Print ninit memory usage statistics.

-H  Print history. This will print the names of some recently spawned processes. This is useful if you see a process looping (initialization fails and ninit is restarting it all the time).

-L  Print all services loaded in memory.

-V  Print version

-Wnumber
    Wait at most number seconds service(s) to finish. Example:
    nsvc -d qmail
    nsvc -W180 qmail || nsvc -k qmail

-Cnumber -C+number
    Tell ninit that the service is in CRON mode. If number is zero it disables CRON mode. Let now=`date +%s`. If number < now then ninit starts the service immediately, otherwise ninit will start it latter. The flag -C+number (if the number is positive) is equaivalent to the following:
    t=`expr now + number`
    nsvc -C$t ... To stop foo, which is in CRON mode do:
    nsvc -C0 foo
    nsvc -d foo

-Z -Znumber
    Zero (free) a service. This is done with the ninit-reload program. Example:
    nsvc -Z30 foo
    This removes foo (if such a service exists) and prepares ninit to accept 30 new services approximately.

-E -Enumber
    Update ninit environ. This is done by ninit-reload program. Example:
    nsvc -E36 ABC=12 UVW
    This updates the variable ABC and removes UVW. It prepares ninit to accept 36 new services approximately. See the environ with:
    tr '\\000' '\\012' < /proc/1/environ

RETURN CODES
Generally, nsvc returns zero if everything is OK or 1 on error (could not open /etc/ninit/in or /etc/ninit/out or there is no process with the given name). In diagnostic mode, it will exit 0 if the service is up, 2 if it is down or 3 if it is finished.

ENVIRON
nsvc uses the variables NINIT_MEMORY and NINIT_HOME.

SEE ALSO
ninit(8), ninit-scan(8)
ninit-shutdown(8), nkillall(8), svc(8), msvc(8)