-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLawnchair.sh
63 lines (56 loc) · 1.71 KB
/
Lawnchair.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#url='https://labs.xda-developers.com/store/app/download/ch.deletescape.lawnchair'
gh_json=https://api.github.com/repos/Deletescape-Media/Lawnchair/releases/latest
down_url=$(echo $gh_json | python -c 'import sys, urllib, json; url=(sys.stdin.readline()); response=urllib.urlopen(url); data=json.loads(response.read()); print data["assets"][0]["browser_download_url"]')
CUR_DIR=`pwd`
DOWN_PATH="$CUR_DIR/dot_scripts/Lawnchair"
# Package manager check to install 'wget'
declare -A osInfo;
osInfo[/etc/redhat-release]=yum
osInfo[/etc/pacman.conf]=pacman
osInfo[/etc/debian_version]=apt-get
if which wget > /dev/null 2> /dev/null
then
echo "wget package found..."
else
echo "wget package not found. Trying to install..."
for f in ${!osInfo[@]}
do
if [[ -f $f ]]; then
echo Package manager: ${osInfo[$f]}
TEMP=${osInfo[$f]}
fi
done
case "$TEMP" in
"yum")
`sudo yum install wget`
;;
"apt-get")
`sudo apt-get intall wget`
;;
"pacman")
`sudo pacman -S wget`
;;
*)
echo "Unknow Distribution! 'wget' couldn't be installed. Please install it manually"
;;
esac
fi
wget -q --tries=10 --timeout=20 --spider http://google.com
if [[ $? -eq 0 ]]; then
if [[ -f $DOWN_PATH/Lawnchair.apk ]]; then
if [[ $(find "$DOWN_PATH/Lawnchair.apk" -mtime +1 -print) ]]; then
echo "We already have the latest version of Lawnchair"
fi
else
echo "Grabbing the latest version of Lawnchair"
wget -q -O $DOWN_PATH/Lawnchair.apk $down_url
fi
else
echo "Looks like you aren't connected to the Internet"
if [[ -f $DOWN_PATH/Lawnchair.apk ]]; then
echo "An old version of Lawnchair exists, using it for now."
else
echo "Nothing found! Lawncahir won't be available in this build!"
fi
fi