mirror of
https://github.com/dchakro/brewlog.git
synced 2026-05-17 10:12:16 -07:00
Merge branch 'develop'
This commit is contained in:
commit
33454db1e2
2 changed files with 30 additions and 13 deletions
10
brewlog.sh
10
brewlog.sh
|
|
@ -59,29 +59,36 @@ if [ ! -f "$LOGFILE" ] ; then
|
||||||
touch "$LOGFILE"
|
touch "$LOGFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ "$#" -eq 0 ]; then
|
||||||
HELP
|
HELP
|
||||||
|
exit 0;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" == "--help" ]; then
|
if [ "$1" == "--help" ]; then
|
||||||
HELP
|
HELP
|
||||||
|
exit 0;
|
||||||
elif [ "$1" == "--brew-help" ]; then
|
elif [ "$1" == "--brew-help" ]; then
|
||||||
brew help
|
brew help
|
||||||
|
exit 0;
|
||||||
elif [ "$1" == "version" ]; then
|
elif [ "$1" == "version" ]; then
|
||||||
VERSION
|
VERSION
|
||||||
|
exit 0;
|
||||||
elif [ "$1" == "tail" ]; then
|
elif [ "$1" == "tail" ]; then
|
||||||
if [ "$2" == "-n" ]; then
|
if [ "$2" == "-n" ]; then
|
||||||
# tail with specified number of lines
|
# tail with specified number of lines
|
||||||
tail -n "$3" "$LOGFILE"
|
tail -n "$3" "$LOGFILE"
|
||||||
|
exit 0;
|
||||||
else
|
else
|
||||||
# tail with 15 lines (default -n for tail is 10, I wanted more)
|
# tail with 15 lines (default -n for tail is 10, I wanted more)
|
||||||
tail -n 15 "$LOGFILE"
|
tail -n 15 "$LOGFILE"
|
||||||
|
exit 0;
|
||||||
fi
|
fi
|
||||||
elif [ "$1" == "archive" ]; then
|
elif [ "$1" == "archive" ]; then
|
||||||
if [ -f "$LOGFILE" ] ; then
|
if [ -f "$LOGFILE" ] ; then
|
||||||
# Archiving logfile i.e. brew.log is removed (will be created on next run)
|
# Archiving logfile i.e. brew.log is removed (will be created on next run)
|
||||||
xz -vf $LOGFILE
|
xz -vf $LOGFILE
|
||||||
mv "${LOGFILE}.xz" "$LOGFILE-$(date +'%Y%m%d').xz"
|
mv "${LOGFILE}.xz" "$LOGFILE-$(date +'%Y%m%d').xz"
|
||||||
|
exit 0;
|
||||||
else
|
else
|
||||||
echo "$LOGFILE doesn't exist"
|
echo "$LOGFILE doesn't exist"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -90,4 +97,5 @@ else
|
||||||
echo "brew $* :: $(date)" | tee -a "$LOGFILE"
|
echo "brew $* :: $(date)" | tee -a "$LOGFILE"
|
||||||
# logs both STDOUT and STDERR to $LOGFILE
|
# logs both STDOUT and STDERR to $LOGFILE
|
||||||
$(which brew) "$@" 2>&1 | tee -a "$LOGFILE"
|
$(which brew) "$@" 2>&1 | tee -a "$LOGFILE"
|
||||||
|
exit 0;
|
||||||
fi
|
fi
|
||||||
23
install.sh
23
install.sh
|
|
@ -1,17 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -w /usr/local/bin ]; then
|
if [ -w /usr/local/bin ]; then
|
||||||
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/brewlog.sh' > /usr/local/bin/brewlog
|
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/brewlog.sh' > /usr/local/bin/brewlog
|
||||||
chmod +x /usr/local/bin/brewlog
|
chmod +x /usr/local/bin/brewlog
|
||||||
else
|
else
|
||||||
sudo -s
|
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/brewlog.sh' >| brewlog.sh
|
||||||
if [ -w /usr/local/bin ]; then
|
echo "user $(whoami) cannot write to /usr/local/bin."
|
||||||
curl -sSL 'https://raw.githubusercontent.com/robocopAlpha/brewlog/master/brewlog.sh' > /usr/local/bin/brewlog
|
read -r -p "use sudo (y/N): " choice
|
||||||
chmod +x /usr/local/bin/brewlog
|
shopt -q nocasematch;
|
||||||
exit
|
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
|
sudo -k
|
||||||
else
|
else
|
||||||
echo "cannot write to /usr/local/bin".
|
echo "cannot install /usr/local/bin/brewlog without sudo rights"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
if [ "$flag" -eq "1" ]; then
|
||||||
|
shopt -s nocasematch
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue