From 23df556c586bbf5054856b603ed7bfebf955be15 Mon Sep 17 00:00:00 2001 From: Andrei Shevchuk Date: Mon, 26 Feb 2018 12:36:12 +0300 Subject: [PATCH] Automatically configure language on install --- install.sh | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e19eb94..4241df1 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,36 @@ -#! /usr/bin/env sh +#! /usr/bin/env bash THEME='poly-light' +LANG='English' + +# Pre-authorise sudo +sudo echo + +# Select language, optional +declare -A LANGS=( + [Chinese]=zh_CN + [English]=EN + [French]=FR + [German]=DE + [Portuguese]=PT + [Russian]=RU + [Ukrainian]=UA +) + +LANG_NAMES=($(echo ${!LANGS[*]} | tr ' ' '\n' | sort -n)) + +PS3='Please select language #: ' +select l in "${LANG_NAMES[@]}" +do + if [[ -v LANGS[$l] ]] + then + LANG=$l + break + else + echo 'No such language, try again' + fi +done + echo 'Fetching theme archive' wget https://github.com/shvchk/$THEME/archive/master.zip @@ -8,6 +38,13 @@ wget https://github.com/shvchk/$THEME/archive/master.zip echo 'Unpacking theme' unzip master.zip +if [[ "$LANG" != "English" ]] +then + echo "Changing language to ${LANG}" + sed -i -r -e '/^\s+# EN$/{n;s/^(\s*)/\1# /}' \ + -e '/^\s+# '"${LANGS[$LANG]}"'$/{n;s/^(\s*)#\s*/\1/}' $THEME-master/theme.txt +fi + echo 'Creating GRUB themes directory' sudo mkdir -p /boot/grub/themes/$THEME