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

Add error handling in install.sh #119

Merged
merged 4 commits into from
May 11, 2024
Merged

Conversation

stschulte
Copy link
Contributor

The install.sh script can be used to install the binary into /usr/bin. This script is really optimistic so this MR
adds at least two error checks:

  1. We should validate we were able to create the temporary directory. If this fails we may download the project to an unintended path and running rm -rf on something that may not be the expected temporary directory may lead to unexpected and dangerous results
  2. The script has to install the binary into /usr/bin and a normal user will not be able to do that. So the install.sh script performs the move with sudo. This assume that sudo is available on the system and the user actually has the necessary rights to perform the move. We now check the return value of the move instead.

The `install.sh` script should have the executable bit set in order to
be able to run `./install.sh` from the source directory.
The script install.sh creates a temporary directory in order to download
and extract files. We should validate this succeeds otherwise all
following steps can lead to strange results.

Especially since we run `rm -rf` on the temp directory we should ensure
we actually got a temporary directory and are not removing something
unrelated.
The install.sh script moves the downloaded and extracted binary to
`/usr/bin`. This may fail for different reasons, e.g.

- `sudo` may not be available on the system at all
- the current user has no sudo permissions to move the file

Before this change we still saw a success message. We should check if
the move actually succeeded.
@yorukot yorukot merged commit 5d92348 into yorukot:main May 11, 2024
1 check passed
@yorukot
Copy link
Owner

yorukot commented May 11, 2024

Thank you for your PR!
This really make this script more graet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants