Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
e4a19585
Commit
e4a19585
authored
Jun 26, 2016
by
neil
Browse files
support apache2ctl
parent
523c7682
Changes
1
Show whitespace changes
Inline
Side-by-side
acme.sh
View file @
e4a19585
...
@@ -1069,18 +1069,23 @@ _initpath() {
...
@@ -1069,18 +1069,23 @@ _initpath() {
_apachePath
()
{
_apachePath
()
{
_APAHECTL
=
"apachectl"
if
!
_exists apachectl
;
then
if
!
_exists apachectl
;
then
if
_exists apache2ctl
;
then
_APAHECTL
=
"apache2ctl"
else
_err
"'apachecrl not found. It seems that apache is not installed, or you are not root user.'"
_err
"'apachecrl not found. It seems that apache is not installed, or you are not root user.'"
_err
"Please use webroot mode to try again."
_err
"Please use webroot mode to try again."
return
1
return
1
fi
fi
httpdconfname
=
"
$(
apachectl
-V
|
grep
SERVER_CONFIG_FILE
=
|
cut
-d
=
-f
2 |
tr
-d
'"'
)
"
fi
httpdconfname
=
"
$(
$_APAHECTL
-V
|
grep
SERVER_CONFIG_FILE
=
|
cut
-d
=
-f
2 |
tr
-d
'"'
)
"
_debug httpdconfname
"
$httpdconfname
"
_debug httpdconfname
"
$httpdconfname
"
if
_startswith
"
$httpdconfname
"
'/'
;
then
if
_startswith
"
$httpdconfname
"
'/'
;
then
httpdconf
=
"
$httpdconfname
"
httpdconf
=
"
$httpdconfname
"
httpdconfname
=
"
$(
basename
$httpdconfname
)
"
httpdconfname
=
"
$(
basename
$httpdconfname
)
"
else
else
httpdroot
=
"
$(
apachectl
-V
|
grep
HTTPD_ROOT
=
|
cut
-d
=
-f
2 |
tr
-d
'"'
)
"
httpdroot
=
"
$(
$_APAHECTL
-V
|
grep
HTTPD_ROOT
=
|
cut
-d
=
-f
2 |
tr
-d
'"'
)
"
_debug httpdroot
"
$httpdroot
"
_debug httpdroot
"
$httpdroot
"
httpdconf
=
"
$httpdroot
/
$httpdconfname
"
httpdconf
=
"
$httpdroot
/
$httpdconfname
"
httpdconfname
=
"
$(
basename
$httpdconfname
)
"
httpdconfname
=
"
$(
basename
$httpdconfname
)
"
...
@@ -1110,7 +1115,7 @@ _restoreApache() {
...
@@ -1110,7 +1115,7 @@ _restoreApache() {
cat
"
$APACHE_CONF_BACKUP_DIR
/
$httpdconfname
"
>
"
$httpdconf
"
cat
"
$APACHE_CONF_BACKUP_DIR
/
$httpdconfname
"
>
"
$httpdconf
"
_debug
"Restored:
$httpdconf
."
_debug
"Restored:
$httpdconf
."
if
!
apachectl
-t
>
/dev/null 2>&1
;
then
if
!
$_APAHECTL
-t
>
/dev/null 2>&1
;
then
_err
"Sorry, restore apache config error, please contact me."
_err
"Sorry, restore apache config error, please contact me."
return
1
;
return
1
;
fi
fi
...
@@ -1127,7 +1132,7 @@ _setApache() {
...
@@ -1127,7 +1132,7 @@ _setApache() {
#test the conf first
#test the conf first
_info
"Checking if there is an error in the apache config file before starting."
_info
"Checking if there is an error in the apache config file before starting."
_msg
=
"
$(
apachectl
-t
2>&1
)
"
_msg
=
"
$(
$_APAHECTL
-t
2>&1
)
"
if
[
"
$?
"
!=
"0"
]
;
then
if
[
"
$?
"
!=
"0"
]
;
then
_err
"Sorry, apache config file has error, please fix it first, then try again."
_err
"Sorry, apache config file has error, please fix it first, then try again."
_err
"Don't worry, there is nothing changed to your system."
_err
"Don't worry, there is nothing changed to your system."
...
@@ -1150,7 +1155,7 @@ _setApache() {
...
@@ -1150,7 +1155,7 @@ _setApache() {
#add alias
#add alias
apacheVer
=
"
$(
apachectl
-V
|
grep
"Server version:"
|
cut
-d
:
-f
2 |
cut
-d
" "
-f
2 |
cut
-d
'/'
-f
2
)
"
apacheVer
=
"
$(
$_APAHECTL
-V
|
grep
"Server version:"
|
cut
-d
:
-f
2 |
cut
-d
" "
-f
2 |
cut
-d
'/'
-f
2
)
"
_debug
"apacheVer"
"
$apacheVer
"
_debug
"apacheVer"
"
$apacheVer
"
apacheMajer
=
"
$(
echo
"
$apacheVer
"
|
cut
-d
.
-f
1
)
"
apacheMajer
=
"
$(
echo
"
$apacheVer
"
|
cut
-d
.
-f
1
)
"
apacheMinor
=
"
$(
echo
"
$apacheVer
"
|
cut
-d
.
-f
2
)
"
apacheMinor
=
"
$(
echo
"
$apacheVer
"
|
cut
-d
.
-f
2
)
"
...
@@ -1174,7 +1179,7 @@ Allow from all
...
@@ -1174,7 +1179,7 @@ Allow from all
"
>>
"
$httpdconf
"
"
>>
"
$httpdconf
"
fi
fi
_msg
=
"
$(
apachectl
-t
2>&1
)
"
_msg
=
"
$(
$_APAHECTL
-t
2>&1
)
"
if
[
"
$?
"
!=
"0"
]
;
then
if
[
"
$?
"
!=
"0"
]
;
then
_err
"Sorry, apache config error"
_err
"Sorry, apache config error"
if
_restoreApache
;
then
if
_restoreApache
;
then
...
@@ -1190,8 +1195,8 @@ Allow from all
...
@@ -1190,8 +1195,8 @@ Allow from all
chmod
755
"
$ACME_DIR
"
chmod
755
"
$ACME_DIR
"
fi
fi
if
!
apachectl
graceful
;
then
if
!
$_APAHECTL
graceful
;
then
_err
"Sorry,
apachectl
graceful error, please contact me."
_err
"Sorry,
$_APAHECTL
graceful error, please contact me."
_restoreApache
_restoreApache
return
1
;
return
1
;
fi
fi
...
...
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