Last active
May 12, 2017 17:09
-
-
Save starlays/3663965 to your computer and use it in GitHub Desktop.
Bash
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
#!/bin/bash | |
if [ $# -ne 2 ]; then | |
echo "mkvhost.sh http://<subdomain>.localhost <dirname/path under DocRoot>" | |
exit 1; | |
fi | |
FILE="/etc/httpd/conf/extra/vhosts/$1.conf" | |
read -r -d '' DATA <<EOF | |
<VirtualHost *:80>\n | |
\tDocumentRoot "/srv/http/$2"\n | |
\tServerName $1.localhost.localdomain\n | |
\tServerAlias $1.localhost\n | |
\tErrorLog "/var/log/httpd/$1.localhost.localdomain-error_log"\n | |
\tCustomLog "/var/log/httpd/$1.localhost.localdomain-error_log" common\n | |
\t\t<Directory "/srv/http/$2">\n | |
\t\t\tAllowOverride All\n | |
\t\t\tSetEnv ZF2_PATH /home/{user}/projects/zf2/library\n | |
\t\t</Directory>\n | |
</VirtualHost>\n | |
EOF | |
echo -e $DATA > $FILE | |
NEWHOST="127.0.0.1 $1.localhost.localdomain $1.localhost $HOSTNAME" | |
grep -q "$NEWHOST" /etc/hosts | |
if [ $? -ne 0 ]; then | |
echo "$NEWHOST" >> /etc/hosts | |
fi |
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
#Color cut - syntax hilight | |
ccat() { | |
while getopts ":n" optval "$@" | |
do | |
case $optval in | |
"n") | |
source-highlight -n --failsafe --infer-lang -f esc --style-file=esc.style -i "$2" | |
;; | |
"?") | |
echo "Unknown option" | |
;; | |
*) | |
errormsg="Unknown parameter or option error with option - $OPTARG" | |
;; | |
esac | |
done | |
if [[ $# == 1 ]] | |
then | |
source-highlight --failsafe --infer-lang -f esc --style-file=esc.style -i "$1" | |
fi | |
OPTIND=1 | |
} |
Or is that even necessary at all?
Hmm, removed, this is strange, i didn't received any notification regarding your 2 comments, i think that i have some strange settings somewhere.
replaced flav with {user}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that you can do the
read
andecho
part by sourcing: https://github.com/paullik/webchat/blob/python/src/deploy.sh#L18That will allow some separation of concerns too, maybe some modularity.
Also you have a line:
SetEnv ZF2_PATH /home/flav/projects/zf2/library\n
should that path be hard-coded there?