author | Olivier Brunel
<jjk@jjacky.com> 2018-01-22 21:16:07 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2018-01-23 17:16:51 UTC |
parent | 568a9a7291311c2ac44162c4ad308fee099d18eb |
doc/aa-post-stage0.pod | +19 | -0 |
doc/aa-post-stage2.pod | +25 | -0 |
doc/aa-poststage0.pod | +19 | -0 |
doc/aa-poststage2.pod | +25 | -0 |
package/modes | +2 | -0 |
package/targets.mak | +4 | -0 |
src/scripts/aa-post-stage0 | +30 | -0 |
src/scripts/aa-post-stage2 | +36 | -0 |
src/scripts/aa-poststage0 | +30 | -0 |
src/scripts/aa-poststage2 | +36 | -0 |
diff --git a/doc/aa-post-stage0.pod b/doc/aa-post-stage0.pod new file mode 100644 index 0000000..f39e743 --- /dev/null +++ b/doc/aa-post-stage0.pod @@ -0,0 +1,19 @@ +=head1 NAME + +aa-post-stage0 - Helper for aa-start's return code post stage 0 + +=head1 SYNOPSIS + +B<aa-post-stage0> + +=head1 DESCRIPTION + +B<aa-post-stage0>(1) is an B<execline> script meant to be used as handler for +B<aa-start>(1) return code in stage 0. In other words, it should be set as +I<REPODIR/.anopa/post-stage0> + +It checks B<aa-start>(1) return code (given as argument) for bit 1 or 16, and if +at least one is set executes into an interactive shell (I<sh -i>). + +Bit 1 being set means B<aa-start>(1) failed with a fatal error; Bit 16 means at +least one service marked essential failed. diff --git a/doc/aa-post-stage2.pod b/doc/aa-post-stage2.pod new file mode 100644 index 0000000..aee3f70 --- /dev/null +++ b/doc/aa-post-stage2.pod @@ -0,0 +1,25 @@ +=head1 NAME + +aa-post-stage2 - Helper for aa-start's return code post stage 2 + +=head1 SYNOPSIS + +B<aa-post-stage2> + +=head1 DESCRIPTION + +B<aa-post-stage2>(1) is an B<execline> script meant to be used as handler for +B<aa-start>(1) return code in stage 2. In other words, it should be set as +I<REPODIR/.anopa/post-stage2> + +It checks B<aa-start>(1) return code (given as argument) for bit 1 or 16, and if +at least one is set executes into an interactive shell (I<sh -i>). + +Bit 1 being set means B<aa-start>(1) failed with a fatal error; Bit 16 means at +least one service marked essential failed. + +If neither are set, it echoes "System ready." (even though some (non essential) +services might have failed). + +If the return code was 0, i.e. nothing failed, it switches to tty2 (where one +would expect a getty with login prompt to be available). diff --git a/doc/aa-poststage0.pod b/doc/aa-poststage0.pod new file mode 100644 index 0000000..f39e743 --- /dev/null +++ b/doc/aa-poststage0.pod @@ -0,0 +1,19 @@ +=head1 NAME + +aa-post-stage0 - Helper for aa-start's return code post stage 0 + +=head1 SYNOPSIS + +B<aa-post-stage0> + +=head1 DESCRIPTION + +B<aa-post-stage0>(1) is an B<execline> script meant to be used as handler for +B<aa-start>(1) return code in stage 0. In other words, it should be set as +I<REPODIR/.anopa/post-stage0> + +It checks B<aa-start>(1) return code (given as argument) for bit 1 or 16, and if +at least one is set executes into an interactive shell (I<sh -i>). + +Bit 1 being set means B<aa-start>(1) failed with a fatal error; Bit 16 means at +least one service marked essential failed. diff --git a/doc/aa-poststage2.pod b/doc/aa-poststage2.pod new file mode 100644 index 0000000..aee3f70 --- /dev/null +++ b/doc/aa-poststage2.pod @@ -0,0 +1,25 @@ +=head1 NAME + +aa-post-stage2 - Helper for aa-start's return code post stage 2 + +=head1 SYNOPSIS + +B<aa-post-stage2> + +=head1 DESCRIPTION + +B<aa-post-stage2>(1) is an B<execline> script meant to be used as handler for +B<aa-start>(1) return code in stage 2. In other words, it should be set as +I<REPODIR/.anopa/post-stage2> + +It checks B<aa-start>(1) return code (given as argument) for bit 1 or 16, and if +at least one is set executes into an interactive shell (I<sh -i>). + +Bit 1 being set means B<aa-start>(1) failed with a fatal error; Bit 16 means at +least one service marked essential failed. + +If neither are set, it echoes "System ready." (even though some (non essential) +services might have failed). + +If the return code was 0, i.e. nothing failed, it switches to tty2 (where one +would expect a getty with login prompt to be available). diff --git a/package/modes b/package/modes index 7ce4d7f..0ab7b4a 100644 --- a/package/modes +++ b/package/modes @@ -8,6 +8,8 @@ aa-incmdline 0755 aa-kill 0755 aa-mount 0755 aa-pivot 0755 +aa-post-stage0 0755 +aa-post-stage2 0755 aa-reboot 0755 aa-reset 0755 aa-service 0755 diff --git a/package/targets.mak b/package/targets.mak index c015f88..fa284f3 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -26,6 +26,8 @@ BIN_SCRIPTS_TARGET := \ aa-shutdown LIBEXEC_SCRIPTS_TARGET := \ +aa-post-stage0 \ +aa-post-stage2 \ aa-stage0 \ aa-stage1 \ aa-stage2 \ @@ -45,6 +47,8 @@ aa-incmdline.1 \ aa-kill.1 \ aa-mount.1 \ aa-pivot.1 \ +aa-post-stage0.1 \ +aa-post-stage2.1 \ aa-reboot.1 \ aa-reset.1 \ aa-service.1 \ diff --git a/src/scripts/aa-post-stage0 b/src/scripts/aa-post-stage0 new file mode 100644 index 0000000..bf57a2d --- /dev/null +++ b/src/scripts/aa-post-stage0 @@ -0,0 +1,30 @@ +#!/bin/execlineb -s1 +# +# anopa - Copyright (C) 2015-2017 Olivier Brunel +# +# aa-post-stage0 +# Copyright (C) 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/ +# + +# Executes into the rest of the script if the return code ($1) contains either: +# - bit 1 set, i.e. fatal error +# - bit 16 set, i.e. at least one essential service failed +if { aa-bw $1 17 } +foreground { aa-echo -O3 -Be "Mouting root file system failed" } +foreground { aa-echo -O3 -t "Trying to open a shell; " +g exit +w " to continue" } +emptyenv -c sh -i diff --git a/src/scripts/aa-post-stage2 b/src/scripts/aa-post-stage2 new file mode 100644 index 0000000..e23cacc --- /dev/null +++ b/src/scripts/aa-post-stage2 @@ -0,0 +1,36 @@ +#!@BINDIR@/execlineb -s1 +# +# anopa - Copyright (C) 2015-2017 Olivier Brunel +# +# aa-post-stage2 +# Copyright (C) 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/ +# + +# Open a shell if the return code ($1) contains either: +# - bit 1 set, i.e. fatal error +# - bit 16 set, i.e. at least one essential service failed +ifelse { aa-bw $1 17 } +{ + foreground { aa-echo -O3 -Be "System initialization failed" } + foreground { aa-echo -O3 -t "Trying to open a shell; " +g exit +w " to continue" } + emptyenv -c sh -i +} +# Else we announce success, even if some services might have failed. +foreground { aa-echo -O3 -B "System ready." } +# But in case everything was good, switch to tty2 +if { aa-bw -e $1 0 } chvt 2 diff --git a/src/scripts/aa-poststage0 b/src/scripts/aa-poststage0 new file mode 100644 index 0000000..bf57a2d --- /dev/null +++ b/src/scripts/aa-poststage0 @@ -0,0 +1,30 @@ +#!/bin/execlineb -s1 +# +# anopa - Copyright (C) 2015-2017 Olivier Brunel +# +# aa-post-stage0 +# Copyright (C) 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/ +# + +# Executes into the rest of the script if the return code ($1) contains either: +# - bit 1 set, i.e. fatal error +# - bit 16 set, i.e. at least one essential service failed +if { aa-bw $1 17 } +foreground { aa-echo -O3 -Be "Mouting root file system failed" } +foreground { aa-echo -O3 -t "Trying to open a shell; " +g exit +w " to continue" } +emptyenv -c sh -i diff --git a/src/scripts/aa-poststage2 b/src/scripts/aa-poststage2 new file mode 100644 index 0000000..e23cacc --- /dev/null +++ b/src/scripts/aa-poststage2 @@ -0,0 +1,36 @@ +#!@BINDIR@/execlineb -s1 +# +# anopa - Copyright (C) 2015-2017 Olivier Brunel +# +# aa-post-stage2 +# Copyright (C) 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/ +# + +# Open a shell if the return code ($1) contains either: +# - bit 1 set, i.e. fatal error +# - bit 16 set, i.e. at least one essential service failed +ifelse { aa-bw $1 17 } +{ + foreground { aa-echo -O3 -Be "System initialization failed" } + foreground { aa-echo -O3 -t "Trying to open a shell; " +g exit +w " to continue" } + emptyenv -c sh -i +} +# Else we announce success, even if some services might have failed. +foreground { aa-echo -O3 -B "System ready." } +# But in case everything was good, switch to tty2 +if { aa-bw -e $1 0 } chvt 2