From af04f2e50340e1ede9ae6bf2ae40b6a3d641be58 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sat, 7 Nov 2020 11:01:23 +0000 Subject: [PATCH] Add reload. --- src/mkinit | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/mkinit b/src/mkinit index 4b39890..56be91c 100755 --- a/src/mkinit +++ b/src/mkinit @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/setsid /bin/bash # Copyright (C) 2009 Andy Spencer # See ../COPYING for terms @@ -6,14 +6,15 @@ # GLobals COMMAND=boot TESTING=false +RELOAD=false if [ $$ == 1 ]; then DAEMON=true else DAEMON=false fi -PATH=/lib/mkinit/bin:/bin:/sbin:/usr/bin:/usr/sbin -export PATH +export PLAN9=/opt/plan9 +export PATH=/lib/mkinit/bin:/bin:/sbin:/usr/bin:/usr/sbin # Functions function usage { @@ -23,6 +24,7 @@ function usage { echo ' -h,--help Print usage information' echo ' -t,--test Fake all commands' echo ' -d,--daemon For spawning stdin listener' + echo ' -r,--reload Reload mkinit' echo '' echo 'Command:' echo ' boot Execute boot-up procedures' @@ -37,7 +39,7 @@ function usage { # Handle arguments function doopts { - TMP=`getopt -n "$0" -o htd -l help,test,daemon -- "$@"` + TMP=`getopt -n "$0" -o htdr -l help,test,daemon,reload -- "$@"` [ $? != 0 ] && usage eval set -- "$TMP" @@ -48,6 +50,7 @@ function doopts { -h|--help ) usage ;; -t|--test ) TESTING=true ;; -d|--daemon ) DAEMON=true ;; + -r|--reload ) RELOAD=true ;; esac shift done @@ -62,6 +65,7 @@ function doopts { echo ' TESTING:' $TESTING 1>&2 echo ' DAEMON:' $DAEMON 1>&2 echo ' COMMAND:' $COMMAND 1>&2 + echo ' RELOAD:' $RELAOD 1>&2 fi } @@ -90,6 +94,7 @@ function process { if [ "$*" ]; then runamk "$@"-stop || runamk "$@"-zap + sleep 0.5 runamk "$@"-start fi ;; @@ -119,16 +124,18 @@ function process { doopts "$@" # Run whatever was requested -process "${COMMAND[@]}" +if ! $RELOAD; then + process "${COMMAND[@]}" +fi # Fork console listener while $DAEMON; do + $TESTING || exec 0/dev/tty1 2>&1 while read -ep "mkinit> " line; do process $line history -s $line done $TESTING && exit - exec 0/dev/console 2>&1 - echo "Respawning on /dev/console.." + echo "Respawning on /dev/tty1" sleep 1 done -- 2.43.2