Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Open sidebar
Hj Ahmad Rasyid Hj Ismail
ISPConfig Autoinstaller
Commits
46184687
Commit
46184687
authored
Oct 15, 2020
by
Marius Burkard
Browse files
- do not allow unknown arguments, fixes #18
parent
1946005f
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/class.ISPConfig.inc.php
View file @
46184687
...
...
@@ -17,20 +17,20 @@ define('ISPC_WEBSERVER_NGINX', 2);
class
ISPConfig
{
private
static
$is_cli_run
=
false
;
private
static
$cli_script
=
false
;
private
static
$autoload_files
=
array
(
'PXBashColor'
=>
LIB_DIR
.
'/libbashcolor.inc.php'
);
public
static
$WEBSERVER
=
ISPC_WEBSERVER_APACHE
;
private
static
function
init
()
{
if
(
!
isset
(
$_GET
))
{
$_GET
=
array
();
}
if
(
php_sapi_name
()
==
'cli'
)
{
self
::
$is_cli_run
=
true
;
$argc
=
0
;
$argv
=
array
();
if
(
isset
(
$_SERVER
[
'argc'
]))
{
...
...
@@ -39,11 +39,11 @@ class ISPConfig {
if
(
isset
(
$_SERVER
[
'argv'
]))
{
$argv
=
$_SERVER
[
'argv'
];
}
if
(
isset
(
$argv
[
0
]))
{
self
::
$cli_script
=
basename
(
$argv
[
0
]);
}
for
(
$a
=
1
;
$a
<
$argc
;
$a
++
)
{
if
(
substr
(
$argv
[
$a
],
0
,
2
)
==
'--'
)
{
$sArg
=
substr
(
$argv
[
$a
],
2
);
...
...
@@ -54,10 +54,13 @@ class ISPConfig {
$sValue
=
true
;
}
$_GET
[
$sKey
]
=
$sValue
;
}
else
{
self
::
printHelp
();
exit
;
}
}
}
if
(
!
self
::
shallInstall
(
'web'
))
{
self
::
$WEBSERVER
=
ISPC_WEBSERVER_NONE
;
}
elseif
(
isset
(
$_GET
[
'use-nginx'
])
&&
$_GET
[
'use-nginx'
])
{
...
...
@@ -66,17 +69,17 @@ class ISPConfig {
self
::
$WEBSERVER
=
ISPC_WEBSERVER_APACHE
;
}
}
private
static
function
input
()
{
$input
=
fgets
(
STDIN
);
return
rtrim
(
$input
);
}
public
static
function
ask
(
$prompt
)
{
print
$prompt
.
': '
;
return
self
::
input
();
}
/**
* @param string $class_name
* @throws ISPConfigClassException
...
...
@@ -85,7 +88,7 @@ class ISPConfig {
if
(
preg_match
(
'/^\w+$/'
,
$class_name
)
===
false
)
{
throw
new
ISPConfigClassException
(
$class_name
.
' is not a valid class name.'
);
}
$class_dir
=
LIB_DIR
;
if
(
preg_match
(
'/Exception$/'
,
$class_name
))
{
$class_dir
.
=
'/exceptions'
;
...
...
@@ -96,7 +99,7 @@ class ISPConfig {
}
elseif
(
preg_match
(
'/OS$/'
,
$class_name
))
{
$class_dir
.
=
'/os'
;
}
$use_file
=
null
;
if
(
isset
(
self
::
$autoload_files
[
$class_name
]))
{
$use_file
=
self
::
$autoload_files
[
$class_name
];
...
...
@@ -113,7 +116,7 @@ class ISPConfig {
if
(
$class_name
!=
'ISPConfigLog'
)
{
ISPConfigLog
::
debug
(
'Trying to autoload class file "'
.
$use_file
.
'" for class "'
.
$class_name
.
'"'
);
}
if
(
!
file_exists
(
$use_file
))
{
throw
new
ISPConfigClassException
(
'File '
.
$use_file
.
' not found for class '
.
$class_name
.
'.'
);
}
...
...
@@ -123,14 +126,14 @@ class ISPConfig {
throw
new
ISPConfigClassException
(
$class_name
.
' not found in file '
.
LIB_DIR
.
'/class.'
.
$class_name
.
'.inc.php.'
);
}
}
/**
* @return boolean
*/
public
static
function
isCLI
()
{
return
self
::
$is_cli_run
;
}
/**
* @return string
*/
...
...
@@ -145,7 +148,7 @@ class ISPConfig {
return
true
;
}
}
public
static
function
wantsInteractive
()
{
if
(
isset
(
$_GET
[
'interactive'
])
&&
$_GET
[
'interactive'
])
{
return
true
;
...
...
@@ -153,7 +156,7 @@ class ISPConfig {
return
false
;
}
}
public
static
function
wantsAmavis
()
{
if
(
isset
(
$_GET
[
'use-amavis'
])
&&
$_GET
[
'use-amavis'
])
{
return
true
;
...
...
@@ -161,7 +164,7 @@ class ISPConfig {
return
false
;
}
}
public
static
function
wantsPHP
()
{
if
(
isset
(
$_GET
[
'use-php'
])
&&
$_GET
[
'use-php'
])
{
return
$_GET
[
'use-php'
];
...
...
@@ -169,7 +172,7 @@ class ISPConfig {
return
false
;
}
}
public
static
function
getISPConfigChannel
()
{
if
(
isset
(
$_GET
[
'channel'
])
&&
$_GET
[
'channel'
])
{
return
$_GET
[
'channel'
];
...
...
@@ -177,7 +180,7 @@ class ISPConfig {
return
'stable'
;
}
}
public
static
function
getFTPPassivePorts
()
{
if
(
isset
(
$_GET
[
'use-ftp-ports'
]))
{
list
(
$from
,
$to
)
=
explode
(
'-'
,
$_GET
[
'use-ftp-ports'
]);
...
...
@@ -188,7 +191,7 @@ class ISPConfig {
}
return
false
;
}
private
static
function
printHelp
()
{
$message
=
'
...
...
@@ -228,7 +231,7 @@ Possible arguments are:
--i-know-what-i-am-doing
->Prevent the autoinstaller to ask for confirmation before continuing to reconfigure the server.
'
;
ISPConfigLog
::
print
(
$message
);
exit
;
}
...
...
@@ -238,16 +241,16 @@ Possible arguments are:
*/
public
static
function
run
()
{
self
::
init
();
$pmatch
=
null
;
$valid_args
=
array
(
'help'
,
'debug'
,
'interactive'
,
'use-nginx'
,
'use-amavis'
,
'use-php'
,
'use-ftp-ports'
,
'channel'
,
'lang'
,
'no-web'
,
'no-mail'
,
'no-dns'
,
'no-firewall'
,
'no-roundcube'
,
'no-pma'
,
'no-mailman'
,
'no-quota'
,
'i-know-what-i-am-doing'
);
reset
(
$_GET
);
foreach
(
array_keys
(
$_GET
)
as
$key
)
{
if
(
!
in_array
(
$key
,
$valid_args
,
true
))
{
...
...
@@ -255,7 +258,7 @@ Possible arguments are:
exit
;
}
}
if
(
isset
(
$_GET
[
'help'
])
&&
$_GET
[
'help'
])
{
self
::
printHelp
();
exit
;
...
...
@@ -272,7 +275,7 @@ Possible arguments are:
self
::
printHelp
();
exit
;
}
if
(
!
isset
(
$_GET
[
'i-know-what-i-am-doing'
])
||
!
$_GET
[
'i-know-what-i-am-doing'
])
{
print
PXBashColor
::
getString
(
'<lightred>WARNING!</lightred> This script will reconfigure your complete server!'
)
.
"
\n
"
;
print
'It should be run on a freshly installed server and all current configuration that you have done will most likely be lost!'
.
"
\n
"
;
...
...
@@ -282,15 +285,15 @@ Possible arguments are:
exit
;
}
}
if
(
isset
(
$_GET
[
'debug'
])
&&
$_GET
[
'debug'
])
{
ISPConfigLog
::
setLogPriority
(
ISPConfigLog
::
PRIO_DEBUG
);
}
// get operating system
try
{
$os
=
ISPConfigBaseOS
::
getOSVersion
();
ISPConfigLog
::
info
(
'Starting perfect server setup for '
.
$os
[
'NAME'
],
true
);
$installer
=
ISPConfigBaseOS
::
getOSInstance
();
$installer
->
runPerfectSetup
();
...
...
@@ -298,8 +301,8 @@ Possible arguments are:
}
catch
(
Exception
$ex
)
{
throw
$ex
;
}
exit
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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