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

install: Improve linux ipfs install script #2504

Closed
wants to merge 1 commit into from

Conversation

mrshu
Copy link

@mrshu mrshu commented Mar 25, 2016

  • 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..

Signed-off-by: mr.Shu mr@shu.io



for binpath in $paths;
do
if [ -d "$binpath" ]; then
Copy link
Author

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.

@mrshu mrshu force-pushed the mrshu/linux-install-script branch from 8b6c78f to e4c644d Compare March 25, 2016 16:25
@whyrusleeping
Copy link
Member

It might be nice to have the user experience be something like:

ipfs will be installed to '$BEST_PATH_WE_FOUND'
Is that okay? [Y/n]

If they type n, we can ask them for a path that they would like it installed to, OR alternatively print out a list of possible locations (from $PATH) and have them select one by number.

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).

@mrshu
Copy link
Author

mrshu commented Mar 25, 2016

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 sudo and permissions, I have two comments:

  1. Checking whether a directory is writable is pretty difficult as just doing [ -w $DIR] might not always be enough. If we are OK with leaving a couple of edge cases uncovered, however, it might be feasible to do it this way.
  2. I am not sure if directly using sudo is the best way of dealing with this as we cannot be always sure that sudo will be installed on user's system. I believe informing the user would be a better option.

@whyrusleeping
Copy link
Member

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

@mrshu mrshu force-pushed the mrshu/linux-install-script branch from e4c644d to 6216ade Compare March 25, 2016 23:01
@mrshu
Copy link
Author

mrshu commented Mar 25, 2016

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 $PATH and the script is not ran under root a note is printed. By doing this a huge portion of your desired UX is implemented while the script is still pretty short and clean. I believe it is a tremendous improvement over its current state.

Please do let me know if you have additional feedback.

@whyrusleeping
Copy link
Member

@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
Copy link
Contributor

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.

@chriscool
Copy link
Contributor

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>
@mrshu mrshu force-pushed the mrshu/linux-install-script branch from 6216ade to c26ebbc Compare March 28, 2016 20:09
@mrshu
Copy link
Author

mrshu commented Mar 28, 2016

Thanks for the comment @chriscool

@whyrusleeping no worries, feel free to review it whenever you find some time to spare!

@mrshu
Copy link
Author

mrshu commented Apr 10, 2016

@whyrusleeping There is no rush here, just checking if you have any further comments/feedback.

@whyrusleeping
Copy link
Member

@mrshu just tried this out, it looks good :) thank you!
I'd like to have @jbenet take a look at this before we merge it, he cares a lot about the install process


if [ ! -f "$bin" ]; then
echo "The '$bin' binary was not found in the current directory."
echo "There is nothing to install."
Copy link
Member

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."

Copy link
Member

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.

Copy link
Member

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.

@jbenet
Copy link
Member

jbenet commented Jul 7, 2016

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.

@Kubuxu Kubuxu mentioned this pull request Sep 7, 2016
esac
done

if mv "$bin" "$binpath"; then
Copy link
Contributor

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.

Copy link
Member

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)

Copy link
Member

Choose a reason for hiding this comment

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

mv "$bin" "$binpath/$bin"

Copy link
Contributor

@kulla kulla Sep 8, 2016

Choose a reason for hiding this comment

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

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... (cf. #3194 (comment))

Copy link
Member

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
.

@kulla
Copy link
Contributor

kulla commented Sep 7, 2016

I have a more general question: Is it really necessary to check all directories in $PATH?! Concerning KISS we shall only do this, when this is really necessary. I mean for most users the directory /usr/local/bin exists and will be used as the target directory for this script so that there is no difference with the current version of install.sh. Are there any unix systems without /usr/local/bin?! What are your opinions?

@Kubuxu
Copy link
Member

Kubuxu commented Sep 7, 2016

Arch for example doesn't have /usr/local/bin by default but most people will add it as most installers use /usr/local/bin either way.

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)"
Copy link
Member

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

@jbenet
Copy link
Member

jbenet commented Sep 7, 2016

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 install.sh it means installing a binary is mysterious to you. A non-totally-obvious script will make matters much worse. I think the script in this PR is too complicated.

kulla added a commit to kulla/go-ipfs that referenced this pull request Sep 8, 2016
Implement proposal of the comment
ipfs#2504 (comment)

License: MIT
Signed-off-by: Stephan Kulla <git.mail@kulla.me>
kulla added a commit to kulla/go-ipfs that referenced this pull request Sep 8, 2016
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>
kulla added a commit to kulla/go-ipfs that referenced this pull request Sep 8, 2016
Implement proposal of the comment
ipfs#2504 (comment)

License: MIT
Signed-off-by: Stephan Kulla <git.mail@kulla.me>
kulla added a commit to kulla/go-ipfs that referenced this pull request Sep 8, 2016
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>
@Kubuxu Kubuxu added the status/deferred Conscious decision to pause or backlog label Sep 29, 2016
@whyrusleeping
Copy link
Member

closing in favor of #3194

@whyrusleeping whyrusleeping removed the status/deferred Conscious decision to pause or backlog label Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/review Needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants