提交 81e40de5 作者: Stephan Kulla

install.sh: Recommend using sudo on error.

Show error message that the user shall try running this script with sudo
in case write permissions are missing. Implement proposal of comment
https://github.com/ipfs/go-ipfs/pull/3194#issuecomment-245376993

License: MIT
Signed-off-by: 's avatarStephan Kulla <git.mail@kulla.me>
上级 f00b8d58
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
bin=ipfs bin=ipfs
binpaths="/usr/local/bin /usr/bin" 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. # this script is currently brain dead.
# it merely tries two locations. # it merely tries two locations.
# in the future maybe use value of $PATH. # in the future maybe use value of $PATH.
...@@ -11,8 +15,21 @@ for binpath in $binpaths; do ...@@ -11,8 +15,21 @@ for binpath in $binpaths; do
if mv -t "$binpath" "$bin" 2> /dev/null; then if mv -t "$binpath" "$bin" 2> /dev/null; then
echo "Moved $bin to $binpath" echo "Moved $bin to $binpath"
exit 0 exit 0
else
if [ -d "$binpath" -a ! -w "$binpath" ]; then
is_write_perm_missing=1
fi
fi fi
done 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 exit 1
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论