#!/bin/bash # # Installation script for GitHub gist 188e1731135874d7d69a2f1b9711f9a8 # (screenrc with a decent-looking caption / hardstatus line, including LSF # job status) # # trace all operations so user can see what's happening set -x GIST='https://gist.github.com/ernstki/188e1731135874d7d69a2f1b9711f9a8' GISTRAW="$GIST/raw" SCREENRC='screenrc-with-lsf-support' SCRIPT='zz_bjob_status.sh' # create ~/bin and add it to user's PATH environment variable test -d ~/bin || mkdir ~/bin grep -q "$HOME/bin" <<<"$PATH" || \ echo -e "\n# add ~/bin to PATH\nexport PATH=\"\$PATH:\$HOME/bin\"" >> ~/.bashrc # make a backup of an existing ~/.screenrc (could be file or symlink) test -r ~/.screenrc && \mv ~/.screenrc ~/.screenrc.bak-$(date +%Y%m%d) # fetch the helper script, then the .screenrc GETTER='curl -sLOJ' which curl &>/dev/null || GETTER='wget' ( cd ~/bin; $GETTER $GISTRAW/$SCRIPT; \mv $SCRIPT ${SCRIPT/zz_/} ) SCRIPT=${SCRIPT/zz_/} chmod a+x ~/bin/$SCRIPT ( cd; $GETTER $GISTRAW/$SCREENRC; \mv $SCREENRC .screenrc ) # stop tracing set +x if test -x ~/bin/$SCRIPT -a -f ~/.screenrc; then source ~/.bashrc unset GIST GISTRAW SCREENRC SCRIPT echo -e "\nOK! Restart 'screen' (if necessary) for changes to take effect." else echo -e "\nOh noes. Something went wrong with the installation." >&2 fi # end