From ad87e986a6e85dd19ca163ab862094c6869f722d Mon Sep 17 00:00:00 2001 From: Martin Buchleitner Date: Mon, 11 Dec 2023 16:13:50 +0100 Subject: [PATCH] fix: adapt replace_var script to dotfiles Signed-off-by: Martin Buchleitner --- .functions | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.functions b/.functions index 8a2193d..d4cd76e 100644 --- a/.functions +++ b/.functions @@ -29,3 +29,30 @@ env_ini() { echo $property | sed s'/"//g' | awk -F'=' '{print "export "$1"="$2}' done } + + +replace_variables() { + + SCRIPT_DIR=${1:-${PWD}} + + if [ ! -d "$SCRIPT_DIR" ]; then + echo "$SCRIPT_DIR is not a directory" + return + fi + + # Replace + find "${SCRIPT_DIR}" -type f -exec sed -i -e "s//$USER_ID/g" {} \; + + # Replace + find "${SCRIPT_DIR}" -type f -exec sed -i -e "s//$ANIMAL/g" {} \; + + # Replace + find "${SCRIPT_DIR}" -type f -exec sed -i -e "s//$HOST_IP/g" {} \; + + # Replace + find "${SCRIPT_DIR}" -type f -exec sed -i -e "s//$ENVIRONMENT/g" {} \; + + # Replace + find "${SCRIPT_DIR}" -type f -exec sed -i -e "s//$DOMAIN/g" {} \; + +}