#!/bin/sh

#############
# ALINITSYS #
#############

# ALINITSYS is a passthrough to RUNIT OR OPENRC, if RUNIT OR OPENRC exists, if not, then ALINITSYS will wrap it up and init the system.

function init(){
	exec runit && echo ":: Running Runit..." || echo ":: Runit not found..." ;
	exec openrc && echo ":: Running OpenRC..." || echo ":: OpenRC not found..." ;
	echo ":: Running alinitsys"
}
function rescue(){
	echo "[E] Something might've went wrong..."
	echo ":: Dropping into the SH"
	exec sh
}
function daemon(){
	/var/service/*/start
}
function getty(){
	echo ":: Getting TTY"
	exec getty || exec stty
}
function start(){
	init ||
	daemon &&
	getty ||
	rescue
}
start