Joey Hafner
97e4cc547a
1. homelab [Gitea](https://gitea.jafner.tools/Jafner/homelab), [Github (docker_config)](https://github.com/Jafner/docker_config), [Github (wiki)](https://github.com/Jafner/wiki), [Github (cloud_tools)](https://github.com/Jafner/cloud_tools), [Github (self-hosting)](https://github.com/Jafner/self-hosting). - Rename? Jafner.net? Wouldn't that be `Jafner/Jafner.net/Jafner.net`? 2. Jafner.dev [Github](https://github.com/Jafner/Jafner.dev). 3. dotfiles [Gitea](https://gitea.jafner.tools/Jafner/dotfiles), [Github](https://github.com/Jafner/dotfiles). 4. nvgm [Gitea](https://gitea.jafner.tools/Jafner/nvgm) 5. pamidi [Gitea](https://gitea.jafner.tools/Jafner/pamidi), [Github](https://github.com/Jafner/pamidi) 6. docker-llm-amd [Gitea](https://gitea.jafner.tools/Jafner/docker-llm-amd) 7. doradash [Gitea](https://gitea.jafner.tools/Jafner/doradash) 8. clip-it-and-ship-it [Gitea (PyClipIt)](https://gitea.jafner.tools/Jafner/PyClipIt), [Github](https://github.com/Jafner/clip-it-and-ship-it). 9. razer battery led [Github](https://github.com/Jafner/Razer-BatteryLevelRGB) 10. 5etools-docker [Github](https://github.com/Jafner/5etools-docker) 11. jafner-homebrew [Github](https://github.com/Jafner/jafner-homebrew)
77 lines
2.4 KiB
Bash
77 lines
2.4 KiB
Bash
function initialize {
|
|
USER="admin"
|
|
HOSTNAME=$(hostname)
|
|
STACKS_DIRECTORY="/home/$USER/homelab/$HOSTNAME/config"
|
|
|
|
echo "Initialized with:"
|
|
echo "USER=$USER"
|
|
echo "HOSTNAME=$HOSTNAME"
|
|
echo "STACKS_DIRECTORY=$STACKS_DIRECTORY"
|
|
}
|
|
|
|
function main {
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
# parse global flags
|
|
-n|--nas-only) NAS_ONLY=true; shift ;;
|
|
-l|--lint) LINT=true; shift ;;
|
|
-p|--path) STACKS_DIRECTORY="$2"; shift; shift ;;
|
|
-v|--verbose) VERBOSE=true; shift ;;
|
|
# parse command
|
|
up*) COMMAND="docker-compose up -d"; shift;
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-f|--force-recreate) COMMAND="$COMMAND --force-recreate"; shift;;
|
|
*) echo "Unrecognized option '$1' for '$COMMAND'"; exit 1;;
|
|
esac
|
|
done
|
|
;;
|
|
down*) COMMAND="docker-compose down"; shift;
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-o|--remove-orphans) COMMAND="$COMMAND --remove-orphans"; shift;;
|
|
*) echo "Unrecognized option '$1' for '$COMMAND'"; exit 1;;
|
|
esac
|
|
done
|
|
;;
|
|
config*) COMMAND="docker-compose config"; shift;
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-n|--no-interpolate) COMMAND="$COMMAND --no-interpolate"; shift;;
|
|
*) echo "Unrecognized option '$1' for '$COMMAND'"; exit 1;;
|
|
esac
|
|
done
|
|
;;
|
|
*) echo "Unrecognized option $1"; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
if [ -z ${COMMAND+x} ]; then
|
|
echo "Error: no command specified"
|
|
exit 1
|
|
fi
|
|
|
|
for stack in "$STACKS_DIRECTORY"/* ; do
|
|
cd $stack
|
|
if [ $NAS_ONLY ] || [ $LINT ]; then
|
|
TMP=$(docker-compose config)
|
|
PASS=$?
|
|
if [ $PASS != 0 ]; then
|
|
echo "ERROR: $stack failed to lint"
|
|
continue
|
|
fi
|
|
if [ $NAS_ONLY ]; then
|
|
echo $TMP | grep -q /mnt/nas
|
|
NAS_DEPENDENT=$?
|
|
if [ $NAS_DEPENDENT == 1 ]; then
|
|
continue
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
echo "${PWD} $COMMAND"
|
|
done
|
|
}
|
|
|
|
initialize
|
|
main "$@" |