Added inv-alias and hosto

This commit is contained in:
2022-02-12 21:21:42 +01:00
parent dfe5db0360
commit 5a0f72b41a
3 changed files with 174 additions and 0 deletions

31
scripts/bin/hosto Executable file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
POSITIONAL_ARGS=()
INVENTORY_FILE="$(pwd)/inventory"
while [[ $# -gt 0 ]]; do
case $1 in
-i|--inv-file)
INVENTORY_FILE="$2"
shift
shift
;;
-*|--*)
echo "hosto: Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1")
shift
;;
esac
done
if [ -f $INVENTORY_FILE ]; then
sudo inv-alias add $INVENTORY_FILE
eval "${POSITIONAL_ARGS[@]}"
sudo inv-alias rm $INVENTORY_FILE
else
echo "hosto: Could not find inventory file in $PWD"
eval "${POSITIONAL_ARGS[@]}"
fi