systemrescue-zfs/airootfs/etc/systemd/scripts/sysresccd-initialize
Marcos Mello f7dca9e0b7 Fix and simplify keymap configuration
Use localectl to set kbd and x11 keymaps.

Order sysresccd-initialize.service before getty-pre.target (pasive target,
pulled in manually) to ensure console keymap is proper configured when
getty@.service runs.

Fixes #74
2020-02-28 10:30:32 -03:00

54 lines
1.9 KiB
Bash
Executable file

#!/bin/sh
echo "$0 Starting ..."
errcnt=0
# Process options passed on the boot command line
for curopt in $(cat /proc/cmdline)
do
case "${curopt}" in
# Configure keyboard layout if requested in the boot command line
setkmap\=*)
echo "Found option '${curopt}' on the boot command line"
SETKMAP=$(echo "${curopt}" | cut -f2 -d=)
localectl set-keymap ${SETKMAP}
;;
# Set the system root password from a clear password
rootpass\=*)
SSHPASS1=$(echo "${curopt}" | cut -f2 -d=)
echo "Found option 'rootpass=******' on the boot command line"
if echo "root:${SSHPASS1}" | chpasswd --crypt-method SHA512
then
echo "Password successfully changed"
else
echo "Failed to change password"
errcnt=$((errcnt + 1))
fi
;;
# Set the system root password from an encrypted password
# A password can be encrypted using a one-line python3 command such as:
# python3 -c 'import crypt; print(crypt.crypt("MyPassWord123", crypt.mksalt(crypt.METHOD_SHA256)))'
rootcryptpass\=*)
SSHPASS2=$(echo "${curopt}" | cut -f2 -d=)
echo "Found option 'rootcryptpass=******' on the boot command line"
if echo "root:${SSHPASS2}" | chpasswd --encrypted
then
echo "Password successfully changed"
else
echo "Failed to change password"
errcnt=$((errcnt + 1))
fi
;;
# Option to allow user to disable the firewall
nofirewall)
echo "Found option 'nofirewall' on the boot command line"
systemctl disable iptables.service
systemctl disable ip6tables.service
systemctl stop iptables.service
systemctl stop ip6tables.service
;;
esac
done
exit ${errcnt}