configshell 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. c_bold="\033[1m";
  3. c_norm="\033[0m";
  4. help(){
  5. if [[ "$1" != "" ]];then
  6. case "$1" in
  7. addsite)
  8. echo "Addsite Usage:";
  9. echo "addsite <name> <host> [<path>] - adds a site to apache and enables it";
  10. ;;
  11. help)
  12. echo "Help Usage:";
  13. echo "help - displays this message";
  14. echo "help <command> - displays help for a command";
  15. ;;
  16. *)
  17. help;
  18. esac;
  19. else
  20. echo "Commands:";
  21. echo " help";
  22. echo " addsite";
  23. fi;
  24. }
  25. addsite(){
  26. if [ -f /etc/apache2/sites-available/$1.conf ];then
  27. echo "Site already exists";
  28. else
  29. if [[ "$3" != "" ]];then
  30. path="$3";
  31. else
  32. path="/var/www/$1";
  33. fi;
  34. mkdir -p "$path";
  35. echo "<VirtualHost *:80>
  36. ServerName $2
  37. DocumentRoot $path
  38. <Directory $path>
  39. Options +ExecCGI +Indexes +FollowSymLinks +MultiViews
  40. AllowOverride All
  41. RewriteEngine On
  42. Order allow,deny
  43. allow from all
  44. </Directory>
  45. ErrorLog ${APACHE_LOG_DIR}/error.log
  46. CustomLog ${APACHE_LOG_DIR}/access.log combined
  47. ServerAdmin [email protected]
  48. </VirtualHost>" > /etc/apache2/sites-available/$1.conf;
  49. echo "Created site $1 ($2) at $path";
  50. a2ensite $1;
  51. sudo service apache2 reload;
  52. fi;
  53. }
  54. while true; do
  55. echo -ne "$c_bold$(whoami)@$(pwd)>$c_norm ";
  56. read input;
  57. case "$input" in
  58. *)
  59. eval "$input";
  60. esac;
  61. done;