commit 8b5838cb396a9df917f99ba0773325d925014e23
Author: Cem Keylan <cem@ckyln.com>
Date: Tue, 24 Mar 2020 13:38:41 +0300
initial commit
Diffstat:
4 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/LICENSE b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 Cem Keylan
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
@@ -0,0 +1,8 @@
+PREFIX = /usr/local
+BINDIR = ${PREFIX}/bin
+
+install:
+ install -Dm755 -t ${DESTDIR}${BINDIR} shinit
+
+uninstall:
+ rm -f ${DESTDIR}${BINDIR}/shinit
diff --git a/README.md b/README.md
@@ -0,0 +1,15 @@
+shinit
+======
+
+Basic init daemon in POSIX sh with only 3 lines of code.
+
+
+Installing
+----------
+
+Before installing, edit the second command to use your boot script. If you
+are using Carbs Linux or KISS, you don't need to change it.
+
+You can then install with `make`.
+
+ make install
diff --git a/shinit b/shinit
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Exit with status 1 if pid is not 1
+[ $$ -eq 1 ] || exit 1
+
+# Run boot script and fork
+/lib/init/rc.boot &
+
+# Sleep for a day. As sleep is not a builtin for every
+# shell, we don't want to keep spawning processes, hence
+# the long sleep time.
+#
+# We also don't want to run 'while :; do :; done' as
+# it would lead to high cpu usage.
+while :; do sleep 86400; done