Skip to content

Commit

Permalink
Change how unpartitioned space is determined, always show banner and …
Browse files Browse the repository at this point in the history
…storage tab if more than 1G unpartitioned.
  • Loading branch information
dkulp committed Oct 30, 2023
1 parent 20aab09 commit 0d6a884
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
45 changes: 26 additions & 19 deletions scripts/init_pre_network
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,33 @@ echo "FPP - Clearing reboot flags"
sed -i -e "s/^rebootFlag .*/rebootFlag = \"0\"/" ${FPPHOME}/media/settings

if [ ! -f /etc/fpp/desktop ]; then
# make sure the media directory in the settings matches what we used at boot
echo "FPP - Sanity checking storage device setting"
MEDIADEV=`findmnt -n -o SOURCE /home/fpp/media | colrm 1 5`
if [ "$MEDIADEV" = "" ]; then
MEDIADEV=`findmnt -n -o SOURCE / | colrm 1 5`
fi
if grep -q storageDevice "${FPPHOME}/media/settings"; then
sed -i -e "s#^storageDevice .*#storageDevice = \"$MEDIADEV\"#" ${FPPHOME}/media/settings
else
echo "storageDevice = \"$MEDIADEV\"" >> ${FPPHOME}/media/settings
fi
# make sure the media directory in the settings matches what we used at boot
echo "FPP - Sanity checking storage device setting"
MEDIADEV=`findmnt -n -o SOURCE /home/fpp/media | colrm 1 5`
if [ "$MEDIADEV" = "" ]; then
MEDIADEV=`findmnt -n -o SOURCE / | colrm 1 5`
fi
if grep -q storageDevice "${FPPHOME}/media/settings"; then
sed -i -e "s#^storageDevice .*#storageDevice = \"$MEDIADEV\"#" ${FPPHOME}/media/settings
else
echo "storageDevice = \"$MEDIADEV\"" >> ${FPPHOME}/media/settings
fi

LASTBLOCK=$(getSetting LastBlock)
if [ "x${LASTBLOCK}" != "x0" ]
then
LASTBLOCK=$(sfdisk -q -l -o end /dev/mmcblk0 2>/dev/null | tail -n 1)
if [ "$LASTBLOCK" == "" ]; then
LASTBLOCK=0
if [ -f /dev/mmcblk0 ]; then
SPACEFREE_SFDISK=$(sfdisk -F /dev/mmcblk0 2>/dev/null | tail -n 1)
if [ "$SPACEFREE_SFDISK" == "" ]; then
setSetting UnpartitionedSpace "0"
else
read -r -a SFARRAY <<< "$SPACEFREE_SFDISK"
if [ "${SFARRAY[3]: -1}" == "G" ]; then
SPACEFREE=${SFARRAY[3]::-1}
setSetting UnpartitionedSpace "${SPACEFREE}"
elif [ "${SFARRAY[3]: -1}" == "M" ]; then
setSetting UnpartitionedSpace "0"
fi
fi
setSetting LastBlock $LASTBLOCK
else
setSetting UnpartitionedSpace "0"
fi
fi

Expand All @@ -156,7 +163,7 @@ then
if [[ $uboot != *"U-Boot 2022.04-gd0771d5"* ]]; then
cd /opt/fpp/bin.bbb/bootloader
/opt/fpp/bin.bbb/bootloader/install.sh
echo 'rebootFlag = "1"' >> /home/fpp/media/settings
setSetting rebootFlag "1"
fi
else
# bug in kernel on pcoketbeagle where in P2-36 is not
Expand Down
2 changes: 1 addition & 1 deletion www/healthCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function StartHealthCheck() {
<div id="healthCheck" class="">

<?php
if (isset($settings["LastBlock"]) && $settings["LastBlock"] > 1000000 && $settings["LastBlock"] < 8000000) {
if (isset($settings["UnpartitionedSpace"]) && $settings["UnpartitionedSpace"] > 0) {
?>
<div id='upgradeFlag' class="alert alert-danger" role="alert">
SD card has unused space. Go to
Expand Down
6 changes: 2 additions & 4 deletions www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,10 @@ function NextPlaylistEntry()
<h1 class="title statusTitle">Status <span class="statusHostname"><?=$settings["HostName"]?></span></h1>

<?php
if (isset($settings["LastBlock"]) && $settings["LastBlock"] > 1000000 && $settings["LastBlock"] < 8000000):
if (isset($settings["UnpartitionedSpace"]) && $settings["UnpartitionedSpace"] > 0):
?>
<div id='spaceFlag' class="alert alert-danger" role="alert">
SD card has unused space. Go to <a href="settings.php?tab=Storage">Storage Settings</a> to expand the
file system or create a new storage partition.
<input type='button' class='buttons btn-success' style='float: right' value='Leave Unused' onClick='SetSetting("LastBlock", "0", 0, 0); $("#spaceFlag").hide();'>
SD card has unused space. Go to <a href="settings.php?tab=Storage">Storage Settings</a> to expand the file system or create a new storage partition.
</div>
<?php endif;?>

Expand Down
2 changes: 1 addition & 1 deletion www/settings-all.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
include('common/menuHead.inc');

$storageUILevel = 1;
if (isset($settings["LastBlock"]) && $settings['LastBlock'] > 0 && $settings['LastBlock'] < 8000000) {
if (isset($settings["UnpartitionedSpace"]) && $settings['UnpartitionedSpace'] > 0) {
$storageUILevel = 0;
}
$pages = array(
Expand Down
3 changes: 1 addition & 2 deletions www/settings-storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
function StorageDialogDone() {
EnableModalDialogCloseButton("storageSettingsProgress");
$('#storageSettingsProgressCloseButton').prop("disabled", false);
SetSetting("LastBlock", "0", 0, 1);
}
function growSDCardFS() {
DisplayConfirmationDialog("growSDCard", "Grow Filesystem", $("#dialog-confirm"), function() {
Expand Down Expand Up @@ -235,7 +234,7 @@ function PrintStorageDeviceSelect($platform)
exec('findmnt -n -o SOURCE / | colrm 1 5', $output, $return_val);
$rootDevice = $output[0];
if ($rootDevice == 'mmcblk0p1' || $rootDevice == 'mmcblk0p2') {
if (isset($settings["LastBlock"]) && $settings['LastBlock'] < 8000000 && $settings['LastBlock'] > 0) {
if (isset($settings["UnpartitionedSpace"]) && $settings['UnpartitionedSpace'] > 0) {
$addnewfsbutton = true;
}
if ($settings['Platform'] == "BeagleBone Black") {
Expand Down
2 changes: 1 addition & 1 deletion www/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function UpdateCurrentTime(once = false) {
$tabId = $_GET['tab'];
}
$storageUILevel = 1;
if (isset($settings["LastBlock"]) && $settings['LastBlock'] > 0 && $settings['LastBlock'] < 8000000) {
if (isset($settings["UnpartitionedSpace"]) && $settings['UnpartitionedSpace'] > 0) {
$storageUILevel = 0;
}
?>
Expand Down

0 comments on commit 0d6a884

Please sign in to comment.