Guest User

Untitled

a guest
May 5th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 5 ]; then
  4. printf "\n\nสวัสดี $USER คุณอาจต้องการความช่วยเหลือ:\n\n"
  5. cat /opt/kid/help.txt
  6. printf "\n"
  7. exit
  8. fi
  9.  
  10. POSITIONAL=()
  11. while [[ $# -gt 0 ]]
  12. do
  13. key="$1"
  14.  
  15. case $key in
  16. -n|--name)
  17. NAME="$2"
  18. shift # past argument
  19. shift # past value
  20. ;;
  21. -r|--root)
  22. ROOTDIR="$2"
  23. shift # past argument
  24. shift # past value
  25. ;;
  26. *) # unknown option
  27. POSITIONAL+=("$1") # save it in an array for later
  28. shift # past argument
  29. ;;
  30. esac
  31. done
  32. set -- "${POSITIONAL[@]}" # restore positional parameters
  33.  
  34. echo VHost name = "${NAME}"
  35. echo Root directory = "${ROOTDIR}"
  36.  
  37. cd /etc/apache2/sites-available
  38. sudo cp example.conf $NAME.conf
  39. sudo sed -i "s,/var/www/example,/var/www/$ROOTDIR,g; s/example/$NAME/g" $NAME.conf
  40. printf "Virtual host '$NAME' created.\n\n"
  41. cat $NAME.conf
  42. printf '\n\nMapping hostname...'
  43. printf "\n\n# $NAME\n127.0.0.1 $NAME.local" | sudo tee -a /etc/hosts
  44. printf '\n\nHostname mapped!\n'
  45. sudo a2ensite $NAME
  46. sudo service apache2 restart
  47. echo Apache2 restarted!
Add Comment
Please, Sign In to add comment