From 5eaabf4716516047d26fcd7f0629b12e379bf28b Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Thu, 2 Feb 2017 22:35:24 -0800 Subject: [PATCH] Basic tool installer. --- bin/install_tool | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 bin/install_tool diff --git a/bin/install_tool b/bin/install_tool new file mode 100755 index 0000000..d0fe696 --- /dev/null +++ b/bin/install_tool @@ -0,0 +1,67 @@ +#!/bin/bash + +set -ue + +REINSTALL=0 + +while getopts -- "-:" a ; do + case "${a}" in + -) + case "${OPTARG}" in + reinstall) + REINSTALL=1 + ;; + *) + echo "Unknown long option ${OPTARG}" >/dev/stderr + exit 1 + ;; + esac + esac +done + +if [ $# -ne 1 ] ; then + echo "Usage: ${0} " >/dev/stderr + exit 1 +fi +TOOL=${1} + +function install_pkgs { + if [ `id -u` -ne "0" ] ; then + echo "Unable to install packages, please ensure these are installed." >/dev/stderr + echo $* + return 0 + fi + apt-get -y install $* +} + +DESTDIR="${HOME}/tools/${TOOL}" + +if [ -d ${DESTDIR} ] ; then + if [ ${REINSTALL} -eq 1 ] ; then + rm -ri ${DESTDIR} + else + echo "${DESTDIR} exists but not reinstalling." >/dev/stderr + exit 1 + fi +fi + +mkdir -p ${DESTDIR} + +case ${TOOL} in + john) + install_pkgs libssl-dev git build-essential yasm libgmp-dev libpcap-dev \ + pkg-config libbz2-dev libopenmpi-dev openmpi-bin libnss-dev \ + libkrb5-dev libgmp-dev + jtemp=`mktemp -d` + git clone https://github.com/magnumripper/JohnTheRipper.git ${jtemp}/john + cd ${jtemp}/john/src + ./configure && make -sj2 + cp -r ${jtemp}/john/run/* ${DESTDIR} + rm -rf ${jtemp} + ;; + *) + echo "Unknown tool: ${TOOL}" >/dev/stderr + rmdir ${DESTDIR} + exit 1 + ;; +esac