Diff
1diff --git a/plugins/nginx/nginx.plugin.zsh b/plugins/nginx/nginx.plugin.zsh
2index 6dd90c6d528898f01fbb80d3dfadcade87086179..4d2c4122d35fc3d6ad2069f585505970aa319d37 100644
3--- a/plugins/nginx/nginx.plugin.zsh
4+++ b/plugins/nginx/nginx.plugin.zsh
5@@ -81,45 +81,36 @@ _nginx_vhost () {
6
7 # Parsing arguments
8 vhost () {
9- user=$USER;
10- template=$NGINX_VHOST_TEMPLATE
11- tpl="non_existing_template"
12- enable=1
13- write_hosts=0
14- args=""
15+ local user=$USER;
16+ local template=$NGINX_VHOST_TEMPLATE
17+ local tpl="non_existing_template"
18+ local enable=1
19+ local write_hosts=0
20
21 while getopts ":lu:t:nwh" option
22 do
23 case $option in
24 l ) ls $NGINX_DIR/sites-enabled; return ;;
25- u ) user=$OPTARG; args="$args -u $OPTARG" ;;
26- t ) tpl=$OPTARG; args="$args -t $OPTARG" ;;
27- n ) enable=0; args="$args -n" ;;
28- w ) write_hosts=1; args="$args -w" ;;
29+ u ) user=$OPTARG ;;
30+ t ) tpl=$OPTARG ;;
31+ n ) enable=0 ;;
32+ w ) write_hosts=1 ;;
33 h ) _vhost_usage; return ;;
34 esac
35 done
36
37- vhost=${@: -1}
38- vhostNotGiven=0
39-
40- if [ ! $vhost ]; then
41- vhostNotGiven=1
42- else
43- if [ $(echo $args | grep -o $vhost) ]; then
44- vhostNotGiven=1
45- fi
46- fi
47-
48- if [ $vhostNotGiven -eq 1 ]; then
49+ shift $[ $OPTIND - 1 ]
50+ local vhost=$1
51+
52+ if [ -z "$vhost" ]; then
53 echo "\033[337;41m\nThe name of the vhost is required!\n\033[0m"
54 return
55 fi
56
57 if [ -e $ZSH/plugins/nginx/templates/$tpl ]; then
58- template=$ZSH/plugins/nginx/templates/$tpl
59+ local template=$ZSH/plugins/nginx/templates/$tpl
60 elif [ -e $tpl ]; then
61- template=$tpl
62+ local template=$tpl
63 fi
64
65 _vhost_generate $vhost $user
66@@ -149,7 +140,7 @@ _vhost_usage () {
67
68 # Generate config file
69 _vhost_generate () {
70- user=$(cat /etc/passwd | grep $2 | awk -F : '{print $1 }')
71+ local user=$(cat /etc/passwd | grep $2 | awk -F : '{print $1 }')
72
73 if [ ! $user ]; then
74 echo "User \033[31m$2\033[0m doesn't have an account on \033[33m$HOST\033[0m"
75@@ -158,10 +149,10 @@ _vhost_generate () {
76
77 echo "Generating \033[32m$1\033[0m vhost for \033[33m$user\033[0m user"
78
79- user_id=$(cat /etc/passwd | grep $2 | awk -F : '{print $3 }')
80- pool_port=1$user_id
81+ local user_id=$(cat /etc/passwd | grep $2 | awk -F : '{print $3 }')
82+ local pool_port=1$user_id
83
84- conf=$(sed -e 's/{vhost}/'$1'/g' -e 's/{user}/'$user'/g' -e 's/{pool_port}/'$pool_port'/g' $template )
85+ local conf=$(sed -e 's/{vhost}/'$1'/g' -e 's/{user}/'$user'/g' -e 's/{pool_port}/'$pool_port'/g' $template )
86
87 echo $conf > $1.tmp
88 $sudo mv $1.tmp $NGINX_DIR/sites-available/$1
89@@ -188,7 +179,7 @@ _write_hosts () {
90
91 $sudo mv $temp /etc/hosts;
92
93- "\033[32m$1\033[0m vhost has been successfully written in /etc/hosts"
94+ echo "\033[32m$1\033[0m vhost has been successfully written in /etc/hosts"
95 }
96
97 alias ngt="$sudo nginx -t"
98diff --git a/plugins/nginx/templates/symfony2 b/plugins/nginx/templates/symfony2
99index 4d5754ca1a3d77f9967252b437de72f06586360d..c2eeaec0ab29b34594c86aa1a52be9697983352a 100644
100--- a/plugins/nginx/templates/symfony2
101+++ b/plugins/nginx/templates/symfony2
102@@ -9,7 +9,7 @@ server {
103 access_log /var/log/nginx/{vhost}.access.log;
104
105 location / {
106- try_files $uri $uri/ /app_dev.php;
107+ try_files $uri $uri/ /app_dev.php$uri /app_dev.php$is_args$args;
108 }
109
110 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:{pool_port}