Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
df0f8729
Commit
df0f8729
authored
Oct 20, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nginx-le.sh: improve parse nginx conf
parent
6835657d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
nginx-le.sh
certs/nginx-le.sh
+17
-9
No files found.
certs/nginx-le.sh
View file @
df0f8729
...
...
@@ -2,6 +2,12 @@
# run with domain or path to conf file (preferable)
fatal
()
{
echo
"FATAL:
$*
"
>
&2
exit
1
}
INTHOST
=
host03.eterhost.ru
NCONF
=
$1
shift
...
...
@@ -11,19 +17,21 @@ shift
if
[
-r
"
$NCONF
"
]
;
then
DOMAIN
=
""
DOMAINARG
=
""
for
i
in
$(
grep
server_name
$NCONF
|
sed
-e
"s|;||"
)
;
do
echo
"
$i
"
|
grep
-q
"server_name"
&&
continue
echo
"
$i
"
|
grep
-q
"
$INTHOST
"
&&
continue
[
-n
"
$DOMAIN
"
]
||
DOMAIN
=
"
$i
"
DOMAINARG
=
"
$DOMAINARG
-d
$i
"
done
else
DOMAIN
=
"
$NCONF
"
DOMAINARG
=
"-d
$DOMAIN
"
NCONF
=
/etc/nginx/sites-enabled.d/
$DOMAIN
.conf
fi
[
-r
"
$NCONF
"
]
||
fatal
"Can't find
$NCONF
"
DOMAINARG
=
""
for
i
in
$(
grep
server_name
$NCONF
|
sed
-e
"s|;||"
)
;
do
echo
"
$i
"
|
grep
-q
"server_name"
&&
continue
echo
"
$i
"
|
grep
-q
"
$INTHOST
"
&&
continue
[
-n
"
$DOMAIN
"
]
||
DOMAIN
=
"
$i
"
DOMAINARG
=
"
$DOMAINARG
-d
$i
"
done
# depends on a system
DIR
=
/var/spool/nginx/tmp/client
[
-d
"
$DIR
"
]
||
DIR
=
/var/lib/nginx/tmp/client
...
...
@@ -38,7 +46,7 @@ CERTBOT=$(which certbot 2>/dev/null)
[
-x
"
$CERTBOT
"
]
||
CERTBOT
=
$(
which certbot-auto 2>/dev/null
)
[
-x
"
$CERTBOT
"
]
||
exit
$CERTBOT
certonly
--webroot
-w
$DIR
$DOMAINARG
$@
||
exit
$CERTBOT
certonly
--webroot
-w
$DIR
$DOMAINARG
$@
||
fatal
KEY
=
/etc/letsencrypt/live/
$DOMAIN
/privkey.pem
PEM
=
/etc/letsencrypt/live/
$DOMAIN
/fullchain.pem
...
...
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