@cryptotaxi247 / kubo / commits / a049ba9d1

fix: installation without sudo (#8715)

* fix: installation without sudo I think it's good practice that users don't need to run `sudo` to install something just to try it out. With this change, the local bin directory is tried first, which usually is also in the `PATH`. This way the installation script can be run without `sudo` and should still work. * fix: try local path last and support spaces in $HOME Try the `$HOME/.local/bin` path last, so that the script is backwards compatible. Also make sure that it works even if there are spaces in the directory set by `$HOME`.

Volker Mische committed Feb 16, 2022 at 13:54 UTC a049ba9d1740f2aa6096dd923c32f938fdfac5ae
1 file changed +4 -2
cmd/ipfs/dist/install.sh
+4 -2
@@ -6,13 +6,15 @@
6 INSTALL_DIR=$(dirname $0)
7
8 bin="$INSTALL_DIR/ipfs"
9 -binpaths="/usr/local/bin /usr/bin"
9 +binpaths='/usr/local/bin /usr/bin $HOME/.local/bin'
10
11 # This variable contains a nonzero length string in case the script fails
12 # because of missing write permissions.
13 is_write_perm_missing=""
14
15 -for binpath in $binpaths; do
15 +for raw in $binpaths; do
16 + # Expand the $HOME variable.
17 + binpath=$(eval echo "$raw")
18 if mv "$bin" "$binpath/ipfs" ; then
19 echo "Moved $bin to $binpath"
20 exit 0