From 184421dc4b605b984f89e75bb000b17e6d82b0d6 Mon Sep 17 00:00:00 2001 From: Steve Magnuson Date: Mon, 9 Dec 2019 17:41:15 -0800 Subject: [PATCH] Update initialize-pi.sh --- initialize-pi.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/initialize-pi.sh b/initialize-pi.sh index aa1b94d..41dc6a7 100755 --- a/initialize-pi.sh +++ b/initialize-pi.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSION="1.14.1" +VERSION="1.15.0" # # Script to generate new VNC server and SSH server keys at boot time if a certain @@ -19,7 +19,7 @@ DIR="$HOME" INIT_DONE_FILE="$DIR/DO_NOT_DELETE_THIS_FILE" # Does $INIT_DONE_FILE exist? Is it a regular file? Is it not empty? If YES to all, then -# check the status of the piano switch. +# exit. if [ -e "$INIT_DONE_FILE" ] && [ -f "$INIT_DONE_FILE" ] && [ -s "$INIT_DONE_FILE" ] then # [ -s /usr/local/bin/check-piano.sh ] && /usr/local/bin/check-piano.sh @@ -181,6 +181,12 @@ do sudo sed -e "s/_LEFT_RADIO_/Left Radio/" -e "s/_RIGHT_RADIO_/Right Radio/g" $F > ${F%.*}.desktop done +# Expand the filesystem if it is < 8 GB +echo "Expand filesystem if needed" >> "$INIT_DONE_FILE" +PARTSIZE=$( df | sed -n '/root/{s/ */ /gp}' | cut -d ' ' -f2 ) +THRESHOLD=$((8 * 1024 * 1024)) +(( $PARTSIZE < $THRESHOLD )) && sudo raspi-config --expand-rootfs >> "$INIT_DONE_FILE" + echo "Raspberry Pi initialization complete" >> "$INIT_DONE_FILE" sudo shutdown -r now