Skip to content

Commit 477d4e9

Browse files
committed
Initial commit of the interface part of the APS installer.
1 parent 80bee61 commit 477d4e9

28 files changed

+2790
-2
lines changed

install/dist/lib/fedora.lib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,10 @@ public function install_ispconfig()
865865
}
866866
}
867867

868+
//* Make the APS directories group writable
869+
exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages");
870+
exec("chmod -R 770 $install_dir/server/aps_packages");
871+
868872
//* make sure that the server config file (not the interface one) is only readable by the root user
869873
exec("chmod 600 $install_dir/server/lib/$configfile");
870874
exec("chown root:root $install_dir/server/lib/$configfile");

install/dist/lib/gentoo.lib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,10 @@ public function install_ispconfig()
858858
}
859859
}
860860

861+
//* Make the APS directories group writable
862+
exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages");
863+
exec("chmod -R 770 $install_dir/server/aps_packages");
864+
861865
//* make sure that the server config file (not the interface one) is only readable by the root user
862866
chmod($install_dir.'/server/lib/'.$configfile, 0600);
863867
chown($install_dir.'/server/lib/'.$configfile, 'root');

install/dist/lib/opensuse.lib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,10 @@ public function install_ispconfig()
903903
}
904904
}
905905

906+
//* Make the APS directories group writable
907+
exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages");
908+
exec("chmod -R 770 $install_dir/server/aps_packages");
909+
906910
//* make sure that the server config file (not the interface one) is only readable by the root user
907911
exec("chmod 600 $install_dir/server/lib/$configfile");
908912
exec("chown root:root $install_dir/server/lib/$configfile");

install/lib/installer_base.lib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,10 @@ public function install_ispconfig() {
17671767
}
17681768
}
17691769
}
1770+
1771+
//* Make the APS directories group writable
1772+
exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages");
1773+
exec("chmod -R 770 $install_dir/server/aps_packages");
17701774

17711775
//* make sure that the server config file (not the interface one) is only readable by the root user
17721776
chmod($install_dir.'/server/lib/'.$configfile, 0600);
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
-- --------------------------------------------------------
2+
3+
--
4+
-- Table structure for table `aps_instances`
5+
--
6+
7+
CREATE TABLE IF NOT EXISTS `aps_instances` (
8+
`id` int(4) NOT NULL AUTO_INCREMENT,
9+
`sys_userid` int(11) unsigned NOT NULL DEFAULT '0',
10+
`sys_groupid` int(11) unsigned NOT NULL DEFAULT '0',
11+
`sys_perm_user` varchar(5) DEFAULT NULL,
12+
`sys_perm_group` varchar(5) DEFAULT NULL,
13+
`sys_perm_other` varchar(5) DEFAULT NULL,
14+
`server_id` int(11) NOT NULL DEFAULT '0',
15+
`customer_id` int(4) NOT NULL,
16+
`package_id` int(4) NOT NULL,
17+
`instance_status` int(4) NOT NULL,
18+
PRIMARY KEY (`id`)
19+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
20+
21+
-- --------------------------------------------------------
22+
23+
--
24+
-- Table structure for table `aps_instances_settings`
25+
--
26+
27+
CREATE TABLE IF NOT EXISTS `aps_instances_settings` (
28+
`id` int(4) NOT NULL AUTO_INCREMENT,
29+
`server_id` int(11) NOT NULL DEFAULT '0',
30+
`instance_id` int(4) NOT NULL,
31+
`name` varchar(255) NOT NULL,
32+
`value` text NOT NULL,
33+
PRIMARY KEY (`id`)
34+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
35+
36+
-- --------------------------------------------------------
37+
38+
--
39+
-- Table structure for table `aps_packages`
40+
--
41+
42+
CREATE TABLE IF NOT EXISTS `aps_packages` (
43+
`id` int(4) NOT NULL AUTO_INCREMENT,
44+
`path` varchar(255) NOT NULL,
45+
`name` varchar(255) NOT NULL,
46+
`category` varchar(255) NOT NULL,
47+
`version` varchar(20) NOT NULL,
48+
`release` int(4) NOT NULL,
49+
`package_status` int(1) NOT NULL DEFAULT '2',
50+
PRIMARY KEY (`id`)
51+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
52+
53+
-- --------------------------------------------------------
54+
55+
--
56+
-- Tabellenstruktur für Tabelle `aps_settings`
57+
--
58+
59+
CREATE TABLE IF NOT EXISTS `aps_settings` (
60+
`id` int(4) NOT NULL AUTO_INCREMENT,
61+
`name` varchar(255) NOT NULL,
62+
`value` text NOT NULL,
63+
PRIMARY KEY (`id`),
64+
UNIQUE KEY `name` (`name`)
65+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
66+
67+
--
68+
-- Dumping data for table `aps_settings`
69+
--
70+
71+
INSERT INTO `aps_settings` (`id`, `name`, `value`) VALUES(1, 'ignore-php-extension', '');
72+
INSERT INTO `aps_settings` (`id`, `name`, `value`) VALUES(2, 'ignore-php-configuration', '');
73+
INSERT INTO `aps_settings` (`id`, `name`, `value`) VALUES(3, 'ignore-webserver-module', '');
74+
75+
ALTER TABLE `client` ADD `limit_aps` int(11) NOT NULL DEFAULT '0' AFTER `limit_webdav_user`;
76+
ALTER TABLE `client_template` ADD `limit_aps` int(11) NOT NULL DEFAULT '0' AFTER `limit_webdav_user`;

install/sql/ispconfig3.sql

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,67 @@ SET FOREIGN_KEY_CHECKS = 0;
5353
-- --------------------------------------------------------
5454
-- --------------------------------------------------------
5555

56+
--
57+
-- Table structure for table `aps_instances`
58+
--
59+
60+
CREATE TABLE IF NOT EXISTS `aps_instances` (
61+
`id` int(4) NOT NULL AUTO_INCREMENT,
62+
`server_id` int(11) NOT NULL DEFAULT '0',
63+
`customer_id` int(4) NOT NULL,
64+
`package_id` int(4) NOT NULL,
65+
`instance_status` int(4) NOT NULL,
66+
PRIMARY KEY (`id`)
67+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
68+
69+
-- --------------------------------------------------------
70+
71+
--
72+
-- Table structure for table `aps_instances_settings`
73+
--
74+
75+
CREATE TABLE IF NOT EXISTS `aps_instances_settings` (
76+
`id` int(4) NOT NULL AUTO_INCREMENT,
77+
`server_id` int(11) NOT NULL DEFAULT '0',
78+
`instance_id` int(4) NOT NULL,
79+
`name` varchar(255) NOT NULL,
80+
`value` text NOT NULL,
81+
PRIMARY KEY (`id`)
82+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
83+
84+
-- --------------------------------------------------------
85+
86+
--
87+
-- Table structure for table `aps_packages`
88+
--
89+
90+
CREATE TABLE IF NOT EXISTS `aps_packages` (
91+
`id` int(4) NOT NULL AUTO_INCREMENT,
92+
`path` varchar(255) NOT NULL,
93+
`name` varchar(255) NOT NULL,
94+
`category` varchar(255) NOT NULL,
95+
`version` varchar(20) NOT NULL,
96+
`release` int(4) NOT NULL,
97+
`package_status` int(1) NOT NULL DEFAULT '2',
98+
PRIMARY KEY (`id`)
99+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
100+
101+
-- --------------------------------------------------------
102+
103+
--
104+
-- Tabellenstruktur für Tabelle `aps_settings`
105+
--
106+
107+
CREATE TABLE IF NOT EXISTS `aps_settings` (
108+
`id` int(4) NOT NULL AUTO_INCREMENT,
109+
`name` varchar(255) NOT NULL,
110+
`value` text NOT NULL,
111+
PRIMARY KEY (`id`),
112+
UNIQUE KEY `name` (`name`)
113+
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
114+
115+
-- --------------------------------------------------------
116+
56117
--
57118
-- Table structure for table `attempts_login`
58119
--
@@ -123,6 +184,7 @@ CREATE TABLE `client` (
123184
`limit_shell_user` int(11) NOT NULL DEFAULT '0',
124185
`ssh_chroot` varchar(255) NOT NULL DEFAULT 'no,jailkit,ssh-chroot',
125186
`limit_webdav_user` int(11) NOT NULL DEFAULT '0',
187+
`limit_aps` int(11) NOT NULL DEFAULT '0',
126188
`default_dnsserver` int(11) unsigned NOT NULL DEFAULT '1',
127189
`limit_dns_zone` int(11) NOT NULL DEFAULT '-1',
128190
`limit_dns_slave_zone` int(11) NOT NULL DEFAULT '-1',
@@ -208,6 +270,7 @@ CREATE TABLE `client_template` (
208270
`limit_shell_user` int(11) NOT NULL default '0',
209271
`ssh_chroot` varchar(255) NOT NULL DEFAULT 'no',
210272
`limit_webdav_user` int(11) NOT NULL default '0',
273+
`limit_aps` int(11) NOT NULL DEFAULT '0',
211274
`limit_dns_zone` int(11) NOT NULL default '-1',
212275
`limit_dns_slave_zone` int(11) NOT NULL default '-1',
213276
`limit_dns_record` int(11) NOT NULL default '-1',
@@ -1670,6 +1733,14 @@ CREATE TABLE `web_traffic` (
16701733
-- --------------------------------------------------------
16711734
-- --------------------------------------------------------
16721735

1736+
--
1737+
-- Dumping data for table `aps_settings`
1738+
--
1739+
1740+
INSERT INTO `aps_settings` (`id`, `name`, `value`) VALUES(1, 'ignore-php-extension', '');
1741+
INSERT INTO `aps_settings` (`id`, `name`, `value`) VALUES(2, 'ignore-php-configuration', '');
1742+
INSERT INTO `aps_settings` (`id`, `name`, `value`) VALUES(3, 'ignore-webserver-module', '');
1743+
16731744
-- --------------------------------------------------------
16741745

16751746
--
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
/*
3+
Copyright (c) 2012, ISPConfig UG
4+
Contributors: web wack creations, http://www.web-wack.at
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
// Constants describing instances
32+
define('INSTANCE_PENDING', 0);
33+
define('INSTANCE_INSTALL', 1);
34+
define('INSTANCE_ERROR', 2);
35+
define('INSTANCE_SUCCESS', 3);
36+
define('INSTANCE_REMOVE', 4);
37+
38+
// Constants describing packages
39+
define('PACKAGE_LOCKED', 1);
40+
define('PACKAGE_ENABLED', 2);
41+
define('PACKAGE_OUTDATED', 3);
42+
define('PACKAGE_ERROR_NOMETA', 4);
43+
44+
class ApsBase
45+
{
46+
protected $app = null;
47+
protected $db = null;
48+
49+
protected $log_prefix = '';
50+
protected $fetch_url = '';
51+
protected $aps_version = '';
52+
protected $packages_dir = '';
53+
protected $temp_pkg_dir = '';
54+
protected $interface_pkg_dir = '';
55+
protected $interface_mode = false; // server mode by default
56+
57+
/**
58+
* Constructor
59+
*
60+
* @param $app the application instance (db handle + log method)
61+
* @param $interface_mode act in interface (true) or server mode (false)
62+
* @param $log_prefix a prefix to set before all log entries
63+
*/
64+
public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false)
65+
{
66+
$this->db = $app->db;
67+
$this->app = $app;
68+
69+
$this->log_prefix = $log_prefix;
70+
$this->interface_mode = $interface_mode;
71+
$this->fetch_url = 'apscatalog.com';
72+
$this->aps_version = '1';
73+
$this->packages_dir = ISPC_ROOT_PATH.'/aps_packages';
74+
$this->interface_pkg_dir = ISPC_ROOT_PATH.'/web/sites/aps_meta_packages';
75+
}
76+
77+
/**
78+
* Converts a given value to it's native representation in 1024 units
79+
*
80+
* @param $value the size to convert
81+
* @return integer and string
82+
*/
83+
public function convertSize($value)
84+
{
85+
$unit = array('Bytes', 'KB', 'MB', 'GB', 'TB');
86+
return @round($value/pow(1024, ($i = floor(log($value, 1024)))), 2).' '.$unit[$i];
87+
}
88+
89+
/**
90+
* Determine a specific xpath from a given SimpleXMLElement handle. If the
91+
* element is found, it's string representation is returned. If not,
92+
* the return value will stay empty
93+
*
94+
* @param $xml_handle the SimpleXMLElement handle
95+
* @param $query the XPath query
96+
* @param $array define whether to return an array or a string
97+
* @return $ret the return string
98+
*/
99+
protected function getXPathValue($xml_handle, $query, $array = false)
100+
{
101+
$ret = '';
102+
103+
$xp_result = @($xml_handle->xpath($query)) ? $xml_handle->xpath($query) : false;
104+
if($xp_result !== false) $ret = (($array === false) ? (string)$xp_result[0] : $xp_result);
105+
106+
return $ret;
107+
}
108+
}
109+
?>

0 commit comments

Comments
 (0)