When attempting to reset the database on a "large" USB device, the calculation for SIZEAVAIL overflows.
See code change below which is used in other scripts. Use AWK rather than SHELL to do calculation.
--- ntpmerlin
+++ ntpmerlin_NEW
@@ -1195,8 +1195,9 @@
Reset_DB(){
SIZEAVAIL="$(df -P -k "$SCRIPT_STORAGE_DIR" | awk '{print $4}' | tail -n 1)"
+ SIZEAVAIL="$(echo "$SIZEAVAIL" | awk '{printf("%s", $1*1024);}')"
SIZEDB="$(ls -l "$SCRIPT_STORAGE_DIR/ntpdstats.db" | awk '{print $5}')"
- if [ "$SIZEDB" -gt "$((SIZEAVAIL*1024))" ]; then
+ if [ "$SIZEDB" -gt "$SIZEAVAIL" ]; then
Print_Output true "Database size exceeds available space. $(ls -lh "$SCRIPT_STORAGE_DIR/ntpdstats.db" | awk '{print $5}')B is required to create backup." "$ERR"
return 1
See code change below which is used in other scripts. Use AWK rather than SHELL to do calculation.
--- ntpmerlin
+++ ntpmerlin_NEW
@@ -1195,8 +1195,9 @@
Reset_DB(){
SIZEAVAIL="$(df -P -k "$SCRIPT_STORAGE_DIR" | awk '{print $4}' | tail -n 1)"
+ SIZEAVAIL="$(echo "$SIZEAVAIL" | awk '{printf("%s", $1*1024);}')"
SIZEDB="$(ls -l "$SCRIPT_STORAGE_DIR/ntpdstats.db" | awk '{print $5}')"
- if [ "$SIZEDB" -gt "$((SIZEAVAIL*1024))" ]; then
+ if [ "$SIZEDB" -gt "$SIZEAVAIL" ]; then
Print_Output true "Database size exceeds available space. $(ls -lh "$SCRIPT_STORAGE_DIR/ntpdstats.db" | awk '{print $5}')B is required to create backup." "$ERR"
return 1