diff --git a/functions/menus/f_mainMenus.cfg b/functions/menus/f_mainMenus.cfg index 4ecaa1ef..4ef47589 100644 --- a/functions/menus/f_mainMenus.cfg +++ b/functions/menus/f_mainMenus.cfg @@ -9,7 +9,7 @@ main_menu_items=( 8 '[Sub-Menu] Cleanup Linux System' C 'Install Multimedia Codecs' I 'Display Info about current install' - O '[Sub-menu] Default Grub related Submenu' + O '[Sub-Menu] Default Grub related Submenu' R "Check/Install Third Party Repositories" S '[Sub-Menu] Install Software' T '[Sub-Menu] Install Theming' diff --git a/functions/universal/f_osprober.cfg b/functions/universal/f_osprober.cfg index 15971f46..03adc049 100644 --- a/functions/universal/f_osprober.cfg +++ b/functions/universal/f_osprober.cfg @@ -21,41 +21,63 @@ function backupDefaultGrubConfig() { # Backs up any original backup file ... maybe overkill but just in case it's there and BECAUSE this deals with the boot loader... I want to back it up backupOriginalGrubBackup - # should i put a check for an existing backup file? - fancy_message action "Backing up default grub config file" && sudo cp ${defaultGrubConfig} ${defaultGrubConfigBackup} && fancy_message info "Default grub config file backed up" || fancy_message warn "Issue occured backing up default grub config file" + [ -f ${defaultGrubConfig} ] && fancy_message action "Backing up default grub config file" && sudo cp ${defaultGrubConfig} ${defaultGrubConfigBackup} && fancy_message info "Default grub config file backed up" || fancy_message warn "Issue occured backing up default grub config file" ## pass or fail there should be a pause... no need to have two, above userPrompt } +# Main Restore function function restoreDefaultGrubConfig() { - [ -f "${defaultGrubConfigBackup}" ] && fancy_message action "Restoring default grub config file" && userPrompt && cp ${defaultGrubConfigBackup} ${defaultGrubConfig} && fancy_message info "Default Grub config file is now restored" || fancy_message warn "Default Grub config backup file was not found; therefore, can not be restored" + fancy_message action "Restoring default grub config file" && userPrompt -} + [ -f "${defaultGrubConfigBackup}" ] && echo -e "Restoring ${defaultGrubConfigBackup} ${defaultGrubConfig}" && sudo cp ${defaultGrubConfigBackup} ${defaultGrubConfig} && fancy_message info "Default Grub config file is now restored" || fancy_message warn "Default Grub config backup file was not found; therefore, can not be restored" + userPrompt +} # End of Backup and Restore functions ########################################################################## +function displayGrubFileContent() { + # debugging + grubfileContent=$(grep "GRUB_DISABLE_OS_PROBER" /etc/default/grub) -function detectOSProberStatus() { - unset osProberStatus - - fancy_message action "Detecting status of OS_PROBER" - # idea: if it starts with GRUB_DISABLE_OS_PROBER (shouldn't match "#GRUB_DISABLE_OS_PROBER") and contains the word true - grep -E "^GRUB_DISABLE_OS_PROBER\|TRUE" ${defaultGrubConfig} + echo -e "Default Grub file content:\t ${grubfileContent}" + echo -e "\n Remember if a line with False OR there is no output then os_prober IS enabled" + echo -e "If this is empty that may mean there is NO GRUB_DISABLE_OS_PROBER line of any sort in the default grub file" + userPrompt + # end debugging - # 0 = disabled - osProberResult=$? +} - if [ "${osProberResult}" -eq "0" ]; then +function displayOSProberStatus() { + if [[ ${osproberLine} == GRUB_DISABLE_OS_PROBER* ]] && [[ ${osproberLine} == *"true"* ]]; then fancy_message info "os-prober is disabled" osProberStatus="disabled" else fancy_message info "os-prober is enabled" osProberStatus="enabled" + fi + + #displayGrubFileContent +} + +function detectOSProberStatus() { + unset osProberStatus + + fancy_message action "Detecting status of OS_PROBER" + + # idea: if it starts with GRUB_DISABLE_OS_PROBER (shouldn't match "#GRUB_DISABLE_OS_PROBER") and contains the word true + osproberLine=$(grep -E "^GRUB_DISABLE_OS_PROBER" ${defaultGrubConfig} ) + + # debugging + # echo -e "osproberLine:\t${osproberLine}" && userPrompt + # end debugging + + displayOSProberStatus userPrompt } @@ -66,5 +88,10 @@ function enableosProber() { # sed '/xmetal/c\THIS WAS A XMETAL LINE' test.txt; detectOSProberStatus - [ ${osProberStatus} == "disabled" ] && fancy_message action "Enabling os-prober to detect other OSs" && backupDefaultGrubConfig && sed 'GRUB_DISABLE_OS_PROBER=true/c\GRUB_DISABLE_OSPROBER=false' ${defaultGrubConfig} && "os-prober successfully enabled" || fancy_message warn "not able to enable, os-prober" + + # if disabled + # 1. Backup Grub config file in /etc/defaults + [ ${osProberStatus} == "disabled" ] && fancy_message action "Enabling os-prober to detect other OSs" && backupDefaultGrubConfig && sudo sed -i '/GRUB_DISABLE_OS_PROBER/s/^/#/' ${defaultGrubConfig} && fancy_message info "os-prober successfully enabled" || fancy_message warn "not able to enable, os-prober" + + userPrompt }