Browse Source

It might look nicer with spaces. Also deleted some unnecessary test files.

master
Bandie 2 years ago
parent
commit
c30e227b84
Signed by: Bandie GPG Key ID: 843D7FA93BA46312
  1. 8
      README.md
  2. 6
      build/etc/default/grub
  3. 51
      build/etc/grub.d/000_ownership
  4. 6
      etc/grub.d/000_ownership

8
README.md

@ -4,10 +4,10 @@ Show an owner when grub is booting up.
It is looking like this:
```
##########################
# Owner: #
# Alex Alexsen <a@a.tld> #
##########################
##########################
# Owner: #
# Alex Alexsen <a@a.tld> #
##########################
```

6
build/etc/default/grub

@ -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

51
build/etc/grub.d/000_ownership

@ -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

6
etc/grub.d/000_ownership

@ -25,7 +25,7 @@ for ((i=${#OWNER}; i<6; i++)); do
done
## Generate border around the owner message
B="##########"
B=" ##########"
for ((i=6; i<${#OWNER}; i++)); do
B="${B}#"
SPACE="$SPACE "
@ -42,8 +42,8 @@ fi
cat << EOF
echo ""
echo "$B"
echo "# Owner: ${SPACE}#"
echo "# $OWNER $NSP#"
echo " # Owner: ${SPACE}#"
echo " # $OWNER $NSP#"
echo "$B"
echo ""
echo ""

Loading…
Cancel
Save