Skip to content

Commit

Permalink
added function to upgrade to correct lacale issues related to headles…
Browse files Browse the repository at this point in the history
…s install of a rpi.
  • Loading branch information
lgbrownjr committed Apr 7, 2021
1 parent 704a18e commit ec04974
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ fi
#fi

#Add required packadges:

if [ ${upgrade_path} != "basic" ] ; then
printf "\n${nor}Check for the status of additional required packages:\n"
for package in "${package_install_list[@]}"; do
Expand All @@ -272,7 +271,7 @@ if [ ${upgrade_path} != "basic" ] ; then
printf "\n${nor}Check for the status of rquired Python 3 modules:\n"
printf " ${nor}Reading in list of already-installed modules...${nor}"
installed_modules=($(pip3 list)) && printf "${drk_grn}Done${nor}\n"
printf " ${nor}Checking required modules against list and installing anything missing...${nor}\n"
printf " ${nor}Checking required modules against list and installing anything missing:${nor}\n"
for module in "${python_req_list[@]}"; do
echo ${installed_modules[@]} | grep ${module} > /dev/null 2>&1
if [ ${?} -eq 1 ]; then
Expand All @@ -284,6 +283,23 @@ if [ ${upgrade_path} != "basic" ] ; then
done
fi

#Check for and correct locale while managing a headless pi:
printf "\n${nor}Checking and correcting ${yel}locale ${nor}issues\n"
set_local=$(grep LANG= /etc/default/locale | cut -f 2 -d "=")
existing_local_ver=$(awk '/^LANGUAGE=/,/^LC_ALL=.*&/ { print }' "${etc_folder}default/locale")
official_local_ver="LANGUAGE=${set_local}\nLC_ALL=${set_local}"
diff --suppress-common-lines -W 160 -y <(printf "${existing_local_ver}") <(printf "${official_local_ver}") &>/dev/null
if [ ${?} -eq 1 ]; then
printf " ${nor}Will clean and re-apply corected configurations..." | fmt --goal=91 --width=${last_col}
# sed -i '/^LANGUAGE=,*/, /^LC_ALL=.*/d' "${etc_folder}default/locale"
update-locale LANG=${set_local} LANGUAGE=${set_local} LC_ALL=${set_local} > /dev/null 2>&1 && printf "${drk_grn}Done${nor}.\n" || printf "${drk_grn}Failed${nor}.\n"
printf " ${nor}Applying updates..."
printf "${official_local_ver}" >> "${etc_folder}$default/locale" && printf "${drk_grn}Done${nor}.\n" || printf "${drk_grn}Failed${nor}.\n"
else
printf " ${nor}Both versions are the same, skipping...\n"
fi


#checking and adding modules as needed into /etc/modules:
printf "\n${nor}Check to make sure the the relavent modules are loaded:\n"
grep -q -s -o -e "^g_serial" ${etc_folder}modules && (printf " ${nor}module ${drk_grn}already${nor} loaded\n") || (sudo bash -c "echo 'g_serial' >> ${etc_folder}modules"; printf " ${nor}module ${drk_grn}successfully${nor} loaded\n")
Expand Down

0 comments on commit ec04974

Please sign in to comment.