Welcome to little lamb

Code » anopa » jjk » tree

[jjk] / src / scripts / aa-stage2

#!@BINDIR@/execlineb -P
#
# anopa - Copyright (C) 2015-2017 Olivier Brunel
#
# aa-stage2
# Copyright (C) 2015-2018 Olivier Brunel <jjk@jjacky.com>
#
# This file is part of anopa.
#
# anopa is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# anopa is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# anopa. If not, see http://www.gnu.org/licenses/
#

# Set up a pipe to log messages
piperw 3 4
background
{
  fdclose 4 fdmove 0 3
  redirfd -a 1 /var/log/boot/current
  fdmove -c 2 1
  s6-tai64n
}
fdclose 3
fdmove 3 4

# We want the actual tty on stdin
backtick -n TTY { aa-tty }
importas -u TTY TTY
redirfd -r 0 ${TTY}
# Reopen the console
redirfd -w 1 /dev/console
fdmove -c 2 1
# And start everything
foreground { aa-echo -O3 -B "Stage 2: Initializing system..." }
backtick -n -D onboot LISTDIR { aa-incmdline -rs aa }
importas -u LISTDIR LISTDIR
# We have a tty in stdin, become session leader and set controlling terminal.
# This is so Ctrl+C will trigger a SIGINT to aa-start, so one can manually
# timeout a service.
foreground {
    emptyenv -c s6-setsid aa-ctty -O3 -s aa-start -O3 -l /etc/anopa/listdirs/${LISTDIR}
}
if { aa-test -e /run/services/.anopa/post-start }
importas -u RC ? emptyenv -c /run/services/.anopa/post-start $RC