Index: scripts/factory_reset.sh =================================================================== diff -u -r984f3ebe19ddb9cf4bdfd9b2d47c082ff0b3426b -r9a8412f742caf6491cf888843155a32040de4c04 --- scripts/factory_reset.sh (.../factory_reset.sh) (revision 984f3ebe19ddb9cf4bdfd9b2d47c082ff0b3426b) +++ scripts/factory_reset.sh (.../factory_reset.sh) (revision 9a8412f742caf6491cf888843155a32040de4c04) @@ -19,7 +19,6 @@ # @details # This file is called by UI Software to remove and reset the device - #TODO This script needs to be integrated with the globals.sh ERR_REMOVE_PRM_DIR=150 @@ -41,7 +40,12 @@ LOC_SETTINGS_DFLT="/var/configurations/Settings/System.dflt" LOC_LOG_BASE_FOLDER="/media/sd-card/" LOC_TX_LOG_BASE_FOLDER="/var/configurations/treatment/" +LOC_SCRIPTS=$HOME/scripts +LOC_SCRIPTS_BRIGHTNESS=$LOC_SCRIPTS/brightness_set.sh +DEFAULT_BRIGHTNESS_LEVEL=10 + + TRUE=1 FALSE=0 function false() { echo $FALSE; } @@ -174,29 +178,41 @@ _has_error_=$? exitError $_has_error_ $ERR_CLEAN_SETTINGS_CONF_OVERWRITE "Service settings overwrite failed" - sed -i "s/^.*Password.*$/$servicePasswordLineK/" $LOC_SETTINGS_CONF # keep the service password + sed -i "s/^.*Password.*$/$servicePasswordLine/" $LOC_SETTINGS_CONF # keep the service password _has_error_=$? exitError $_has_error_ $ERR_CLEAN_SETTINGS_DFLT_RESTORE "Service password restore failed" } +function defaultBrightness() { + $LOC_SCRIPTS_BRIGHTNESS $DEFAULT_BRIGHTNESS_LEVEL +} + function deleteLogFiles() { - # handling log deletion in a special manner: + # handling log deletion in a special manner: # - Log files generated today # - are not deleted # - not part of the checking whether deletion was successful # - setting maxDepth to 2 due to path used is root level with sd-card/ folders of logs # NOTE: find command always return true / non-zero! when using with exec - find "$LOC_LOG_BASE_FOLDER" -maxdepth 2 -type f -daystart -mtime +0 | xargs rm + # TODO: Checking the file count should be fixed later + + # Remove the contents of the log folder + rm "$LOC_LOG_BASE_FOLDER"/log/* _has_error_=!$? exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Log file deletion" + + # Remove the contents of the service folder + rm "$LOC_LOG_BASE_FOLDER"/service/* + _has_error_=!$? + exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Service file deletion" fileCount=$(find "$LOC_LOG_BASE_FOLDER" -maxdepth 2 -type f -daystart -mtime +0 | wc -l) _has_error_=$fileCount exitError $_has_error_ $ERR_REMOVE_DEL_FIL "Remained '$fileCount' file undeleted" - - # Deleting treatment logs in encrypted partition: + + # Deleting treatment logs in encrypted partition: find "$LOC_TX_LOG_BASE_FOLDER" -maxdepth 2 -type f | xargs rm - + _has_error_=!$? exitError $_has_error_ $ERR_REMOVE_CMD_FIL "Tx Log file deletion" @@ -208,6 +224,7 @@ # delete WiFi settings # delete Bluetooth settings # settings.conf to default +# brightness to default (10) # delete logs # keep partition password # keep service password @@ -216,6 +233,7 @@ deleteWiFi deleteBluetooth defaultSettings + defaultBrightness deleteLogFiles }