-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
41 lines (33 loc) · 964 Bytes
/
build.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
#!/bin/bash
set -e
package="github.com/shappy0/ntui"
git_rev=$(git rev-parse --short HEAD)
version="v1.0.0"
output_bin="bin/ntui"
rm -rf "$output_bin"
echo "===> Bulding ntui"
# build code
go build -ldflags "-w -s -X $package/cmd.Version=$version -X $package/cmd.Commit=$git_rev" -o $output_bin main.go
# move binary in targeted folder
set -- "/usr/local/bin" "/usr/bin" "/opt/bin"
while [ -n "$1" ]; do
# Check if destination is in path.
if echo "$PATH"|grep "$1" -> /dev/null ; then
if cp $output_bin "$1" ; then
echo ""
echo "Done!"
exit 0
else
echo ""
echo "We'd like to move the ntui executable in $1. Please enter your password."
if sudo cp $output_bin "$1" ; then
echo ""
echo "Done!"
exit 0
fi
fi
fi
shift
done
echo "could not find supported destination path in \$PATH"
exit 1