-
Notifications
You must be signed in to change notification settings - Fork 23
/
upPASTE
47 lines (42 loc) · 1.24 KB
/
upPASTE
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
#!/bin/bash
export NVOC="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source ${NVOC}/1bash
TIMEOUT=$(($upPASTE_TIMEOUT_IN_MINUTES * 60))
echo
echo "checks for a 1bash update every $TIMEOUT seconds"
echo
while true
do
if [[ wget -O "${NVOC}/temp1bash" $pasteBASH && -f "${NVOC}/temp1bash" ]]
then
old=$(md5sum "${NVOC}/1bash" | sed 's/[^0-9]*//g')
echo $old
echo
new=$(md5sum "${NVOC}/temp1bash" | sed 's/[^0-9]*//g')
echo $new
echo
if [[ $old != $new ]]
then
# ensure unix encoding
dos2unix "${NVOC}/temp1bash"
# check new 1bash for errors
if [[ "$(which shellcheck)" != "" && $(shellcheck -e 2034 -f gcc "${NVOC}/temp1bash" | grep -c error) != 0 ]]
then
echo "################################################################################"
echo " !! There is something wrong with your 1bash file at $pasteBASH"
echo " Current 1bash file will not be replaced."
echo
else
cp "${NVOC}/temp1bash" "${NVOC}/1bash"
echo
echo "1bash updated from paste: $pasteBASH"
echo "restarting nvOC..."
bash ${NVOC}/nvOC restart
fi
else
echo "same 1bash, no changes"
echo
fi
fi
sleep $TIMEOUT
done