-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_executables.sh
51 lines (41 loc) · 1.3 KB
/
build_executables.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
#!/usr/bin/env bash
package="github.com/mutl3y/prtg_client_util"
if [[ -z "$package" ]]; then
echo "usage: $0 <package-name>"
exit 1
fi
package_split=(${package//\// })
package_name=${package_split[-1]}
platforms=("windows/amd64" "windows/386" "darwin/amd64" "linux/amd64")
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=releases/$package_name'-'$GOOS'-'$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name $package
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution…'
exit 1
fi
done
cp releases/prtg_client_util-windows-amd64.exe "/c/Program Files (x86)/PRTG Network Monitor/Custom Sensors/EXEXML/"
function myscp() {
scp -i /c/Users/mark/.ssh/mark releases/prtg_client_util-linux-amd64 mark@linuxserver:/var/prtg/scriptsxml
}
tries=0
ssh -i /c/Users/mark/.ssh/mark mark@linuxserver sudo rm /var/prtg/scriptsxml/prtg_client_util-linux-amd64
myscp; while [ $? -ne 0 ]
do
sleep 0.5
myscp
let tries=tries+1
if [ ${tries} -ge 20 ]; then
break
fi
done
ssh -i /c/Users/mark/.ssh/mark mark@linuxserver sudo chmod 777 /var/prtg/scriptsxml/*
echo Completed uploads