ctf-tools/bin/manage-tools

79 lines
1.1 KiB
Bash
Executable file

#!/bin/bash -e
ALLOW_SUDO=0
while [[ $1 == -* ]]
do
case $1 in
-h)
cat <<END
Usage: $0 [-s] (list|setup|install|uninstall|bin) tool
Where:
-s allow running things with sudo (i.e., to install debs)
tool the name of the tool
END
exit
;;
-s)
ALLOW_SUDO=1
;;
*)
;;
esac
shift
done
ACTION=$1
TOOL=$2
cd $(dirname "${BASH_SOURCE[0]}")/..
case $ACTION in
setup)
echo "PATH=\"$PWD/bin:\$PATH\"" >> ~/.bashrc
;;
list)
for t in *
do
[ ! -e "$t/install" ] && continue
echo $t
done
;;
bin)
if [ -n "$TOOL" ]
then
cd bin
ln -sf ../$TOOL/bin/* .
echo "TOOLS | $TOOL | bin symlinks updated"
cd ..
else
for t in $(bin/manage-tools list)
do
bin/manage-tools bin $t
done
fi
;;
install)
cd $TOOL
echo "TOOLS | $TOOL | starting install"
[ -x ./install-root -a "$ALLOW_SUDO" -eq 1 ] && sudo ./install-root
./install
echo "TOOLS | $TOOL | install finished"
cd ..
$0 bin $TOOL
;;
uninstall)
cd $TOOL
[ -x ./uninstall ] && ./uninstall
git clean -dffx .
echo "TOOLS | $TOOL | uninstall finished"
cd ..
;;
*)
echo "TOOLS | ERROR | unknown action $ACTION"
;;
esac