Last active
February 10, 2020 09:43
-
-
Save Tchaokko/7100914 to your computer and use it in GitHub Desktop.
Premier jet
This file contains 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 | |
APACHE_SITES="/home/tchaokko/test" | |
VERSION_APACHE="1" | |
if [ $VERSION_APACHE == "1" ] ; | |
then | |
DEST=$APACHE_SITES | |
elif [[ $VERSION_APACHE == "2" ]]; then | |
DEST=$1; | |
[ ! -d $DEST ] || touch $DEST | |
fi | |
if [ $# -eq 2 ] ; | |
then | |
echo "<VirtualHost *:80>" >> $DEST | |
echo " ServerName $1" >> $DEST | |
echo " DocumentRoot $2" >> $DEST | |
echo " <Directory $2 >" >> $DEST | |
echo " Order allow,deny" >> $DEST | |
echo " Allow from all" >> $DEST | |
echo " </Directory>" >> $DEST | |
echo "</VirtualHost>" >> $DEST; | |
echo "127.0.0.1 $1" | sudo tee -a /etc/hosts > /dev/null | |
echo "::1 $1" | sudo tee -a /etc/hosts > /dev/null | |
if [ $VERSION_APACHE == "2" ] ; | |
then | |
sudo mv $1 $APACHE_SITES | |
sudo a2ensite $1 | |
fi | |
sudo apachectl graceful | |
else | |
echo "Usage: ./$0 ServerName DocumentRoot" | |
echo | |
echo "This script is VirtualHost creating script. It takes 2 arguments." | |
echo "The first one is the ServerName and the second one is the DocumentRoot"; | |
echo "What it's going to do? It's going to create a file, and move it in $APACHE_SITES" | |
echo "If that directory doesn't look good to you, you might wan to change it." | |
echo "Then it's going to add a line in you /etc/hosts. Same thing, you might wanna change that." | |
echo "If your computer explode, I'm not the one to blame. Just dance, it will ease your pain." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment