Skip to content

Commit 57f720a

Browse files
author
Tayler
committed
Fixed userdir being listed twice when no doc root is specified
1 parent e068e19 commit 57f720a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

virtualhost-nginx.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,25 @@ if [ "$action" == 'create' ]
4848
fi
4949

5050
### check if directory exists or not
51-
if ! [ -d $userDir$rootDir ]; then
51+
if ! [ -d $rootDir ]; then
5252
### create the directory
53-
mkdir $userDir$rootDir
53+
mkdir $rootDir
5454
### give permission to root dir
55-
chmod 755 $userDir$rootDir
55+
chmod 755 $rootDir
5656
### write test file in the new domain dir
57-
if ! echo "<?php echo phpinfo(); ?>" > $userDir$rootDir/phpinfo.php
57+
if ! echo "<?php echo phpinfo(); ?>" > $rootDir/phpinfo.php
5858
then
59-
echo $"ERROR: Not able to write in file $userDir/$rootDir/phpinfo.php. Please check permissions."
59+
echo $"ERROR: Not able to write in file $rootDir/phpinfo.php. Please check permissions."
6060
exit;
6161
else
62-
echo $"Added content to $userDir$rootDir/phpinfo.php."
62+
echo $"Added content to $rootDir/phpinfo.php."
6363
fi
6464
fi
6565

6666
### create virtual host rules file
6767
if ! echo "server {
6868
listen 80;
69-
root $userDir$rootDir;
69+
root $rootDir;
7070
index index.php index.html index.htm;
7171
server_name $domain;
7272
@@ -124,9 +124,9 @@ if [ "$action" == 'create' ]
124124
fi
125125

126126
if [ "$owner" == "" ]; then
127-
chown -R $(whoami):www-data $userDir$rootDir
127+
chown -R $(whoami):www-data $rootDir
128128
else
129-
chown -R $owner:www-data $userDir$rootDir
129+
chown -R $owner:www-data $rootDir
130130
fi
131131

132132
### enable website
@@ -136,7 +136,7 @@ if [ "$action" == 'create' ]
136136
service nginx restart
137137

138138
### show the finished message
139-
echo -e $"Complete! \nYou now have a new Virtual Host \nYour new host is: http://$domain \nAnd its located at $userDir$rootDir"
139+
echo -e $"Complete! \nYou now have a new Virtual Host \nYour new host is: http://$domain \nAnd its located at $rootDir"
140140
exit;
141141
else
142142
### check whether domain already exists
@@ -159,13 +159,13 @@ if [ "$action" == 'create' ]
159159
fi
160160

161161
### check if directory exists or not
162-
if [ -d $userDir$rootDir ]; then
162+
if [ -d $rootDir ]; then
163163
echo -e $"Delete host root directory ? (s/n)"
164164
read deldir
165165

166166
if [ "$deldir" == 's' -o "$deldir" == 'S' ]; then
167167
### Delete the directory
168-
rm -rf $userDir$rootDir
168+
rm -rf $rootDir
169169
echo -e $"Directory deleted"
170170
else
171171
echo -e $"Host directory conserved"

0 commit comments

Comments
 (0)