Skip to content

Commit

Permalink
Merge pull request #3 from infralovers/adapting-replace
Browse files Browse the repository at this point in the history
fix: adapt replace_var script to dotfiles
  • Loading branch information
mabunixda authored Dec 11, 2023
2 parents 79af713 + ad87e98 commit 070e501
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ENV-USER-ID>
find "${SCRIPT_DIR}" -type f -exec sed -i -e "s/<ENV-USER-ID>/$USER_ID/g" {} \;

# Replace <ENV-ANIMAL>
find "${SCRIPT_DIR}" -type f -exec sed -i -e "s/<ENV-ANIMAL>/$ANIMAL/g" {} \;

# Replace <ENV-IP>
find "${SCRIPT_DIR}" -type f -exec sed -i -e "s/<ENV-IP>/$HOST_IP/g" {} \;

# Replace <ENV-NAME>
find "${SCRIPT_DIR}" -type f -exec sed -i -e "s/<ENV-NAME>/$ENVIRONMENT/g" {} \;

# Replace <ENV-DOMAIN>
find "${SCRIPT_DIR}" -type f -exec sed -i -e "s/<ENV-DOMAIN>/$DOMAIN/g" {} \;

}

0 comments on commit 070e501

Please sign in to comment.