-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild
executable file
·93 lines (75 loc) · 2.06 KB
/
build
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
#!/usr/bin/env bash
set -e
cargo build --release
cp "${CARGO_BUILD_TARGET_DIR:-./target}/riscv32-kartoffel-bot/release/kartoffel-bot" kartoffel
if [[ "$1" == "--copy" ]]; then
# Mac
if [[ -x "$(command -v pbcopy)" ]]; then
base64 -i kartoffel | pbcopy
exit
fi
# WSL
if [[ -x "$(command -v clip.exe)" ]]; then
base64 kartoffel | clip.exe
exit
fi
# Wayland
if [[ -x "$(command -v wl-copy)" ]]; then
base64 kartoffel | wl-copy
exit
fi
# Xorg
if [[ -x "$(command -v xclip)" ]]; then
base64 kartoffel | xclip -sel clip
exit
fi
echo "err: can't figure out how to copy stuff to clipboard"
echo ""
echo "if you have a moment, please report it at:"
echo " https://github.com/patryk27/kartoffel"
echo ""
echo "... and provide a bit of information on your setup (what's your system, desktop manager etc.)"
exit 1
fi
if [[ "$1" == "--upload" ]]; then
if [[ -z "$2" ]]; then
echo "err: missing session id"
echo
echo "usage:"
echo " ./build --upload <sessionId>"
echo
echo "e.g.:"
echo " ./build --upload 1234-1234-1234-1234"
exit 1
fi
status=$(
curl \
-s \
-o /dev/null \
-w "%{http_code}" \
-X POST \
-T kartoffel \
"https://kartoffels.pwy.io/api/sessions/$2/bots"
)
case "$status" in
"201")
echo "ok, bot uploaded"
;;
"404")
echo "err: upload not expected, no such session exists"
;;
"410")
echo "err: upload not expected - open the uploading dialog in game and try again"
;;
*)
echo "err: couldn't upload the bot - retrying with more verbosity"
echo
sleep 2
curl \
-v \
-X POST \
-T kartoffel \
"https://kartoffels.pwy.io/api/sessions/$2/bots"
;;
esac
fi