Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ISPConfig 3
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1,573
Issues
1,573
List
Boards
Labels
Milestones
Merge Requests
30
Merge Requests
30
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
ISPConfig
ISPConfig 3
Commits
f8b551ed
Commit
f8b551ed
authored
Nov 16, 2018
by
Marius Burkard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- added helper script for installing addons
parent
46f5b91a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
29 deletions
+54
-29
server/addons.php
server/addons.php
+27
-29
server/lib/classes/ispconfig_addon_installer_base.inc.php
server/lib/classes/ispconfig_addon_installer_base.inc.php
+27
-0
No files found.
server/addons.php
View file @
f8b551ed
<?php
/*
Copyright (c) 20
07-2016, Till Brehm, projektfarm Gmbh
Copyright (c) 20
18 Marius Burkard, ISPConfig UG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
...
...
@@ -38,35 +38,33 @@ ini_set('error_reporting', E_ALL & ~E_NOTICE);
// make sure server_id is always an int
$conf
[
'server_id'
]
=
intval
(
$conf
[
'server_id'
]);
// Load required base-classes
$app
->
uses
(
'ini_parser,file,services,getconf,system,cron,functions'
);
$app
->
load
(
'libdatetime,cronjob'
);
// Path settings
$path
=
SCRIPT_PATH
.
'/lib/classes/cron.d'
;
//** Get commandline options
$cmd_opt
=
getopt
(
''
,
array
(
'cronjob::'
));
if
(
isset
(
$cmd_opt
[
'cronjob'
])
&&
is_file
(
$path
.
'/'
.
$cmd_opt
[
'cronjob'
]))
{
// Cronjob that shell be run
$cronjob_file
=
$cmd_opt
[
'cronjob'
];
}
else
{
die
(
'Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php'
);
if
(
!
isset
(
$_SERVER
[
'argv'
]))
{
die
(
'No package path given.'
);
}
// Load and run the cronjob
$name
=
substr
(
$cronjob_file
,
0
,
strpos
(
$cronjob_file
,
'.'
));
if
(
preg_match
(
'/^\d+\-(.*)$/'
,
$name
,
$match
))
$name
=
$match
[
1
];
// strip numerical prefix from file name
include
$path
.
'/'
.
$cronjob_file
;
$class_name
=
'cronjob_'
.
$name
;
$cronjob
=
new
$class_name
();
$action
=
''
;
$package
=
''
;
$cronjob
->
onPrepare
();
$cronjob
->
onBeforeRun
();
$cronjob
->
onRunJob
();
$cronjob
->
onAfterRun
();
die
(
"finished.
\n
"
);
$argv
=
$_SERVER
[
'argv'
];
for
(
$a
=
0
;
$a
<
count
(
$argv
);
$a
++
)
{
if
(
$argv
[
$a
]
===
'--install'
||
$argv
[
$a
]
===
'install'
||
$argv
[
$a
]
===
'--update'
||
$argv
[
$a
]
===
'update'
)
{
$action
=
'install'
;
}
elseif
(
$argv
[
$a
]
===
'--uninstall'
||
$argv
[
$a
]
===
'uninstall'
)
{
$action
=
'uninstall'
;
}
elseif
(
substr
(
$argv
[
$a
],
-
4
)
===
'.pkg'
&&
is_file
(
$argv
[
$a
]))
{
$package
=
$argv
[
$a
];
}
else
{
die
(
'Unknown argument '
.
$argv
[
$a
]);
}
}
?>
if
(
$action
==
'uninstall'
)
{
die
(
'Automatic uninstall not supported, yet.'
);
}
else
{
try
{
$app
->
addon_installer
->
installAddon
(
$package
);
}
catch
(
Exception
$e
)
{
die
(
'Error: '
.
$e
->
getMessage
()
.
"
\n
"
);
}
}
\ No newline at end of file
server/lib/classes/ispconfig_addon_installer_base.inc.php
View file @
f8b551ed
...
...
@@ -72,6 +72,31 @@ class ispconfig_addon_installer_base {
}
}
protected
function
copyAddonFiles
()
{
global
$app
,
$conf
;
$install_dir
=
realpath
(
$conf
[
'rootpath'
]
.
'/..'
)
.
'/addons/'
.
$this
->
addon_ident
;
if
(
!
is_dir
(
$install_dir
))
{
if
(
!
$app
->
system
->
mkdir
(
$install_dir
,
false
,
0750
,
true
))
{
throw
new
AddonInstallerException
(
'Could not create addons dir '
.
$install_dir
);
}
}
if
(
is_dir
(
$this
->
temp_dir
.
'/install'
))
{
$ret
=
null
;
$retval
=
0
;
$command
=
'cp -rf '
.
escapeshellarg
(
$this
->
temp_dir
.
'/addon.ini'
)
.
' '
.
escapeshellarg
(
$this
->
temp_dir
.
'/'
.
$this
->
addon_ident
.
'addon.php'
)
.
' '
.
escapeshellarg
(
$this
->
temp_dir
.
'/install'
)
.
' '
.
escapeshellarg
(
$install_dir
.
'/'
);
exec
(
$command
,
$ret
,
$retval
);
if
(
$retval
!=
0
)
{
throw
new
AddonInstallerException
(
'Command '
.
$command
.
' failed with code '
.
$retval
);
}
return
true
;
}
else
{
return
false
;
}
}
protected
function
executeSqlStatements
()
{
global
$app
,
$conf
;
...
...
@@ -128,6 +153,7 @@ class ispconfig_addon_installer_base {
public
function
onBeforeInstall
()
{
}
public
function
onInstall
()
{
$this
->
copyAddonFiles
();
$this
->
copyInterfaceFiles
();
$this
->
copyServerFiles
();
$this
->
executeSqlStatements
();
...
...
@@ -138,6 +164,7 @@ class ispconfig_addon_installer_base {
public
function
onBeforeUpdate
()
{
}
public
function
onUpdate
()
{
$this
->
copyAddonFiles
();
$this
->
copyInterfaceFiles
();
$this
->
copyServerFiles
();
$this
->
executeSqlStatements
();
...
...
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