diff --git a/install.sh b/install.sh index a444c96..52e981e 100755 --- a/install.sh +++ b/install.sh @@ -45,12 +45,21 @@ then tput sc echo -e "\e[35mwelcome.sh\e[0m already installed!" if [[ $vernum -gt $(grep version ~/.welcome/welcome.sh | sed 's/.*=//' | sed 's/[.][.]*//g') ]]; then - cfgver=$(echo $(curl -Ls https://github.com/G2-Games/welcome.sh/releases/download/v$version/config.cfg) | grep version | sed 's/.*=//' | sed 's/[.][.]*//g') + cfgver=$(echo $(curl -Ls https://github.com/G2-Games/welcome.sh/releases/download/v$version/config.cfg) | grep version | sed 's/.*=//' | sed 's/[.][.]*//g') # Check the new config version echo -en "Do you want to \e[36mupdate \e[35mwelcome.sh\e[0m? (v$(grep version ~/.welcome/welcome.sh | sed 's/.*=//') => v$version) \n\e[36mY/n\e[0m" if [[ "$environment" = "bash" ]]; then read -p " " -n 1 -r; elif [[ "$environment" = "zsh" ]]; then read -q "REPLY? " -n 1 -r; fi echo if [[ $REPLY =~ ^[Yy]$ ]]; then + if [[ $cfgver -gt $(grep version ~/.welcome/config.cfg | sed 's/.*=//' | sed 's/[.][.]*//g') ]]; then + echo -en "New config version available. Do you want to \e[31moverwrite\e[0m your config?\n\e[36mY/n\e[0m" + if [[ "$environment" = "bash" ]]; then read -p " " -n 1 -r; + elif [[ "$environment" = "zsh" ]]; then read -q "REPLY? " -n 1 -r; fi + echo + if [[ $REPLY =~ ^[Yy]$ ]]; then + overcfg=1 + fi + fi tput rc el ed echo "Updating..." tput sc @@ -58,13 +67,15 @@ then if which curl >/dev/null ; then curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --output ~/.welcome/welcome.sh - if [[ $vernum -ge 100 ]] && [[ $cfgver -gt $(grep version ~/.welcome/config.cfg | sed 's/.*=//' | sed 's/[.][.]*//g') ]]; then + if [[ $vernum -ge 100 ]] && [[ $overcfg -gt 0 ]]; then + mv ~/.welcome/config.cfg ~/.welcome/config_old.cfg curl -SL https://github.com/G2-Games/welcome.sh/releases/download/v${version}/config.cfg --output ~/.welcome/config.cfg fi elif which wget >/dev/null ; then wget https://github.com/G2-Games/welcome.sh/releases/download/v${version}/welcome.sh --P ~/.welcome/ - if [[ $vernum -ge 100 ]] && [[ $cfgver -gt $(grep version ~/.welcome/config.cfg | sed 's/.*=//' | sed 's/[.][.]*//g') ]]; then + if [[ $vernum -ge 100 ]] && [[ $overcfg -gt 0 ]]; then + mv ~/.welcome/config.cfg ~/.welcome/config_old.cfg wget https://github.com/G2-Games/welcome.sh/releases/download/v${version}/config.cfg --P ~/.welcome/ fi else