2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
6 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
8 [[ $EUID == 0 ]] ||
exec sudo
-E "${BASH_SOURCE[0]}" "$@"
9 if [[ $
- != *i
* ]]; then
10 exec &>>/var
/log
/keyscript-on.log
11 echo "$0: starting. $(date)"
15 sed="sed --follow-symlinks"
17 # for running under corn, we need this, else, if we call
18 # /sbin/update-initramfs , it will fail with:
19 # /sbin/update-initramfs: 157: mkinitramfs: not found
22 if [[ $INVOCATION_ID ]]; then
23 if [[ -e /b
/bash_unpublished
/source-state
]]; then
24 source /b
/bash_unpublished
/source-state
26 if [[ $MAIL_HOST && $MAIL_HOST != $HOSTNAME ]]; then
27 echo "$0: exiting early: running under systemd as MAIL_HOST"
32 if [[ ! -e /tmp
/keyscript-off
]]; then
33 if [[ $
($sed -rn 's/^ID=(.*)/\1/p' /etc
/os-release
) == arch
]]; then
34 if ! grep -q '^\s*FILES=' /etc
/mkinitcpio.conf
; then
35 $sed -ri 's/^#(\s*FILES=.*)/\1/' /etc
/mkinitcpio.conf
# uncomment
40 if grep -q "${x}," /etc
/crypttab
; then
41 $sed -i "s#${x},#/root/keyscript,#" /etc
/crypttab
46 # switch to easy or hard login pass which is the same as luks
47 f
=/q
/root
/shadow
/traci-simple
48 [[ $HOSTNAME != tpnew
]] || usermod
-p "$(cat $f)" iank
50 echo "$0: finished. $(date)"