fix vpn host naming
[distro-setup] / keyscript-on
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-on.log
11 echo "$0: starting. $(date)"
12 fi
13 rootn=1
14
15 sed="sed --follow-symlinks"
16
17 if [[ ! -e /tmp/keyscript-off ]]; then
18 if [[ $($sed -rn 's/^ID=(.*)/\1/p' /etc/os-release) == arch ]]; then
19 if ! grep -q '^\s*FILES=' /etc/mkinitcpio.conf; then
20 $sed -ri 's/^#(\s*FILES=.*)/\1/' /etc/mkinitcpio.conf # uncomment
21 mkinitcpio -p linux
22 fi
23 else
24 x=decrypt_keyctl
25 # old name. can remove this sometime after aug 2019
26 $sed -i "s#/root/keyscript-manual,#${x},#" /etc/crypttab
27 if grep -q "${x}," /etc/crypttab; then
28 $sed -i "s#${x},#/root/keyscript,#" /etc/crypttab
29 update-initramfs -u
30 fi
31 fi
32 fi
33 # switch to easy or hard login pass which is the same as luks
34 f=/q/root/shadow/traci-simple
35 [[ $HOSTNAME != tpnew ]] || usermod -p "$(cat $f)" iank
36
37 echo "$0: finished. $(date)"