forked from irinazheltisheva/powergate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.tmpl
More file actions
executable file
·39 lines (31 loc) · 1015 Bytes
/
install.tmpl
File metadata and controls
executable file
·39 lines (31 loc) · 1015 Bytes
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
#!/usr/bin/env bash
set -Eeuo pipefail
# From https://github.com/ipfs/go-ipfs/blob/ccef991a194beaedf009b1d0702b1150db3da0a6/cmd/ipfs/dist/install.sh
#
# Installation script for powergate. It tries to move $bin in one of the
# directories stored in $binpaths.
INSTALL_DIR="$(dirname "$0")"
file="$INSTALL_DIR/{{ .Env.POW_FILE }}"
binpaths="/usr/local/bin /usr/bin"
# This variable contains a nonzero length string in case the script fails
# because of missing write permissions.
is_write_perm_missing=""
for binpath in $binpaths; do
if mv "$file" "$binpath/$file" 2>/dev/null; then
echo "Moved $file to $binpath"
exit 0
else
if test -d "$binpath" && ! test -w "$binpath"; then
is_write_perm_missing=1
fi
fi
done
echo "We cannot install $file in one of the directories $binpaths"
if test -n "$is_write_perm_missing"; then
echo "It seems that we do not have the necessary write permissions."
echo "Perhaps try running this script as a privileged user:"
echo
echo " sudo $0"
echo
fi
exit 1