Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
08f4d8b9
Commit
08f4d8b9
authored
Sep 11, 2012
by
mikka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed nginx vhost template, made variables local, imroved parameter validation
parent
91303246
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
30 deletions
+21
-30
nginx.plugin.zsh
plugins/nginx/nginx.plugin.zsh
+20
-29
symfony2
plugins/nginx/templates/symfony2
+1
-1
No files found.
plugins/nginx/nginx.plugin.zsh
View file @
08f4d8b9
...
@@ -81,45 +81,36 @@ _nginx_vhost () {
...
@@ -81,45 +81,36 @@ _nginx_vhost () {
# Parsing arguments
# Parsing arguments
vhost
()
{
vhost
()
{
user
=
$USER
;
local
user
=
$USER
;
template
=
$NGINX_VHOST_TEMPLATE
local
template
=
$NGINX_VHOST_TEMPLATE
tpl
=
"non_existing_template"
local
tpl
=
"non_existing_template"
enable
=
1
local enable
=
1
write_hosts
=
0
local
write_hosts
=
0
args
=
""
while
getopts
":lu:t:nwh"
option
while
getopts
":lu:t:nwh"
option
do
do
case
$option
in
case
$option
in
l
)
ls
$NGINX_DIR
/sites-enabled
;
return
;;
l
)
ls
$NGINX_DIR
/sites-enabled
;
return
;;
u
)
user
=
$OPTARG
;
args
=
"
$args
-u
$OPTARG
"
;;
u
)
user
=
$OPTARG
;;
t
)
tpl
=
$OPTARG
;
args
=
"
$args
-t
$OPTARG
"
;;
t
)
tpl
=
$OPTARG
;;
n
)
enable
=
0
;
args
=
"
$args
-n"
;;
n
)
enable
=
0
;;
w
)
write_hosts
=
1
;
args
=
"
$args
-w"
;;
w
)
write_hosts
=
1
;;
h
)
_vhost_usage
;
return
;;
h
)
_vhost_usage
;
return
;;
esac
esac
done
done
vhost
=
${
@
:
-1
}
shift
$[
$OPTIND
- 1
]
vhostNotGiven
=
0
local
vhost
=
$1
if
[
!
$vhost
]
;
then
if
[
-z
"
$vhost
"
]
;
then
vhostNotGiven
=
1
else
if
[
$(
echo
$args
|
grep
-o
$vhost
)
]
;
then
vhostNotGiven
=
1
fi
fi
if
[
$vhostNotGiven
-eq
1
]
;
then
echo
"
\0
33[337;41m
\n
The name of the vhost is required!
\n\0
33[0m"
echo
"
\0
33[337;41m
\n
The name of the vhost is required!
\n\0
33[0m"
return
return
fi
fi
if
[
-e
$ZSH
/plugins/nginx/templates/
$tpl
]
;
then
if
[
-e
$ZSH
/plugins/nginx/templates/
$tpl
]
;
then
template
=
$ZSH
/plugins/nginx/templates/
$tpl
local
template
=
$ZSH
/plugins/nginx/templates/
$tpl
elif
[
-e
$tpl
]
;
then
elif
[
-e
$tpl
]
;
then
template
=
$tpl
local
template
=
$tpl
fi
fi
_vhost_generate
$vhost
$user
_vhost_generate
$vhost
$user
...
@@ -149,7 +140,7 @@ _vhost_usage () {
...
@@ -149,7 +140,7 @@ _vhost_usage () {
# Generate config file
# Generate config file
_vhost_generate
()
{
_vhost_generate
()
{
user
=
$(
cat
/etc/passwd |
grep
$2
|
awk
-F
:
'{print $1 }'
)
local
user
=
$(
cat
/etc/passwd |
grep
$2
|
awk
-F
:
'{print $1 }'
)
if
[
!
$user
]
;
then
if
[
!
$user
]
;
then
echo
"User
\0
33[31m
$2
\0
33[0m doesn't have an account on
\0
33[33m
$HOST
\0
33[0m"
echo
"User
\0
33[31m
$2
\0
33[0m doesn't have an account on
\0
33[33m
$HOST
\0
33[0m"
...
@@ -158,10 +149,10 @@ _vhost_generate () {
...
@@ -158,10 +149,10 @@ _vhost_generate () {
echo
"Generating
\0
33[32m
$1
\0
33[0m vhost for
\0
33[33m
$user
\0
33[0m user"
echo
"Generating
\0
33[32m
$1
\0
33[0m vhost for
\0
33[33m
$user
\0
33[0m user"
user_id
=
$(
cat
/etc/passwd |
grep
$2
|
awk
-F
:
'{print $3 }'
)
local
user_id
=
$(
cat
/etc/passwd |
grep
$2
|
awk
-F
:
'{print $3 }'
)
pool_port
=
1
$user_id
local
pool_port
=
1
$user_id
conf
=
$(
sed
-e
's/{vhost}/'
$1
'/g'
-e
's/{user}/'
$user
'/g'
-e
's/{pool_port}/'
$pool_port
'/g'
$template
)
local
conf
=
$(
sed
-e
's/{vhost}/'
$1
'/g'
-e
's/{user}/'
$user
'/g'
-e
's/{pool_port}/'
$pool_port
'/g'
$template
)
echo
$conf
>
$1
.tmp
echo
$conf
>
$1
.tmp
$sudo
mv
$1
.tmp
$NGINX_DIR
/sites-available/
$1
$sudo
mv
$1
.tmp
$NGINX_DIR
/sites-available/
$1
...
@@ -188,7 +179,7 @@ _write_hosts () {
...
@@ -188,7 +179,7 @@ _write_hosts () {
$sudo
mv
$temp
/etc/hosts
;
$sudo
mv
$temp
/etc/hosts
;
"
\0
33[32m
$1
\0
33[0m vhost has been successfully written in /etc/hosts"
echo
"
\0
33[32m
$1
\0
33[0m vhost has been successfully written in /etc/hosts"
}
}
alias
ngt
=
"
$sudo
nginx -t"
alias
ngt
=
"
$sudo
nginx -t"
...
...
plugins/nginx/templates/symfony2
View file @
08f4d8b9
...
@@ -9,7 +9,7 @@ server {
...
@@ -9,7 +9,7 @@ server {
access_log /var/log/nginx/{vhost}.access.log;
access_log /var/log/nginx/{vhost}.access.log;
location / {
location / {
try_files $uri $uri/ /app_dev.php;
try_files $uri $uri/ /app_dev.php
$uri /app_dev.php$is_args$args
;
}
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:{pool_port}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:{pool_port}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment