-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadd-map
More file actions
executable file
·54 lines (41 loc) · 1.58 KB
/
add-map
File metadata and controls
executable file
·54 lines (41 loc) · 1.58 KB
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
#!/usr/bin/env bash
source ~/unique-admin/.env
cd ~
if [[ $# -ne 3 ]]; then
echo "usage: add-map <map> <category> <mapper>"
exit 1
fi
map=$1
category=$2
mapper=$3
forbidden='["\]'
if [[ $map =~ $forbidden || $mapper =~ $forbidden ]]; then
echo "Map and mapper may not contain double quote and backslash"
exit 1
fi
if [[ $category != @(Short|Middle|Long Easy|Long Advanced|Long Hard|Fastcap) ]]; then
echo "Invalid category"
exit 1
fi
if [[ ! -f "$map.map" || ! -f "$map.png" ]]; then
echo "$map.map or $map.png is missing"
exit 1
fi
python3 unique-admin/validate_map.py "$map.map" "$category" || exit 1
cp "$map.map" "unique-maps/maps/$map.map"
cp "$map.png" "unique-maps/screenshots/$map.png"
./map_convert_07 "$map.map" "unique-maps/maps7/$map.map"
resetfile=$(
[[ $category != "Fastcap" ]] && echo "reset_race.cfg" ||
{ [[ $map == *_no_wpns ]] && echo "reset_fastcap_no_wpns.cfg" || echo "reset_fastcap.cfg"; }
)
ln -sf "../$resetfile" "unique-maps/maps/$map.map.cfg"
mariadb -D urace -e "INSERT INTO record_maps (Map, Server, Mapper) VALUES (\"$map\", \"$category\", \"$mapper\") ON DUPLICATE KEY UPDATE Server = VALUES(Server), Mapper = VALUES(Mapper);"
unique-admin/generate-votes
cd unique-maps
git add .
git commit -m "Add $map"
git push
jq -n --arg map "$map" --arg mapper "$mapper" --arg category "$category" \
'{content: "[\($map|@html)](https://uniqueclan.net/map/\($map|@uri)) by [\($mapper|@html)](https://uniqueclan.net/mapper/\($mapper|@uri)) released on \($category)"}' |
curl -X POST -H "Content-Type: application/json" -d @- "$WEBHOOK_MAP_RELEASES_URL"