mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
fix: change default install directory to /usr/local/bin
- Change default DIR from /home/jmeiracorbal/.local/bin to /usr/local/bin, doesn't work if is not present on PATH. - Add permission or checks if sudo is required for the installation. - Update README.md to reflect the new default directory. - Ensure directory creation if it doesn't exist.
This commit is contained in:
parent
bedde4a037
commit
819fe8fe35
2 changed files with 39 additions and 4 deletions
|
|
@ -131,7 +131,7 @@ Automated install/update, don't forget to always verify what you're piping into
|
|||
```sh
|
||||
curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash
|
||||
```
|
||||
The script installs downloaded binary to `$HOME/.local/bin` directory by default, but it can be changed by setting `DIR` environment variable.
|
||||
The script installs downloaded binary to `/usr/local/bin` directory by default, but it can be changed by setting `DIR` environment variable.
|
||||
|
||||
### Go
|
||||
|
||||
|
|
@ -245,6 +245,12 @@ You can also use `go run main.go` to compile and run in one go (pun definitely i
|
|||
|
||||
Call `lazydocker` in your terminal. I personally use this a lot so I've made an alias for it like so:
|
||||
|
||||
```
|
||||
echo "alias lzd='lazydocker'" >> ~/.bashrc
|
||||
```
|
||||
|
||||
Or zsh:
|
||||
|
||||
```
|
||||
echo "alias lzd='lazydocker'" >> ~/.zshrc
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,7 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
# allow specifying different destination directory
|
||||
DIR="${DIR:-"$HOME/.local/bin"}"
|
||||
# change the default destination directory to be executable as a command
|
||||
DIR="${DIR:-"/usr/local/bin"}"
|
||||
|
||||
# check if requires sudo when the directory is not the default value
|
||||
if [ ! -w "$DIR" ]; then
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "Error: You need permissions to write in $DIR"
|
||||
echo "Run the script with sudo or define DIR as a directory with write permissions:"
|
||||
echo " sudo $0"
|
||||
echo " DIR=\"\$HOME/.local/bin\" $0"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# map different architecture variations to the available binaries
|
||||
ARCH=$(uname -m)
|
||||
|
|
@ -20,5 +31,23 @@ GITHUB_URL="https://github.com/jesseduffield/lazydocker/releases/download/${GITH
|
|||
# install/update the local binary
|
||||
curl -L -o lazydocker.tar.gz $GITHUB_URL
|
||||
tar xzvf lazydocker.tar.gz lazydocker
|
||||
install -Dm 755 lazydocker -t "$DIR"
|
||||
|
||||
# create the directory if it doesn't exist, but requires sudo
|
||||
if [ ! -d "$DIR" ]; then
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
mkdir -p "$DIR"
|
||||
else
|
||||
sudo mkdir -p "$DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
# install with correct permissions
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
install -Dm 755 lazydocker -t "$DIR"
|
||||
else
|
||||
sudo install -Dm 755 lazydocker -t "$DIR"
|
||||
fi
|
||||
|
||||
rm lazydocker lazydocker.tar.gz
|
||||
|
||||
echo "lazydocker installed successfully in $DIR"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue