mirror of
https://github.com/dchakro/brewlog.git
synced 2026-05-17 10:12:16 -07:00
Modifications
- proper exit codes in brewlog - check if /usr/local/bin is writable (and use sudo [user permission])
This commit is contained in:
parent
7228492a12
commit
da0cd940ed
2 changed files with 30 additions and 13 deletions
33
install.sh
33
install.sh
|
|
@ -1,17 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -w /usr/local/bin ]; then
|
||||
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/brewlog.sh' > /usr/local/bin/brewlog
|
||||
chmod +x /usr/local/bin/brewlog
|
||||
else
|
||||
sudo -s
|
||||
if [ -w /usr/local/bin ]; then
|
||||
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/brewlog.sh' > /usr/local/bin/brewlog
|
||||
chmod +x /usr/local/bin/brewlog
|
||||
exit
|
||||
sudo -k
|
||||
else
|
||||
echo "cannot write to /usr/local/bin".
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/brewlog.sh' >| brewlog.sh
|
||||
echo "user $(whoami) cannot write to /usr/local/bin."
|
||||
read -r -p "use sudo (y/N): " choice
|
||||
shopt -q nocasematch;
|
||||
if [ "$?" -eq "1" ]; then
|
||||
shopt -s nocasematch
|
||||
flag=1
|
||||
fi
|
||||
if [[ "$choice" =~ ^(yes|y)$ ]]
|
||||
then
|
||||
sudo mv brewlog.sh /usr/local/bin/brewlog
|
||||
sudo chmod +x /usr/local/bin/brewlog
|
||||
sudo -k
|
||||
else
|
||||
echo "cannot install /usr/local/bin/brewlog without sudo rights"
|
||||
exit 1;
|
||||
fi
|
||||
if [ "$flag" -eq "1" ]; then
|
||||
shopt -s nocasematch
|
||||
fi
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue