Skip to content

Commit

Permalink
add bash greeter script
Browse files Browse the repository at this point in the history
  • Loading branch information
ading2210 committed Sep 2, 2024
1 parent 5b6277c commit d98f399
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rootfs/opt/setup_rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,7 @@ echo "Enter a user password:"
set_password "$username" "$user_passwd"

#clean apt caches
apt-get clean
apt-get clean

#enable bash greeter
echo "/usr/local/bin/shimboot_greeter" >> "/home/$username/.bashrc"
30 changes: 30 additions & 0 deletions rootfs/usr/local/bin/shimboot_greeter
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

#get shimboot version
if [ -f "/bootloader/opt/.shimboot_version" ]; then
shimboot_version="$(cat /bootloader/opt/.shimboot_version)"
if [ -f "/bootloader/opt/.shimboot_version_dev" ]; then
shimboot_version+="-dev-$(cat /bootloader/opt/.shimboot_version_dev)"
fi
fi

#get storage stats
percent_full="$(df -BM / | tail -n1 | awk '{print $5}' | tr -d '%')"
total_size="$(df -BM / | tail -n1 | awk '{print $2}' | tr -d 'M')"

#print the greeter
if [ "$shimboot_version" ]; then
echo "Welcome to the Shimboot Linux shell. (${shimboot_version})"
else
echo "Welcome to the Shimboot Linux shell."
fi
echo "For documentation and to report bugs, please visit the project's Github page:"
echo " - https://github.com/ading2210/shimboot"

#a rootfs under 7GB should mean that it is not yet expanded
if [ "$percent_full" -gt 80 ] && [ "$total_size" -lt 7000 ]; then
echo
echo "Warning: Your storage is nearly full and you have not yet expanded the root filesystem. Run 'sudo expand_rootfs' to fix this."
fi

echo

0 comments on commit d98f399

Please sign in to comment.