-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
install: Improve linux ipfs install script #2504
Conversation
|
||
for binpath in $paths; | ||
do | ||
if [ -d "$binpath" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbenet At this point we might want to ask the user whether they would really like to install ifps
to given directory $binpath
. I am sure there are people who would like to skip /usr/bin/local
and rather install ipfs
to ~/bin
for instance.
8b6c78f
to
e4c644d
Compare
It might be nice to have the user experience be something like:
If they type We could also check permissions, and if they need sudo to install it in the selected location, we can use sudo (so it prompts them for a password). |
Thanks for the comments @whyrusleeping! The yes/no dialog is something that I had in mind in my comment. I'll try to figure out how update my PR to facilitate your vision (as it looks pretty solid and way better than what I previously had in mind). With regards to
|
re 1, I think have a few edge cases is fine for now, as long as we can still fail gracefully. As for 2, youre likely right. maybe something like "you must run this command with sudo to install there" would be better |
e4c644d
to
6216ade
Compare
Thanks @whyrusleeping, I implemented all of your suggestions, except for selecting a directory by number/user input as that would be very difficult to implement correctly. In the current setup the user sees the status of each directory in their Please do let me know if you have additional feedback. |
@mrshu awesome, thanks! I likely won't get to reviewing PR's until tuesday or wednesday though, just a heads up! |
if [ -d "$binpath" ]; then | ||
mv "$bin" "$binpath/$bin" | ||
echo "installed $binpath/$bin" | ||
if [ -z $bestpath ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$bestpath should be quoted here.
Except the above comment, this LGTM. |
* Improve linux ipfs install script by trying to install the ipfs binary to every directory in $PATH, starting with `/usr/local/bin` and `/usr/bin` which were used in the previous version of this script.. License: MIT Signed-off-by: mr.Shu <mr@shu.io>
6216ade
to
c26ebbc
Compare
Thanks for the comment @chriscool @whyrusleeping no worries, feel free to review it whenever you find some time to spare! |
@whyrusleeping There is no rush here, just checking if you have any further comments/feedback. |
|
||
if [ ! -f "$bin" ]; then | ||
echo "The '$bin' binary was not found in the current directory." | ||
echo "There is nothing to install." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should exaplain more, and suggest a fixing action:
echo "Perhaps you have already installed this binary?"
echo "If not, you can try extracting the archive again, which should have the '$bin' binary."
echo "If you no longer have the archive, you may have to download it again from its origin."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- a more advanced version could also test the binary is installed, it just needs the right version to know. could get the version from the readme.
- if the versions match, the language should still only say
"it seems '$bin $version' is already installed"
. Operative word "seems". we cannot be sure, as some builds will be different but have exact same version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could check the hash and/or use diff
.
Sorry for my delay in reviewing this. i've contributed comments to make this a smoother install experience. it is already much smoother (thanks!) but important to make sure errors are not cryptic and are actionable. |
esac | ||
done | ||
|
||
if mv "$bin" "$binpath"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend changing mv
into cp
. Cf. PR #3194 comment 3. I also would use the -t
parameter. So I would write
cp -t "$binpath" "$bin"
By this the target directory is stated explicitly. There might be the (very very rare :-) ) case that for $binpath=/usr/local/bin
the directory /usr/local
is empty and thus the ipfs
binary is stored in the file /usr/local/bin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- please use
mv
. it makes sure the binary did indeed go somewhere. People may be confused by the continued presence of the binary. - +1 to removing the bug that might wind up with
ipfs
moved to a file named/ipfs/local/bin
(maybe just be explicit with the filename)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mv "$bin" "$binpath/$bin"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(cf. #3194 (comment))mv "$bin" "$binpath/$bin"
also has his (very rare) pitfalls. If /usr/local/bin/ipfs
is a directory, then for binpath=/usr/local/bin
and bin=ipfs
the file ipfs
will be stored as /usr/local/bin/ipfs/ipfs
. Therefore I guess mv -t "$binpath" "$bin"
is the better command...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yep
On Thu, Sep 8, 2016 at 10:02 AM Stephan Kulla notifications@github.com
wrote:
In cmd/ipfs/dist/install.sh
#2504 (comment):+while true; do
- read -p "Is that okay? [Y/n] " yn
Default to yes on empty response
- if [ -z "$yn" ]; then
yn="Y"
- fi
- case $yn in
[Yy]\* ) break;;
[Nn]\* ) exit 0;;
\* ) echo "Please answer yes or no.";;
- esac
+done
+if mv "$bin" "$binpath"; then
mv "$bin" "$binpath/$bin" also has his (very rare) pitfalls. If
/usr/local/bin/ipfs is a directory, then for binpath=/usr/local/bin and
bin=ipfs the file ipfs will be stored as /usr/local/bin/ipfs/ipfs.
Therefore I guess mv -t "$binpath" "$bin" is the better command...—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
https://github.com/ipfs/go-ipfs/pull/2504/files/c26ebbcf757b4a5e30f467b6db6849a2c4a81263#r77961445,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAIcoYrcGry4L2APQNt7TfytSPz7nTimks5qn8ERgaJpZM4H42aR
.
I have a more general question: Is it really necessary to check all directories in |
Arch for example doesn't have /usr/local/bin by default but most people will add it as most installers use |
else | ||
echo "We were unable to install $bin into $binpath" | ||
echo "Please make sure that you can write into $binpath" | ||
echo "(possibly by running this script as a privileged user)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"privileged user" is not obvious to many people. it should instead say:
Perhaps try running: sudo $0
The install script should be very simple. Meaning no more than a few (<20?) clear lines of code. If you need to use such an |
Implement proposal of the comment ipfs#2504 (comment) License: MIT Signed-off-by: Stephan Kulla <git.mail@kulla.me>
I removed the comment about using $PATH since it leads to long installation scripts (which violates the KISS principle). Cf. the discussion on ipfs#2504 License: MIT Signed-off-by: Stephan Kulla <git.mail@kulla.me>
Implement proposal of the comment ipfs#2504 (comment) License: MIT Signed-off-by: Stephan Kulla <git.mail@kulla.me>
I removed the comment about using $PATH since it leads to long installation scripts (which violates the KISS principle). Cf. the discussion on ipfs#2504 License: MIT Signed-off-by: Stephan Kulla <git.mail@kulla.me>
closing in favor of #3194 |
to every directory in $PATH, starting with
/usr/local/bin
and/usr/bin
which were used in the previous version of this script..Signed-off-by: mr.Shu mr@shu.io