forked from 9hitste/install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-patch.sh
84 lines (76 loc) · 2.23 KB
/
get-patch.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
ARGS=$@
#DOWNLOAD_URL="http://dl.9hits.com/patch-v3-linux64.tar.bz2"
DOWNLOAD_URL="http://mirror-dl.9hits.com/patch-v3-linux64.tar.bz2"
INSTALL_DIR=~
function main() {
echo "Updating..."
parse_args
install_fonts
update
}
function parse_args() {
for i in $ARGS; do
case $i in
--install-dir=*)
INSTALL_DIR="${i#*=}"
shift # past argument=value
;;
--download-url=*)
DOWNLOAD_URL="${i#*=}"
shift # past argument=value
;;
-*|--*)
echo "Unknown option $i"
;;
*)
;;
esac
done
}
function install_fonts () {
if [ -d /usr/share/fonts/windows/ ]; then
echo "Skipping fonts installation"
else
echo "Installing fonts..."
rm -rf fonts.tar.bz2
wget http://dl.9hits.com/fonts.tar.bz2
tar -xvf fonts.tar.bz2 -C /
rm -rf fonts.tar.bz2
fc-cache -f -v
fi
}
function update () {
if [ -d "$INSTALL_DIR/9hitsv3-linux64/" ]; then
echo "Backing up crontab..."
crontab -l > "$INSTALL_DIR/9hitsv3-linux64/_9hits_cron.bak" && crontab -r
echo "Stopping running app..."
pkill 9hits ; pkill 9hbrowser ; pkill 9htl ; pkill exe
echo "Downdloading..."
cd "$INSTALL_DIR/9hitsv3-linux64/" && wget -O "$INSTALL_DIR/_9hits_patch.tar.bz2" $DOWNLOAD_URL
echo "Extracting update..."
pkill 9hits ; pkill 9hbrowser ; pkill 9htl ; pkill exe
cd "$INSTALL_DIR/9hitsv3-linux64/" && tar -xvf "$INSTALL_DIR/_9hits_patch.tar.bz2"
rm -f "$INSTALL_DIR/_9hits_patch.tar.bz2"
chmod -R 777 "$INSTALL_DIR/9hitsv3-linux64/"
chmod +x "$INSTALL_DIR/9hitsv3-linux64/9hits"
chmod +x "$INSTALL_DIR/9hitsv3-linux64/3rd/9htl"
chmod +x "$INSTALL_DIR/9hitsv3-linux64/browser/9hbrowser"
chmod +x "$INSTALL_DIR/9hitsv3-linux64/9HitsApp"
echo "Removing cache..."
rm -rf ~/.cache/9hits-app/
echo "Restoring crontab..."
if [ -f "$INSTALL_DIR/9hitsv3-linux64/_9hits_cron.bak" ]; then
crontab "$INSTALL_DIR/9hitsv3-linux64/_9hits_cron.bak"
rm -f "$INSTALL_DIR/9hitsv3-linux64/_9hits_cron.bak"
echo "Restored"
fi
if !(crontab -l | grep -q "* * * * * $INSTALL_DIR/9hitsv3-linux64/cron-start"); then
(echo "* * * * * $INSTALL_DIR/9hitsv3-linux64/cron-start") | crontab -
echo "Re-created"
fi
echo "9HITS APPLICATION HAS BEEN UPDATED!"
else
echo "ERROR: NOT FOUND THE 9HITS APPLICATION ($INSTALL_DIR)!"
fi
}
main