Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring install.sh #3194

Merged
merged 8 commits into from
Sep 9, 2016
22 changes: 10 additions & 12 deletions cmd/ipfs/dist/install.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#!/bin/sh

bin=ipfs
binpaths="/usr/local/bin /usr/bin"

# this script is currently brain dead.
# it merely tries two locations.
# in the future maybe use value of $PATH.

binpath=/usr/local/bin
if [ -d "$binpath" ]; then
mv "$bin" "$binpath/$bin"
echo "installed $binpath/$bin"
exit 0
fi
for binpath in $binpaths; do
if [ -d "$binpath" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to also check [ -w "$binpath" ] to see if we're allowed to write in the given directory.

mv "$bin" "$binpath/$bin"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if this succeeds or not and not print 'installed X' if it fails.

echo "installed $binpath/$bin"
exit 0
fi
done

binpath=/usr/bin
if [ -d "$binpath" ]; then
mv "$bin" "$binpath/$bin"
echo "installed $binpath/$bin"
exit 0
fi
echo "cannot install $bin in one of the directories $binpaths"
exit 1