install (2317B)
1 #!/bin/sh 2 3 test -d "$1" || exit 1 4 dst=$1 5 6 test -d "$sm_dst_all" || exit 1 7 test -d "$sm_dst_package" || exit 1 8 cmd=$sm_dst_package/command 9 10 src=$("$cmd/s6-dirname" "$0") 11 test -d "$src/skel" || exit 1 12 13 q() { 14 "$sm_dst_package/command/s6-quote" "$@" 15 } 16 17 q_all=$(q "$sm_dst_all") || exit $? 18 q_package=$(q "$sm_dst_package") || exit $? 19 qc=$q_package/command 20 21 # Generate init 22 "$cmd/s6-linux-init-maker" \ 23 -p "/command:/usr/local/bzr/all/sbin:/usr/local/bzr/all/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ 24 -G "/usr/bin/env TERM=linux /sbin/getty 38400 tty9" \ 25 -t 1 \ 26 -f "$src/skel" \ 27 -c "$dst/init" \ 28 "$dst/init" || exit $? 29 30 # Rewrite dynamically generated scripts 31 "$cmd/s6-cat" >"$dst/init/scripts/rc.init" <<EOF || exit $? 32 #!$sm_dst_package/command/execlineb -S1 33 $qc/export TERM "linux" 34 $qc/foreground { $qc/s6-echo "* Starting s6-rc from "$q_all/s6-rc-db } 35 $qc/if { $qc/s6-rc-init -d -c $q_all/s6-rc-db /run/service } 36 $q_all/init/scripts/runlevel \$1 37 EOF 38 39 "$cmd/s6-cat" >"$dst/init/scripts/runlevel" <<EOF || exit $? 40 #!$sm_dst_package/command/execlineb -S1 41 export TERM "linux" 42 43 # The requested runlevel is in "\$1" but currently ignored. 44 45 # Run the service manager. 46 # Call it twice because the first time may spuriously "timeout" 47 # due to the clock jumping forward. 48 49 $qc/ifelse -X { 50 $qc/s6-rc -v 2 -t 600000 -- change ok-all-but-tty 51 } { 52 # no timeout, start ttys properly 53 $qc/foreground { $qc/s6-echo "* System started normally (bundle ok-all-but-tty)" } 54 $qc/foreground { sleep 0.3 } 55 $qc/foreground { $qc/s6-svc -d /run/service/console-log-tail } 56 $qc/s6-rc -v 2 -t 600000 -- change ok-all 57 } 58 $qc/s6-echo "* System startup failure: retry" 59 # try again without tty and then with 60 $qc/foreground { $qc/s6-rc -v 2 -t 600000 -- change ok-all-but-tty } 61 $qc/foreground { sleep 0.1 } 62 $qc/foreground { $qc/s6-svc -d /run/service/console-log-tail } 63 $qc/s6-rc -v 2 -t 600000 -- change ok-all 64 EOF 65 66 "$cmd/s6-mkdir" "$dst/init/run-image/service/console-log-tail" || exit $? 67 "$cmd/s6-cat" >"$dst/init/run-image/service/console-log-tail/run" <<EOF || exit $? 68 #!$sm_dst_package/command/execlineb -P 69 $qc/redirfd -w 1 /dev/console 70 $qc/fdmove -c 2 1 71 $qc/pipeline -w { s6-tai64nlocal } 72 tail -F -n +1 /run/uncaught-logs/current 73 EOF 74 "$cmd/s6-chmod" 755 "$dst/init/run-image/service/console-log-tail/run" exit $?