forked from nan0s7/nfancurve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·59 lines (50 loc) · 1.59 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
echo "~~ nan0s7's fan-speed curve script updater script ~~"
# This script is able to run temp.sh in the background for you, btw
echo "Checking for installed git version..."
verG=`git --version`
# Here I'm assuming that the version string format does not change much
if [ "${#verG}" -lt "22" ]; then
echo "Git found!"
echo $verG
else
echo "Git not found... you should install that and try again"
exit
fi
# Currently installed version
verL=`cat VERSION.txt`
# Repository's version
verR=`git ls-remote -t https://github.com/nan0s7/nfancurve.git`
verR=${verR:(-3)}
echo "Installed version of script: "$verL
echo "Latest version of script: "$verR
if [ "$verL" -eq "$verR" ]; then
echo "You are using the most up-to-date version"
elif [ "$verL" -lt "$verR" ]; then
echo "You are using an outdated version"
echo "If you don't want to automatically download the latest version, press CTRL+C to quit this script"
sleep 4
# Downloads the whole repository to make sure nothing is old
`git clone https://github.com/nan0s7/nfancurve`
cd nfancurve
echo "Replacing old files"
# Moves every file into main directory
mv -f -t ../ `ls`
cd ../
echo "Removing temporary directory"
# Deletes leftover folder
rm -rf nfancurve
echo "Done"
echo "Newly installed version: "`cat VERSION.txt`
else
echo "You're using a developer version! =O"
fi
# Gets the running PID for my script (if it's running)
tempPID=`pgrep temp.sh`
# If the outdated script is running, kill it
if [ -n "$tempPID" ] && [ "$tempPID" -gt 0 ]; then
kill $tempPID
fi
# Run the new version of the script
nohup ./temp.sh >/dev/null 2>&1 &
exit