How to make IRIX initscripts?
#1
How to make IRIX initscripts?
Thus far in porting utilities to IRIX my ability to make initscripts for new daemons or port existing ones have been unsuccessful. There's not many good examples that don't include lines and lines of daemon-specific variables or conditionals, so it'd be good to know what IS required of an IRIX initscript, and get a sort of "skeleton" form going so we can easily add new ones.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
04-26-2021, 06:36 PM
#2
RE: How to make IRIX initscripts?
I've been a little busy the past few days, but the deadline was yesterday.  So I'm done that project now and have some free time for this.

Do you have a specific package in mind that needs an initscript?  If so, are binaries available to experiment with?  I could try to whip up a minimalist script for that package which could also serve as a template for your future needs.

SGI:  Indigo, Indigo2, Octane, Origin 300
Sun:  SPARCstation 20 (x4), Ultra 2, Blade 2500, T5240
HP:  9000/380, 425e, C8000
Digital: DECstation 5000/125, PWS 600au
jpstewart
Developer

Trade Count: (1)
Posts: 444
Threads: 6
Joined: May 2018
Location: SW Ontario, CA
Find Reply
05-05-2021, 01:19 AM
#3
RE: How to make IRIX initscripts?
https://forums.irixnet.org/thread-2497.html

yep. Try the Dropbear in the MIPSIV archive here, I think there's something wrong with the MIPS III archive dropbear I posted later but can't quite verify yet.

https://linux.die.net/man/8/dropbear

This is the manpage that I referenced for it.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
05-05-2021, 01:23 AM
#4
RE: How to make IRIX initscripts?
Ok, so here's a xeno_dropbear initscript that's generic enough to be used a template for other daemons.  You can change the xeno_ prefix to irixce_ or anything else that makes sense.  But I do recommend a prefix of some sort, not just to separate your stuff from IRIX-native, but also because killing the daemon with 'killall' could also kill the script itself without a prefix in its name.  (Learned that the hard way!)

Code:
#!/bin/sh
##
## Start or stop the dropbear daemon
##
## Set custom options in /etc/config/xeno_dropbear.options to override
## default configuration
##
## Script heavily based on SGI's fw_sshd initscript

NAME=dropbear
DESCRIPTION="Dropbear SSH Daemon"
DAEMON=/opt/xeno/sbin/$NAME
CONFIG=/etc/config/xeno_$NAME.options

/sbin/chkconfig xeno_$NAME
IS_ON=$?

if `/sbin/chkconfig verbose`; then
    ECHO=echo
else
    ECHO=:
fi

LD_LIBRARYN32_PATH=/opt/xeno/lib32
export LD_LIBRARYN32_PATH

function start_daemon {
    if test "$IS_ON" -eq 0 && test -x "$DAEMON"; then
        $ECHO -n "Starting $DESCRIPTION ... "
        if [ -r "$CONFIG" ]; then
            $DAEMON `cat "$CONFIG"`
        else
            $DAEMON
        fi
        $ECHO "done"
    else
        $ECHO "$NAME disabled by chkconfig"
    fi;
}

function stop_daemon {
    $ECHO -n "Stopping $DESCRIPTION ... "
    /sbin/killall -TERM "$NAME"
    $ECHO "done";
}

case "$1" in
    start)
        start_daemon
        ;;
    restart)
        stop_daemon
        start_daemon
        ;;
    stop)
        stop_daemon
        ;;
    *)
        echo "usage: $0 {start|stop|restart}"
        ;;
esac

You should only need to change the $NAME and $DESCRIPTION variables for most other daemons.

It obeys the chkconfig verbose setting and will output what it is doing or not accordingly.

To properly integrate with IRIX, the xeno_dropbear script needs to be placed in /etc/init.d and suitable Kxx and Sxx symlinks created in rc0.d and rc2.d respectively.  You also need to create /etc/config/xeno_dropbear containing either "on" or "off" (without quotes) depending on whether you want it to default to being enabled or disabled.  Users can then toggle it on/off and check its status with chkconfig as with any other daemon.  You can optionally create /etc/config/xeno_dropbear.options with the command line options needed.  It will be used automatically if present.  (Just like real IRIX initscripts do.)

Possible future enhancements would include using a PID file. (Dropbear creates one by default by not everything does.)  That would allow checking to see if it's already running and giving a graceful exit in that case and allow more fine-tuned use of 'kill $PID' rather than the coarse-grained 'killall' approach in this script.  But that's "left as an exercise for the reader" as the saying goes.  This isn't meant to be the Holy Grail of initscripts.  It's a basic starting point.

If you have questions about what I did or why, feel free to ask.  I'm sure there are more quirks I should have mentioned but I'm not thinking of them now.

SGI:  Indigo, Indigo2, Octane, Origin 300
Sun:  SPARCstation 20 (x4), Ultra 2, Blade 2500, T5240
HP:  9000/380, 425e, C8000
Digital: DECstation 5000/125, PWS 600au
jpstewart
Developer

Trade Count: (1)
Posts: 444
Threads: 6
Joined: May 2018
Location: SW Ontario, CA
Find Reply
05-06-2021, 11:47 PM
#5
RE: How to make IRIX initscripts?
VERY NICE.

Thank you kindly for taking the time. I appreciate this, and I agree with the suggestions. This will make it relatively easy to adapt to other projects as well.

Ideally, for some users, inetd can be used instead. That may be preferable on systems that require more careful usage of memory and the like. But this is a GREAT start.

Thanks JP, for your continued help. You really are invaluable.

I'm the system admin of this site. Private security technician, licensed locksmith, hack of a c developer and vintage computer enthusiast. 

https://contrib.irixnet.org/raion/ -- contributions and pieces that I'm working on currently. 

https://codeberg.org/SolusRaion -- Code repos I control

Technical problems should be sent my way.
Raion
Chief IRIX Officer

Trade Count: (9)
Posts: 4,240
Threads: 533
Joined: Nov 2017
Location: Eastern Virginia
Website Find Reply
05-06-2021, 11:56 PM


Forum Jump:


Users browsing this thread: 1 Guest(s)