Created
September 17, 2018 15:30
-
-
Save igolden/679d8093519d05ac231b88c73b5ebc05 to your computer and use it in GitHub Desktop.
Sets up dev server hostname for local machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
FILE='/etc/hosts' | |
printf "Name your project (lowercase, no-spaces): \n" | |
read NAME | |
function setup_namespace { | |
sed -i .bak -e "s/project/$NAME/g" config/nginx.conf && rm config/*.bak | |
sed -i .bak -e "s/project/$NAME/g" Dockerfile && rm *.bak | |
sed -i .bak -e "s/project/$NAME/g" Dockerfile-nginx && rm *.bak | |
sed -i .bak -e "s/project/$NAME/g" docker-compose.yml && rm *.bak | |
} | |
function setup_hosts { | |
if grep -q "$NAME.headless" "$FILE"; then | |
echo "Hosts already configured correctly." | |
else | |
echo "Setting up the hosts file.." | |
sudo bash -c "echo -e '## $PROJECT dev environment\n127.0.0.1\t$NAME.headless\n' >> /etc/hosts" | |
echo "Success!" | |
fi | |
} | |
function run { | |
setup_namespace | |
setup_hosts | |
echo "Your local project domain is $NAME.headless" | |
} | |
# Run Functions | |
run | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment