-
Notifications
You must be signed in to change notification settings - Fork 0
/
modcheck.sh
122 lines (96 loc) · 3.05 KB
/
modcheck.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /bin/bash
URL='WEBHOOKPLACEHOLDER'
arrNAME=()
WORKSHOP=()
WORKSHOP=$(grep -e '^Workshop' /home/USERPLACEHOLDER/Zomboid/Server/pei.ini | awk -F= '{print $2}' | sed 's/;/\n/g')
for i in $WORKSHOP
do
wget -q -O /opt/dizcord/mods/$i https://steamcommunity.com/sharedfiles/filedetails/changelog/$i
if [[ $(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 | awk '{print $4}') = "@" ]]; then
YEAR=$(date +%Y)
HOUR=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' 2757712197 | head -n1 | awk '{print $5}' | rev | cut -c3- | rev | awk -F: '{print $1}')
UPDATEMIN=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 | awk '{print $5}' | rev | cut -c3- | rev | awk -F: '{print $2}')
else
YEAR=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 | awk '{print $4}')
HOUR=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 | awk '{print $6}' | rev | cut -c3- | rev | awk -F: '{print $1}')
UPDATEMIN=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 | awk '{print $6}' | rev | cut -c3- | rev | awk -F: '{print $2}')
fi
MONTH=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 | awk '{print $3}' | sed 's/,//')
PREDAY=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 | awk '{print $2}')
if [[ "$PREDAY" -lt 10 ]]; then
DAY="0$PREDAY"
else
DAY="$PREDAY"
fi
MERIDIAN=$(grep -o -e 'Update:\s[0-9 a-zA-Z,]*@\s[0-9:amp]*' $i | head -n1 |awk '{print $5}' | rev | cut -c 1-2 | rev)
case $MONTH in
Jan)
MONTHNUM=1
;;
Feb)
MONTHNUM=2
;;
Mar)
MONTHNUM=3
;;
Apr)
MONTHNUM=4
;;
May)
MONTHNUM=5
;;
Jun)
MONTHNUM=6
;;
Jul)
MONTHNUM=7
;;
Aug)
MONTHNUM=8
;;
Sep)
MONTHNUM=9
;;
Oct)
MONTHNUM=10
;;
Nov)
MONTHNUM=11
;;
Dec)
MONTHNUM=12
;;
esac
if [[ "$MONTHNUM" -lt 10 ]]; then
MONTH=$(echo "0$MONTHNUM")
else
MONTH="$MONTHNUM"
fi
if [[ "$MERIDIAN" = "am" ]]; then
#if am
if [[ "$HOUR" -lt 10 ]]; then
UPDATEHOUR="0$HOUR"
fi
else
#if pm
if [[ "$HOUR" -eq 12 ]]; then
UPDATEHOUR="12"
else
UPDATEHOUR=$(( "$HOUR" + 12 ))
fi
fi
#echo $i
NAME=$(grep -o -e ':: .*::' $i | head -n1 | sed 's/:/*/g')
echo "$NAME"
DIFF=$(( $(date +%s) - $(date -d "$YEAR-$MONTH-$DAY $UPDATEHOUR:$UPDATEMIN:00" +%s) ))
echo "$DIFF"
if [[ "$DIFF" -lt 300000 ]]; then
arrNAME+=("$NAME\n")
# curl -H "Content-Type: application/json" -X POST -d "{\"embeds\": [{ \"color\": \"$ORANGE\", \"title\": \"The following mods on the server appear to be out of date.\n$arrNAME\", \"description\": \"Restarting the server to update all mods.\nPlease wait a minute before rejoining.\" }] }" $URL
# /opt/dizcord/restart.sh
#echo ""
fi
done
if [[ $(echo ${#arrNAME[@]}) -ge 1 ]]; then
curl -H "Content-Type: application/json" -X POST -d "{\"embeds\": [{ \"color\": \"16753920\", \"title\": \"The following mods on the server appear to be out of date.\", \"description\": \"\n${arrNAME[*]}\nRestarting the server to update all mods.\nPlease wait a minute before rejoining.\" }] }" $URL
fi