aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/bin/instinit
diff options
context:
space:
mode:
authorWilliam Harrington <kb0iic@berzerkula.org>2025-01-14 16:06:02 -0600
committerWilliam Harrington <kb0iic@berzerkula.org>2025-01-14 16:06:02 -0600
commit0cc9b20c15460213e488bf5e70963b941482f628 (patch)
treebb0143245583ec846630f39bfa2258dba640ccd7 /sdk/bin/instinit
parent0e084ade5069756d487b5c948c48b777e37c00c9 (diff)
Add source.
Diffstat (limited to 'sdk/bin/instinit')
-rwxr-xr-xsdk/bin/instinit61
1 files changed, 61 insertions, 0 deletions
diff --git a/sdk/bin/instinit b/sdk/bin/instinit
new file mode 100755
index 0000000..fdd0899
--- /dev/null
+++ b/sdk/bin/instinit
@@ -0,0 +1,61 @@
+#!/bin/sh
+run=/etc/rc.d
+levels=""
+base=$1
+
+if [ ! -d $run ] ; then
+ exit 0
+fi
+
+if [ -d $run/init.d ] ; then
+ levels=$run
+ init='../init.d/'$1'.init'
+ run=$run/init.d
+ target=$1'.init'
+else
+ target='rc.'$1
+ levels='false'
+fi
+
+source=$1'.init'
+shift
+
+if [ ! -f "$run/$target" ] ; then
+ echo 'Adding '$target' to '$run
+ if [ -f /etc/sudo.conf ] ; then
+ sudo root install -o root -m 0700 $source $run/$target
+ else
+ su root -c "install -o root -m 0700 $source $run/$target"
+ fi
+else
+ exit 0
+fi
+
+if [ -z "$BASH" ] ; then
+ exit 0
+fi
+
+if [ -z "$levels" ] ; then
+ exit 0
+fi
+
+initial=$1
+shift
+
+for level in $* ; do
+ runlvl=$levels'/rc'$level'.d'
+ if [ ! -d $runlvl ] ; then
+ continue
+ fi
+ cd $runlvl
+ count=$initial
+ while [ -f *$count* ] ; do
+ count=$[count + 1]
+ done
+ target='S'$count$base
+ echo 'Adding '$target' to '$runlvl
+ ln -s $init $target
+done
+
+
+