updatescripts
This commit is contained in:
27
README.md
27
README.md
@@ -1,8 +1,8 @@
|
||||
# Shell Tools package
|
||||
|
||||
```
|
||||
_____ ___
|
||||
|_ _/ _ \
|
||||
_____ ___
|
||||
|_ _/ _ \
|
||||
| || (_) |
|
||||
|_| \__\_\
|
||||
```
|
||||
@@ -22,36 +22,35 @@ Many of the tools use common unix tools. Some extra tools are required. Here are
|
||||
the installation commands.
|
||||
|
||||
```
|
||||
sudo apt-get install mercurial sqlite3 python python-magic python-pip python-gtk2 sc \
|
||||
sudo apt-get install git sqlite3 python python-magic python-pip python-gtk2 sc \
|
||||
gnuplot wget vim rsync curl pv
|
||||
pip install csvkit ncsv
|
||||
pip2 install csvkit ncsv
|
||||
|
||||
```
|
||||
|
||||
## Installation without repository
|
||||
|
||||
```
|
||||
mkdir tools
|
||||
curl https://bitbucket.org/MoonQ/tools/get/tip.tar.gz | tar xz --strip 1 -C tools
|
||||
cd tools && source rc
|
||||
mkdir -p ~/lib/q-tools
|
||||
curl https://bitbucket.org/MoonQ/q-tools/get/HEAD.tar.gz | tar xz --strip 1 -C ~/lib/q-tools
|
||||
source ~/lib/q-tools/rc
|
||||
```
|
||||
Add the `rc` source in your ~/.bashrc
|
||||
Add the to your startup scripts:
|
||||
`echo '. ~/lib/q-tools/rc' >> ~/.bashrc`
|
||||
|
||||
## Installation in user home
|
||||
|
||||
```
|
||||
mkdir -p ~/lib
|
||||
hg clone https://bitbucket.org/MoonQ/tools ~/lib/tools
|
||||
. $HOME/lib/tools/rc
|
||||
git clone https://bitbucket.org/MoonQ/q-tools ~/lib/q-tools
|
||||
echo '. ~/lib/q-tools/rc' >> ~/.bashrc
|
||||
```
|
||||
|
||||
It is best to add the last line in your ~/.bashrc
|
||||
|
||||
|
||||
## Systemwide installation
|
||||
|
||||
```
|
||||
hg clone https://bitbucket.org/MoonQ/tools /usr/local/share/q-tools
|
||||
git clone https://bitbucket.org/MoonQ/q-tools /usr/local/share/q-tools
|
||||
echo '[ -e /usr/local/share/q-tools/rc ] && . /usr/local/share/q-tools/rc' >> /etc/profile.d/q-tools.sh
|
||||
ln -s /usr/local/share/q-tools/rc /etc/cron.weekly/q-tools
|
||||
```
|
||||
@@ -63,7 +62,7 @@ The last step ensures weekly updates
|
||||
|
||||
The Markslider slide viewer can be installed with:
|
||||
```
|
||||
pip2 install https://bitbucket.org/MoonQ/tools/raw/tip/reporting/markslider.tar.gz
|
||||
pip2 install https://bitbucket.org/MoonQ/q-tools/raw/HEAD/reporting/markslider.tar.gz
|
||||
```
|
||||
|
||||
|
||||
|
||||
21
rc
21
rc
@@ -1,12 +1,12 @@
|
||||
# source me to enable tools
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
darwin*)
|
||||
QTOOLSPATH=$( realpath $( dirname "$BASH_SOURCE" ) )
|
||||
;;
|
||||
*)
|
||||
QTOOLSPATH=$( readlink -f $( dirname "$BASH_SOURCE" ) )
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
||||
PATH=$PATH:"$QTOOLSPATH"/bin
|
||||
[[ "$1" = "-f" ]] && PATH="$QTOOLSPATH"/bin:$PATH
|
||||
@@ -33,14 +33,13 @@ function _q-tools-update-binary {
|
||||
# update self
|
||||
[[ -z "$QTOOLSPATH" ]] && return
|
||||
[[ -w "$QTOOLSPATH" ]] || return
|
||||
[[ -f "$QTOOLSPATH"/.hg_archival.txt ]] || return
|
||||
local foo
|
||||
echo "Updating with binary deletes the existing folder! sure? y/N"
|
||||
read foo
|
||||
read foo
|
||||
[[ "$foo" = y ]] || return
|
||||
rm -rf "$QTOOLSPATH"
|
||||
mkdir -p "$QTOOLSPATH"
|
||||
curl https://bitbucket.org/MoonQ/tools/get/tip.tar.gz | \
|
||||
curl https://bitbucket.org/MoonQ/q-tools/get/HEAD.tar.gz | \
|
||||
tar xz --strip 1 -C "$QTOOLSPATH"
|
||||
_q-tools-reload
|
||||
}
|
||||
@@ -49,14 +48,14 @@ function _self_update() {
|
||||
touch "$QTOOLSPATH"/.lastupdate
|
||||
pushd "$QTOOLSPATH" > /dev/null
|
||||
[[ "$1" = "-u" ]] && {
|
||||
hg pull -u https://bitbucket.org/MoonQ/tools
|
||||
git pull
|
||||
} || {
|
||||
timeout 10 hg pull -u https://bitbucket.org/MoonQ/tools > /dev/null 2>&1
|
||||
timeout 10 git pull > /dev/null 2>&1
|
||||
}
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
[[ "$1" = "-u" ]] && {
|
||||
[[ "$1" = "-u" ]] && {
|
||||
_self_update -u
|
||||
unset -f _self_update
|
||||
}
|
||||
@@ -64,16 +63,16 @@ function _self_update() {
|
||||
# if folder writable, if repository, if an interactive terminal, if not updated the last week
|
||||
TOOLS_TO_UPDATE=1
|
||||
[[ -w "$QTOOLSPATH" ]] || TOOLS_TO_UPDATE=0
|
||||
[[ -w "$QTOOLSPATH"/.hg ]] || TOOLS_TO_UPDATE=0
|
||||
[[ -w "$QTOOLSPATH"/.git ]] || TOOLS_TO_UPDATE=0
|
||||
[[ -t 0 ]] || TOOLS_TO_UPDATE=0
|
||||
[[ -t 1 ]] || TOOLS_TO_UPDATE=0
|
||||
[[ -t 2 ]] || TOOLS_TO_UPDATE=0
|
||||
[[ -f "$QTOOLSPATH"/.lastupdate ]] || touch -t 0101010101 "$QTOOLSPATH"/.lastupdate 2> /dev/null
|
||||
[[ -w "$QTOOLSPATH"/.lastupdate ]] || TOOLS_TO_UPDATE=0
|
||||
|
||||
if [ $TOOLS_TO_UPDATE -eq 1 ]; then
|
||||
if [ $TOOLS_TO_UPDATE -eq 1 ]; then
|
||||
TOOLS_LASTUPDATE=$( "$QTOOLSPATH"/files/file-age "$QTOOLSPATH"/.lastupdate d )
|
||||
[[ "$TOOLS_LASTUPDATE" -gt 7 ]] && _self_update
|
||||
[[ "$TOOLS_LASTUPDATE" -gt 7 ]] && _self_update
|
||||
unset TOOLS_LASTUPDATE
|
||||
fi
|
||||
unset TOOLS_TO_UPDATE
|
||||
|
||||
Reference in New Issue
Block a user