-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·38 lines (36 loc) · 1.15 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#colors
red='\e[1;31m%s\e[0m\n'
green='\e[1;32m%s\e[0m\n'
yellow='\e[1;33m%s\e[0m\n'
blue='\e[1;34m%s\e[0m\n'
magenta='\e[1;35m%s\e[0m\n'
cyan='\e[1;36m%s\e[0m\n'
#clear vars
NEWVERSION=""
OLDVERSION=""
choice=""
# Version check
if [ -z "$DOTFILESDIR" ]; then
dotfilesdir="$DOTFILESDIR"
else
dotfilesdir=~/.local/dotfiles/desktops
fi
if [ -f $dotfilesdir/src/os/version.txt ]; then
printf "\t$magenta" "Checking for updates"
NEWVERSION="$(echo $(curl -Lsq https://github.com/casjay/dotfiles/raw/main/src/os/version.txt |grep -v "#" | tail -n 1))"
OLDVERSION="$(echo $(cat $dotfilesdir/src/os/version.txt | tail -n 1))"
if [ "$NEWVERSION" == "$OLDVERSION" ]; then
printf "\t\t$green No updates available current version is $OLDVERSION\n"
else
printf "\t\t$red Update available - New version is $NEWVERSION"
printf "\t\t$red Would you like to update? [y/N]"
read -n 1 -s choice
if [ $choice == "y" ]; then
cd $dotfilesdir && git pull -q
printf "\t\t$green Updated to latest version = $NEWVERSION\n"
else
printf "\t\t$magenta You decided not to update\n"
fi
fi
fi