Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $# -ne 5 ]; then
- printf "\n\nสวัสดี $USER คุณอาจต้องการความช่วยเหลือ:\n\n"
- cat /opt/kid/help.txt
- printf "\n"
- exit
- fi
- POSITIONAL=()
- while [[ $# -gt 0 ]]
- do
- key="$1"
- case $key in
- -n|--name)
- NAME="$2"
- shift # past argument
- shift # past value
- ;;
- -r|--root)
- ROOTDIR="$2"
- shift # past argument
- shift # past value
- ;;
- *) # unknown option
- POSITIONAL+=("$1") # save it in an array for later
- shift # past argument
- ;;
- esac
- done
- set -- "${POSITIONAL[@]}" # restore positional parameters
- echo VHost name = "${NAME}"
- echo Root directory = "${ROOTDIR}"
- cd /etc/apache2/sites-available
- sudo cp example.conf $NAME.conf
- sudo sed -i "s,/var/www/example,/var/www/$ROOTDIR,g; s/example/$NAME/g" $NAME.conf
- printf "Virtual host '$NAME' created.\n\n"
- cat $NAME.conf
- printf '\n\nMapping hostname...'
- printf "\n\n# $NAME\n127.0.0.1 $NAME.local" | sudo tee -a /etc/hosts
- printf '\n\nHostname mapped!\n'
- sudo a2ensite $NAME
- sudo service apache2 restart
- echo Apache2 restarted!
Add Comment
Please, Sign In to add comment