52 lines
1.1 KiB
Bash
Executable File
52 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# Author: Bandie <bandie@chaospott.de>
|
|
# Copyright: Bandie, 2019, GNU-GPLv3
|
|
|
|
set -e
|
|
|
|
## Get params from /etc/default/grub
|
|
OWNER=$(cat /etc/default/grub | egrep "^OWNER=.*$" | sed "s/.*=\(.*\)/\1/;s/\"//g;s/'//g")
|
|
OWNER_TIMEOUT=$(cat /etc/default/grub | egrep "^OWNER_TIMEOUT=.*$" | sed "s/.*=\(.*\)/\1/;s/\"//g;s/'//g")
|
|
|
|
|
|
## Check if OWNER is set
|
|
if [ -z "$OWNER" ]; then
|
|
echo "/etc/default/grub: No OWNER set." >&2
|
|
exit 0
|
|
fi
|
|
|
|
## Notify user about ownership
|
|
echo "Show ==> $OWNER <== as owner" >&2
|
|
|
|
|
|
## Generate spaces in case if the owner has a very short name
|
|
for ((i=${#OWNER}; i<6; i++)); do
|
|
NSP="$NSP "
|
|
done
|
|
|
|
## Generate border around the owner message
|
|
B="##########"
|
|
for ((i=6; i<${#OWNER}; i++)); do
|
|
B="${B}#"
|
|
SPACE="$SPACE "
|
|
done
|
|
|
|
|
|
## Check if OWNER_TIMEOUT is set. If not, default 5
|
|
if ! [[ $OWNER_TIMEOUT =~ ^[0-9]+$ ]]; then
|
|
OWNER_TIMEOUT=5
|
|
echo "/etc/default/grub: No OWNER_TIMEOUT set. Using default: 5 seconds." >&2
|
|
fi
|
|
|
|
## Write it into the grub.cfg
|
|
cat << EOF
|
|
echo ""
|
|
echo "$B"
|
|
echo "# Owner: ${SPACE}#"
|
|
echo "# $OWNER $NSP#"
|
|
echo "$B"
|
|
echo ""
|
|
echo ""
|
|
sleep -i $OWNER_TIMEOUT
|
|
EOF
|