Skip to content

Commit

Permalink
install.sh: Recommend using sudo on error.
Browse files Browse the repository at this point in the history
Show error message that the user shall try running this script with sudo
in case write permissions are missing. Implement proposal of comment
#3194 (comment)

License: MIT
Signed-off-by: Stephan Kulla <git.mail@kulla.me>
  • Loading branch information
kulla committed Sep 8, 2016
1 parent 0b6ef03 commit d6b6b20
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/ipfs/dist/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
bin=ipfs
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=""

# this script is currently brain dead.
# it merely tries two locations.
# in the future maybe use value of $PATH.
Expand All @@ -11,8 +15,21 @@ for binpath in $binpaths; do
if mv -t "$binpath" "$bin" 2> /dev/null; then
echo "Moved $bin into $binpath"
exit 0
else
if [ -d "$binpath" -a ! -w "$binpath" ]; then
is_write_perm_missing=1
fi
fi
done

echo "cannot install $bin in one of the directories $binpaths"
echo "We cannot install $bin in one of the directories $binpaths"

if [ -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

0 comments on commit d6b6b20

Please sign in to comment.