aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/bin/instinit
diff options
context:
space:
mode:
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
+
+
+