ctf-tools/bin/manage-tools

80 lines
1.1 KiB
Text
Raw Normal View History

#!/bin/bash -e
2015-05-08 02:27:54 +00:00
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
2015-05-08 02:27:54 +00:00
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"
2015-05-08 02:27:54 +00:00
[ -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