mainly changes to keep systems up to date
[distro-setup] / keyscript-off
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4
5 set -eE -o pipefail
6 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
7
8 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
9 if [[ $- != *i* ]]; then
10 exec &>/var/log/keyscript-off.log
11 echo "$0: starting. $(date)"
12 fi
13 sed="sed --follow-symlinks"
14
15 if [[ $($sed -rn 's/^ID=(.*)/\1/p' /etc/os-release) == arch ]]; then
16 if grep -q '^\s*FILES=' /etc/mkinitcpio.conf; then
17 $sed -ri 's/^\s*FILES=/#\0/' /etc/mkinitcpio.conf # comment out
18 mkinitcpio -p linux
19 fi
20 else
21 x=/root/keyscript
22 if grep -q "${x}," /etc/crypttab; then
23 $sed -i "s#${x},#decrypt_keyctl,#" /etc/crypttab
24 update-initramfs -u
25 fi
26 fi
27
28 # switch to easy or hard pass which is the same as luks
29 f=/q/root/shadow/traci
30 [[ $HOSTNAME != tpnew ]] || usermod -p "$(cat $f)" iank
31 echo "$0: finished. $(date)"