It might look nicer with spaces. Also deleted some unnecessary test files.
This commit is contained in:
		@@ -1,6 +0,0 @@
 | 
			
		||||
 | 
			
		||||
# Name and mail address of owner
 | 
			
		||||
#OWNER="John Doe <john@doe.tld>"
 | 
			
		||||
 | 
			
		||||
# Amounts of seconds for how long the owner information is displayed. It is skippable via ESC. Default: 5
 | 
			
		||||
#OWNER_TIMEOUT=5
 | 
			
		||||
@@ -1,51 +0,0 @@
 | 
			
		||||
#!/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
 | 
			
		||||
		Reference in New Issue
	
	Block a user