mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-05-02 11:22:54 -05:00
Added automatic update checking functionality
This commit is contained in:
parent
c58f9f5224
commit
bd0f3f2cc0
2 changed files with 43 additions and 7 deletions
28
install.sh
28
install.sh
|
@ -1,8 +1,19 @@
|
|||
tput sc
|
||||
echo "Checking for latest release..."
|
||||
if ! [[ $1 == "auto" ]] && [ -z "$1" ]; then
|
||||
echo "Checking for latest release..."
|
||||
fi
|
||||
|
||||
latestver=$(curl -Ls https://github.com/G2-Games/welcome.sh/releases/latest/download/welcome.sh | grep version | sed 's/.*=//')
|
||||
oldver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | sed 's/.*=//' | sed 's/[.][.]*//g') && if ! [ -n "$oldver" ]; then oldver=0; fi
|
||||
|
||||
version="${1:-$latestver}"
|
||||
|
||||
if [[ $1 == "auto" ]] && [[ $(echo $latestver | sed 's/[.][.]*//g') -le $oldver ]]; then
|
||||
exit 0
|
||||
elif [[ $1 == "auto" ]]; then
|
||||
version=$latestver
|
||||
fi
|
||||
|
||||
vernum=$(echo $version | sed 's/[.][.]*//g' )
|
||||
bashrc=~/.bashrc
|
||||
zshrc=~/.zshrc
|
||||
|
@ -58,8 +69,11 @@ if [ "$environment" = "bash" ] || [ "$environment" = "zsh" ]; then
|
|||
tput rc
|
||||
tput sc
|
||||
mkdir -p ~/.welcome
|
||||
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
||||
oldver=$(grep version ~/.welcome/welcome.sh 2> /dev/null | sed 's/.*=//' | sed 's/[.][.]*//g') && if ! [ -n "$oldver" ]; then oldver=0; fi
|
||||
if ! [[ $1 == "auto" ]]; then
|
||||
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
||||
else
|
||||
echo -e "\e[32mUpdate available for \e[35mwelcome.sh!\e[0m"
|
||||
fi
|
||||
if [[ $vernum -gt $oldver ]]; then
|
||||
if which curl >/dev/null ; 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')
|
||||
|
@ -72,7 +86,7 @@ if [ "$environment" = "bash" ] || [ "$environment" = "zsh" ]; then
|
|||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
if [[ $cfgver -gt $(grep version ~/.welcome/config.cfg 2> /dev/null | sed 's/.*=//' | sed 's/[.][.]*//g') ]] && ! [ -z ~/.welcome/config.cfg ]; then
|
||||
|
||||
univread "Newer config version available. Do you want to \e[31moverwrite\e[0m your config? \nA backup will be created in the \e[36m.welcome\e[0m folder.\n\e[36mY/n\e[0m"
|
||||
univread "Newer \e[36mconfig\e[0m version available. Do you want to \e[31moverwrite\e[0m your \e[36mconfig\e[0m? \nA backup will be created in the \e[36m.welcome\e[0m folder.\n\e[36mY/n\e[0m"
|
||||
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
overcfg=1
|
||||
|
@ -128,7 +142,11 @@ if [ "$environment" = "bash" ] || [ "$environment" = "zsh" ]; then
|
|||
exit 0
|
||||
else
|
||||
tput rc && tput el && tput ed
|
||||
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
||||
if ! [[ $1 == "auto" ]]; then
|
||||
echo -e "\e[35mwelcome.sh\e[0m already installed!"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
22
welcome.sh
22
welcome.sh
|
@ -243,7 +243,7 @@ updatecheck="on" #< Check for general updates
|
|||
flatpakupd="off" #< Check for flatpak updates, this slows startup down A LOT
|
||||
goodgreeting="on" #< Display greetings like "Good afternoon," else "It's afternoon"
|
||||
|
||||
# ALL the stuff above this line and below the colors line is in the config, changing it here will do nothing if the config doesn't exist!
|
||||
# ALL the stuff above this line and below the colors line is in the config, changing it here will do nothing only if the config doesn't exist!
|
||||
|
||||
source ~/.welcome/config.cfg
|
||||
|
||||
|
@ -251,5 +251,23 @@ welcome
|
|||
greeting
|
||||
clock
|
||||
battery
|
||||
if [ "$updatecheck" = "on" ]; then updates; fi
|
||||
if [ "$updatecheck" = "on" ];then updates; fi
|
||||
echo # Properly line break at the end
|
||||
|
||||
set +e
|
||||
|
||||
date=$(date +%s)
|
||||
lastdate=$(cat ~/.welcome/udm 2>/dev/null)
|
||||
|
||||
if [[ $((date - lastdate)) -ge 86400 ]]; then
|
||||
environment=$(ps -o args= -p $$ | grep -Em 1 -o '\w{0,5}sh' | head -1)
|
||||
if [[ "$environment" = "bash" ]]; then
|
||||
bash install.sh auto
|
||||
elif [[ "$environment" = "zsh" ]]; then
|
||||
zsh install.sh auto
|
||||
fi
|
||||
echo $(date +%s) >| ~/.welcome/udm 2>/dev/null
|
||||
elif ! [[ -f ~/.welcome/udm ]]; then
|
||||
touch ~/.welcome/udm
|
||||
echo $(date +%s) >| ~/.welcome/udm 2>/dev/null
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue