diff --git a/README.md b/README.md index 4f170a5..1c15aee 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in ## Overview -Web IP address management application +phpIPAM is an open-source web IP address management application. Its goal is to provide light and simple IP address management application. It is ajax-based using jQuery libraries, it uses php scripts and javascript and some HTML5/CSS3 features, so some modern browser is preferred to be able to display javascript quickly and correctly. -**Shipped version:** 1.5.2~ynh1 +**Shipped version:** 1.5.2~ynh2 **Demo:** http://demo.phpipam.net diff --git a/README_fr.md b/README_fr.md index aa69b19..6f74c86 100644 --- a/README_fr.md +++ b/README_fr.md @@ -16,9 +16,9 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po ## Vue d’ensemble -Application web de gestion d'adresses IP +phpIPAM is an open-source web IP address management application. Its goal is to provide light and simple IP address management application. It is ajax-based using jQuery libraries, it uses php scripts and javascript and some HTML5/CSS3 features, so some modern browser is preferred to be able to display javascript quickly and correctly. -**Version incluse :** 1.5.2~ynh1 +**Version incluse :** 1.5.2~ynh2 **Démo :** http://demo.phpipam.net diff --git a/check_process b/check_process deleted file mode 100644 index 2a0a941..0000000 --- a/check_process +++ /dev/null @@ -1,23 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - is_public=1 - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=1 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&is_public=1& \ No newline at end of file diff --git a/conf/SCHEMA.sql b/conf/SCHEMA.sql index efdc38a..8cac74d 100644 --- a/conf/SCHEMA.sql +++ b/conf/SCHEMA.sql @@ -10,7 +10,7 @@ CREATE TABLE `instructions` ( /* insert default values */ INSERT INTO `instructions` (`id`, `instructions`) VALUES - (1,'You can write instructions under admin menu!'); + (1,'You can write instructions under admin menu!'); # Dump of table customers @@ -21,14 +21,14 @@ CREATE TABLE `customers` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(128) NOT NULL DEFAULT '', `address` varchar(255) DEFAULT NULL, - `postcode` int(8) DEFAULT NULL, + `postcode` VARCHAR(32) NULL DEFAULT NULL, `city` varchar(255) DEFAULT NULL, `state` varchar(255) DEFAULT NULL, - `lat` varchar(12) DEFAULT NULL, - `long` varchar(12) DEFAULT NULL, + `lat` varchar(31) DEFAULT NULL, + `long` varchar(31) DEFAULT NULL, `contact_person` text DEFAULT NULL, `contact_phone` varchar(32) DEFAULT NULL, - `contact_mail` varchar(255) DEFAULT NULL, + `contact_mail` varchar(254) DEFAULT NULL, `note` text DEFAULT NULL, `status` set('Active','Reserved','Inactive') DEFAULT 'Active', PRIMARY KEY (`id`), @@ -44,7 +44,7 @@ CREATE TABLE `ipaddresses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `subnetId` INT(11) UNSIGNED NULL DEFAULT NULL, `ip_addr` varchar(100) NOT NULL, - `is_gateway` TINYINT(1) NULL DEFAULT '0', + `is_gateway` BOOL NOT NULL DEFAULT '0', `description` varchar(64) DEFAULT NULL, `hostname` varchar(255) DEFAULT NULL, `mac` varchar(20) DEFAULT NULL, @@ -55,8 +55,8 @@ CREATE TABLE `ipaddresses` ( `port` varchar(32) DEFAULT NULL, `note` text, `lastSeen` DATETIME NULL DEFAULT '1970-01-01 00:00:01', - `excludePing` BINARY NULL DEFAULT '0', - `PTRignore` BINARY NULL DEFAULT '0', + `excludePing` BOOL NOT NULL DEFAULT '0', + `PTRignore` BOOL NOT NULL DEFAULT '0', `PTR` INT(11) UNSIGNED NULL DEFAULT '0', `firewallAddressObject` VARCHAR(100) NULL DEFAULT NULL, `editDate` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP, @@ -71,16 +71,16 @@ CREATE TABLE `ipaddresses` ( /* insert default values */ INSERT INTO `ipaddresses` (`id`, `subnetId`, `ip_addr`, `description`, `hostname`, `state`) VALUES - (1,3,'168427779','Server1','server1.cust1.local',2), - (2,3,'168427780','Server2','server2.cust1.local',2), - (3,3,'168427781','Server3','server3.cust1.local',3), - (4,3,'168427782','Server4','server4.cust1.local',3), - (5,3,'168428021','Gateway',NULL,2), - (6,4,'168428286','Gateway',NULL,2), - (7,4,'168428042','Server1','ser1.client2.local',2), - (8,6,'172037636','DHCP range',NULL,4), - (9,6,'172037637','DHCP range',NULL,4), - (10,6,'172037638','DHCP range',NULL,4); + (1,3,'168427779','Server1','server1.cust1.local',2), + (2,3,'168427780','Server2','server2.cust1.local',2), + (3,3,'168427781','Server3','server3.cust1.local',3), + (4,3,'168427782','Server4','server4.cust1.local',3), + (5,3,'168428021','Gateway',NULL,2), + (6,4,'168428286','Gateway',NULL,2), + (7,4,'168428042','Server1','ser1.client2.local',2), + (8,6,'172037636','DHCP range',NULL,4), + (9,6,'172037637','DHCP range',NULL,4), + (10,6,'172037638','DHCP range',NULL,4); # Dump of table logs @@ -93,8 +93,8 @@ CREATE TABLE `logs` ( `date` varchar(32) DEFAULT NULL, `username` varchar(255) DEFAULT NULL, `ipaddr` varchar(64) DEFAULT NULL, - `command` varchar(128) DEFAULT '0', - `details` varchar(1024) DEFAULT NULL, + `command` text DEFAULT NULL, + `details` text DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -108,6 +108,7 @@ CREATE TABLE `requests` ( `subnetId` INT(11) UNSIGNED NULL DEFAULT NULL, `ip_addr` varchar(100) DEFAULT NULL, `description` varchar(64) DEFAULT NULL, + `mac` varchar(20) DEFAULT NULL, `hostname` varchar(255) DEFAULT NULL, `state` INT NULL DEFAULT '2', `owner` varchar(128) DEFAULT NULL, @@ -134,6 +135,7 @@ CREATE TABLE `sections` ( `subnetOrdering` VARCHAR(16) NULL DEFAULT NULL, `order` INT(3) NULL DEFAULT NULL, `editDate` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP, + `showSubnet` BOOL NOT NULL DEFAULT '1', `showVLAN` BOOL NOT NULL DEFAULT '0', `showVRF` BOOL NOT NULL DEFAULT '0', `showSupernetOnly` BOOL NOT NULL DEFAULT '0', @@ -144,8 +146,8 @@ CREATE TABLE `sections` ( /* insert default values */ INSERT INTO `sections` (`id`, `name`, `description`, `permissions`) VALUES - (1,'Customers','Section for customers','{\"3\":\"1\",\"2\":\"2\"}'), - (2,'IPv6','Section for IPv6 addresses','{\"3\":\"1\",\"2\":\"2\"}'); + (1,'Customers','Section for customers','{\"3\":\"1\",\"2\":\"2\"}'), + (2,'IPv6','Section for IPv6 addresses','{\"3\":\"1\",\"2\":\"2\"}'); # Dump of table settings @@ -156,7 +158,7 @@ CREATE TABLE `settings` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `siteTitle` varchar(64) DEFAULT NULL, `siteAdminName` varchar(64) DEFAULT NULL, - `siteAdminMail` varchar(64) DEFAULT NULL, + `siteAdminMail` varchar(254) DEFAULT NULL, `siteDomain` varchar(32) DEFAULT NULL, `siteURL` varchar(64) DEFAULT NULL, `siteLoginText` varchar(128) DEFAULT NULL, @@ -179,6 +181,7 @@ CREATE TABLE `settings` ( `enablePSTN` TINYINT(1) NULL DEFAULT '0', `enableChangelog` TINYINT(1) NOT NULL DEFAULT '1', `enableCustomers` TINYINT(1) NOT NULL DEFAULT '1', + `enableVaults` TINYINT(1) NOT NULL DEFAULT '1', `link_field` VARCHAR(32) NULL DEFAULT '0', `version` varchar(5) DEFAULT NULL, `dbversion` INT(8) NOT NULL DEFAULT '0', @@ -199,9 +202,9 @@ CREATE TABLE `settings` ( `api` BINARY NOT NULL DEFAULT '0', `scanPingPath` VARCHAR(64) NULL DEFAULT '/bin/ping', `scanFPingPath` VARCHAR(64) NULL DEFAULT '/bin/fping', - `scanPingType` SET('ping','pear','fping') NOT NULL DEFAULT 'ping', + `scanPingType` ENUM('none','ping','pear','fping') NOT NULL DEFAULT 'ping', `scanMaxThreads` INT(4) NULL DEFAULT '128', - `prettyLinks` SET("Yes","No") NOT NULL DEFAULT 'No', + `prettyLinks` ENUM('Yes','No') NOT NULL DEFAULT 'No', `hiddenCustomFields` text NULL, `inactivityTimeout` INT(5) NOT NULL DEFAULT '3600', `updateTags` TINYINT(1) NULL DEFAULT '0', @@ -211,13 +214,13 @@ CREATE TABLE `settings` ( `decodeMAC` TINYINT(1) NULL DEFAULT '1', `tempShare` TINYINT(1) NULL DEFAULT '0', `tempAccess` TEXT NULL, - `log` SET('Database','syslog', 'both') NOT NULL DEFAULT 'Database', + `log` ENUM('Database','syslog', 'both') NOT NULL DEFAULT 'Database', `subnetView` TINYINT NOT NULL DEFAULT '0', `enableCircuits` TINYINT(1) NULL DEFAULT '1', `enableRouting` TINYINT(1) NULL DEFAULT '0', `permissionPropagate` TINYINT(1) NULL DEFAULT '1', `passwordPolicy` VARCHAR(1024) NULL DEFAULT '{\"minLength\":8,\"maxLength\":0,\"minNumbers\":0,\"minLetters\":0,\"minLowerCase\":0,\"minUpperCase\":0,\"minSymbols\":0,\"maxSymbols\":0,\"allowedSymbols\":\"#,_,-,!,[,],=,~\"}', - `2fa_provider` SET('none','Google_Authenticator') NULL DEFAULT 'none', + `2fa_provider` ENUM('none','Google_Authenticator') NULL DEFAULT 'none', `2fa_name` VARCHAR(32) NULL DEFAULT 'phpipam', `2fa_length` INT(2) NULL DEFAULT '16', `2fa_userchange` BOOL NOT NULL DEFAULT '1', @@ -226,7 +229,7 @@ CREATE TABLE `settings` ( /* insert default values */ INSERT INTO `settings` (`id`, `siteTitle`, `siteAdminName`, `siteAdminMail`, `siteDomain`, `siteURL`, `domainAuth`, `enableIPrequests`, `enableVRF`, `enableDNSresolving`, `version`, `donate`, `IPfilter`, `vlanDuplicate`, `subnetOrdering`, `visualLimit`) VALUES - (1, 'phpipam IP address management', 'Sysadmin', 'admin@domain.local', 'domain.local', 'http://yourpublicurl.com', 0, 0, 0, 0, '1.4', 0, 'mac;owner;state;switch;note;firewallAddressObject', 1, 'subnet,asc', 24); + (1, 'phpipam IP address management', 'Sysadmin', 'admin@domain.local', 'domain.local', 'http://yourpublicurl.com', 0, 0, 0, 0, '1.4', 0, 'mac;owner;state;switch;note;firewallAddressObject', 1, 'subnet,asc', 24); # Dump of table settingsMail @@ -235,21 +238,21 @@ DROP TABLE IF EXISTS `settingsMail`; CREATE TABLE `settingsMail` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `mtype` set('localhost','smtp') NOT NULL DEFAULT 'localhost', - `msecure` SET('none','ssl','tls') NOT NULL DEFAULT 'none', - `mauth` set('yes','no') NOT NULL DEFAULT 'no', + `mtype` ENUM('localhost','smtp') NOT NULL DEFAULT 'localhost', + `msecure` ENUM('none','ssl','tls') NOT NULL DEFAULT 'none', + `mauth` ENUM('yes','no') NOT NULL DEFAULT 'no', `mserver` varchar(128) DEFAULT NULL, `mport` int(5) DEFAULT '25', - `muser` varchar(64) DEFAULT NULL, - `mpass` varchar(64) DEFAULT NULL, - `mAdminName` varchar(64) DEFAULT NULL, - `mAdminMail` varchar(64) DEFAULT NULL, + `muser` varchar(254) DEFAULT NULL, + `mpass` varchar(128) DEFAULT NULL, + `mAdminName` varchar(128) DEFAULT NULL, + `mAdminMail` varchar(254) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /* insert default values */ INSERT INTO `settingsMail` (`id`, `mtype`) VALUES - (1, 'localhost'); + (1, 'localhost'); # Dump of table subnets @@ -266,21 +269,22 @@ CREATE TABLE `subnets` ( `firewallAddressObject` VARCHAR(100) NULL DEFAULT NULL, `vrfId` INT(11) UNSIGNED NULL DEFAULT NULL, `masterSubnetId` INT(11) UNSIGNED NOT NULL default 0, - `allowRequests` tinyint(1) DEFAULT '0', + `allowRequests` BOOL NOT NULL DEFAULT '0', `vlanId` INT(11) UNSIGNED NULL DEFAULT NULL, - `showName` tinyint(1) DEFAULT '0', + `showName` BOOL NOT NULL DEFAULT '0', `device` INT UNSIGNED NULL DEFAULT '0', `permissions` varchar(1024) DEFAULT NULL, - `pingSubnet` BOOL NULL DEFAULT '0', - `discoverSubnet` BINARY(1) NULL DEFAULT '0', - `resolveDNS` TINYINT(1) NULL DEFAULT '0', - `DNSrecursive` TINYINT(1) NULL DEFAULT '0', - `DNSrecords` TINYINT(1) NULL DEFAULT '0', + `pingSubnet` BOOL NOT NULL DEFAULT '0', + `discoverSubnet` BOOL NOT NULL DEFAULT '0', + `resolveDNS` BOOL NOT NULL DEFAULT '0', + `DNSrecursive` BOOL NOT NULL DEFAULT '0', + `DNSrecords` BOOL NOT NULL DEFAULT '0', `nameserverId` INT(11) NULL DEFAULT '0', `scanAgent` INT(11) DEFAULT NULL, `customer_id` INT(11) unsigned NULL default NULL, - `isFolder` BOOL NULL DEFAULT '0', - `isFull` TINYINT(1) NULL DEFAULT '0', + `isFolder` BOOL NOT NULL DEFAULT '0', + `isFull` BOOL NOT NULL DEFAULT '0', + `isPool` BOOL NOT NULL DEFAULT '0', `state` INT(3) NULL DEFAULT '2', `threshold` int(3) NULL DEFAULT 0, `location` INT(11) UNSIGNED NULL DEFAULT NULL, @@ -298,12 +302,12 @@ CREATE TABLE `subnets` ( /* insert default values */ INSERT INTO `subnets` (`id`, `subnet`, `mask`, `sectionId`, `description`, `vrfId`, `masterSubnetId`, `allowRequests`, `vlanId`, `showName`, `permissions`, `isFolder`) VALUES - (1,'336395549904799703390415618052362076160','64',2,'Private subnet 1',0,'0',1,1,1,'{\"3\":\"1\",\"2\":\"2\"}',0), - (2,'168427520','16','1','Business customers',0,'0',1,0,1,'{\"3\":\"1\",\"2\":\"2\"}',0), - (3,'168427776','24','1','Customer 1',0,'2',1,0,1,'{\"3\":\"1\",\"2\":\"2\"}',0), - (4,'168428032','24','1','Customer 2',0,'2',1,0,1,'{\"3\":\"1\",\"2\":\"2\"}',0), - (5, '0', '', 1, 'My folder', 0, 0, 0, 0, 0, '{\"3\":\"1\",\"2\":\"2\"}', 1), - (6, '172037632', '24', 1, 'DHCP range', 0, 5, 0, 0, 1, '{\"3\":\"1\",\"2\":\"2\"}', 0); + (1,'336395549904799703390415618052362076160','64',2,'Private subnet 1',0,'0',1,1,1,'{\"3\":\"1\",\"2\":\"2\"}',0), + (2,'168427520','16','1','Business customers',0,'0',1,0,1,'{\"3\":\"1\",\"2\":\"2\"}',0), + (3,'168427776','24','1','Customer 1',0,'2',1,0,1,'{\"3\":\"1\",\"2\":\"2\"}',0), + (4,'168428032','24','1','Customer 2',0,'2',1,0,1,'{\"3\":\"1\",\"2\":\"2\"}',0), + (5, '0', '', 1, 'My folder', 0, 0, 0, 0, 0, '{\"3\":\"1\",\"2\":\"2\"}', 1), + (6, '172037632', '24', 1, 'DHCP range', 0, 5, 0, 0, 1, '{\"3\":\"1\",\"2\":\"2\"}', 0); # Dump of table devices @@ -354,8 +358,8 @@ CREATE TABLE `userGroups` ( /* insert default values */ INSERT INTO `userGroups` (`g_id`, `g_name`, `g_desc`) VALUES - (2,'Operators','default Operator group'), - (3,'Guests','default Guest group (viewers)'); + (2,'Operators','default Operator group'), + (3,'Guests','default Guest group (viewers)'); # Dump of table users @@ -370,28 +374,28 @@ CREATE TABLE `users` ( `groups` varchar(1024) COLLATE utf8_bin DEFAULT NULL, `role` text CHARACTER SET utf8, `real_name` varchar(128) CHARACTER SET utf8 DEFAULT NULL, - `email` varchar(64) CHARACTER SET utf8 DEFAULT NULL, + `email` varchar(254) CHARACTER SET utf8 DEFAULT NULL, `domainUser` binary(1) DEFAULT '0', `widgets` VARCHAR(1024) NULL DEFAULT 'statistics;favourite_subnets;changelog;top10_hosts_v4', `lang` INT(11) UNSIGNED NULL DEFAULT '9', `favourite_subnets` VARCHAR(1024) NULL DEFAULT NULL, - `disabled` SET('Yes','No') NOT NULL DEFAULT 'No', - `mailNotify` SET('Yes','No') NULL DEFAULT 'No', - `mailChangelog` SET('Yes','No') NULL DEFAULT 'No', - `passChange` SET('Yes','No') NOT NULL DEFAULT 'No', + `disabled` ENUM('Yes','No') NOT NULL DEFAULT 'No', + `mailNotify` ENUM('Yes','No') NOT NULL DEFAULT 'No', + `mailChangelog` ENUM('Yes','No') NOT NULL DEFAULT 'No', + `passChange` ENUM('Yes','No') NOT NULL DEFAULT 'No', `editDate` TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP, `lastLogin` TIMESTAMP NULL, `lastActivity` TIMESTAMP NULL, - `compressOverride` SET('default','Uncompress') NOT NULL DEFAULT 'default', + `compressOverride` ENUM('default','Uncompress') NOT NULL DEFAULT 'default', `hideFreeRange` tinyint(1) DEFAULT '0', - `menuType` SET('Static','Dynamic') NULL DEFAULT 'Dynamic', + `menuType` ENUM('Static','Dynamic') NOT NULL DEFAULT 'Dynamic', `menuCompact` TINYINT NULL DEFAULT '1', `2fa` BOOL NOT NULL DEFAULT '0', `2fa_secret` VARCHAR(32) NULL DEFAULT NULL, `theme` VARCHAR(32) NULL DEFAULT '', `token` VARCHAR(24) NULL DEFAULT NULL, `token_valid_until` DATETIME NULL, - `module_permissions` varchar(255) COLLATE utf8_bin DEFAULT '{"vlan":"1","vrf":"1","pdns":"1","circuits":"1","racks":"1","nat":"1","pstn":"1","customers":"1","locations":"1","devices":"1"}', + `module_permissions` varchar(255) COLLATE utf8_bin DEFAULT '{"vlan":"1","l2dom":"1","vrf":"1","pdns":"1","circuits":"1","racks":"1","nat":"1","pstn":"1","customers":"1","locations":"1","devices":"1","routing":"1","vaults":"1"}', `compress_actions` TINYINT(1) NULL DEFAULT '1', PRIMARY KEY (`username`), UNIQUE KEY `id_2` (`id`) @@ -399,7 +403,7 @@ CREATE TABLE `users` ( /* insert default values */ INSERT INTO `users` (`id`, `username`, `password`, `groups`, `role`, `real_name`, `email`, `domainUser`,`widgets`, `passChange`) VALUES - (1,'Admin',X'243624726F756E64733D33303030244A51454536644C394E70766A6546733424524B3558336F6132382E557A742F6835564166647273766C56652E3748675155594B4D58544A5573756438646D5766507A5A51506252626B38784A6E314B797974342E64576D346E4A4959684156326D624F5A33672E',X'','Administrator','phpIPAM Admin','admin@domain.local',X'30','statistics;favourite_subnets;changelog;access_logs;error_logs;top10_hosts_v4', 'Yes'); + (1,'Admin',X'243624726F756E64733D33303030244A51454536644C394E70766A6546733424524B3558336F6132382E557A742F6835564166647273766C56652E3748675155594B4D58544A5573756438646D5766507A5A51506252626B38784A6E314B797974342E64576D346E4A4959684156326D624F5A33672E',X'','Administrator','phpIPAM Admin','admin@domain.local',X'30','statistics;favourite_subnets;changelog;access_logs;error_logs;top10_hosts_v4', 'Yes'); # Dump of table lang @@ -415,18 +419,20 @@ CREATE TABLE `lang` ( /* insert default values */ INSERT INTO `lang` (`l_id`, `l_code`, `l_name`) VALUES - (1, 'en_GB.UTF-8', 'English'), - (2, 'sl_SI.UTF-8', 'Slovenščina'), - (3, 'fr_FR.UTF-8', 'Français'), - (4, 'nl_NL.UTF-8', 'Nederlands'), - (5, 'de_DE.UTF-8', 'Deutsch'), - (6, 'pt_BR.UTF-8', 'Brazil'), - (7, 'es_ES.UTF-8', 'Español'), - (8, 'cs_CZ.UTF-8', 'Czech'), - (9, 'en_US.UTF-8', 'English (US)'), - (10,'ru_RU.UTF-8', 'Russian'), - (11,'zh_CN.UTF-8', 'Chinese'), - (12,'ja_JP.UTF-8', 'Japanese'); + (1, 'en_GB.UTF-8', 'English'), + (2, 'sl_SI.UTF-8', 'Slovenščina'), + (3, 'fr_FR.UTF-8', 'Français'), + (4, 'nl_NL.UTF-8', 'Nederlands'), + (5, 'de_DE.UTF-8', 'Deutsch'), + (6, 'pt_BR.UTF-8', 'Brazil'), + (7, 'es_ES.UTF-8', 'Español'), + (8, 'cs_CZ.UTF-8', 'Czech'), + (9, 'en_US.UTF-8', 'English (US)'), + (10, 'ru_RU.UTF-8', 'Russian'), + (11, 'zh_CN.UTF-8', 'Chinese'), + (12, 'ja_JP.UTF-8', 'Japanese'), + (13, 'zh_TW.UTF-8', 'Chinese traditional (繁體中文)'), + (14, 'it_IT.UTF-8', 'Italian'); # Dump of table vlans @@ -448,8 +454,8 @@ CREATE TABLE `vlans` ( /* insert default values */ INSERT INTO `vlans` (`vlanId`, `name`, `number`, `description`) VALUES - (1,'IPv6 private 1',2001,'IPv6 private 1 subnets'), - (2,'Servers DMZ',4001,'DMZ public'); + (1,'IPv6 private 1',2001,'IPv6 private 1 subnets'), + (2,'Servers DMZ',4001,'DMZ public'); # Dump of table vlanDomains @@ -466,7 +472,7 @@ CREATE TABLE `vlanDomains` ( /* insert default values */ INSERT INTO `vlanDomains` (`id`, `name`, `description`, `permissions`) VALUES - (1, 'default', 'default L2 domain', NULL); + (1, 'default', 'default L2 domain', NULL); # Dump of table vrf @@ -502,7 +508,7 @@ CREATE TABLE `nameservers` ( /* insert default values */ INSERT INTO `nameservers` (`name`, `namesrv1`, `description`, `permissions`) VALUES - ('Google NS', '8.8.8.8;8.8.4.4', 'Google public nameservers', '1;2'); + ('Google NS', '8.8.8.8;8.8.4.4', 'Google public nameservers', '1;2'); @@ -536,10 +542,10 @@ CREATE TABLE `changelog` ( `ctype` set('ip_addr','subnet','section') NOT NULL DEFAULT '', `coid` int(11) unsigned NOT NULL, `cuser` int(11) unsigned NOT NULL, - `caction` set('add','edit','delete','truncate','resize','perm_change') NOT NULL DEFAULT 'edit', - `cresult` set('error','success') NOT NULL DEFAULT '', + `caction` ENUM('add','edit','delete','truncate','resize','perm_change') NOT NULL DEFAULT 'edit', + `cresult` ENUM('error','success') NOT NULL DEFAULT 'success', `cdate` datetime NOT NULL, - `cdiff` varchar(2048) DEFAULT NULL, + `cdiff` text DEFAULT NULL, PRIMARY KEY (`cid`), KEY `coid` (`coid`), KEY `ctype` (`ctype`) @@ -565,24 +571,25 @@ CREATE TABLE `widgets` ( /* insert default values */ INSERT INTO `widgets` (`wid`, `wtitle`, `wdescription`, `wfile`, `wparams`, `whref`, `wsize`, `wadminonly`, `wactive`) VALUES - (1, 'Statistics', 'Shows some statistics on number of hosts, subnets', 'statistics', NULL, 'no', '4', 'no', 'yes'), - (2, 'Favourite subnets', 'Shows 5 favourite subnets', 'favourite_subnets', NULL, 'yes', '8', 'no', 'yes'), - (3, 'Top 10 IPv4 subnets by number of hosts', 'Shows graph of top 10 IPv4 subnets by number of hosts', 'top10_hosts_v4', NULL, 'yes', '6', 'no', 'yes'), - (4, 'Top 10 IPv6 subnets by number of hosts', 'Shows graph of top 10 IPv6 subnets by number of hosts', 'top10_hosts_v6', NULL, 'yes', '6', 'no', 'yes'), - (5, 'Top 10 IPv4 subnets by usage percentage', 'Shows graph of top 10 IPv4 subnets by usage percentage', 'top10_percentage', NULL, 'yes', '6', 'no', 'yes'), - (6, 'Last 5 change log entries', 'Shows last 5 change log entries', 'changelog', NULL, 'yes', '12', 'no', 'yes'), - (7, 'Active IP addresses requests', 'Shows list of active IP address request', 'requests', NULL, 'yes', '6', 'yes', 'yes'), - (8, 'Last 5 informational logs', 'Shows list of last 5 informational logs', 'access_logs', NULL, 'yes', '6', 'yes', 'yes'), - (9, 'Last 5 warning / error logs', 'Shows list of last 5 warning and error logs', 'error_logs', NULL, 'yes', '6', 'yes', 'yes'), - (10,'Tools menu', 'Shows quick access to tools menu', 'tools', NULL, 'yes', '6', 'no', 'yes'), - (11,'IP Calculator', 'Shows IP calculator as widget', 'ipcalc', NULL, 'yes', '6', 'no', 'yes'), - (12,'IP Request', 'IP Request widget', 'iprequest', NULL, 'no', '6', 'no', 'yes'), - (13,'Threshold', 'Shows threshold usage for top 5 subnets', 'threshold', NULL, 'yes', '6', 'no', 'yes'), - (14,'Inactive hosts', 'Shows list of inactive hosts for defined period', 'inactive-hosts', 86400, 'yes', '6', 'yes', 'yes'), - (15, 'Locations', 'Shows map of locations', 'locations', NULL, 'yes', '6', 'no', 'yes'), + (1, 'Statistics', 'Shows some statistics on number of hosts, subnets', 'statistics', NULL, 'no', '4', 'no', 'yes'), + (2, 'Favourite subnets', 'Shows 5 favourite subnets', 'favourite_subnets', NULL, 'yes', '8', 'no', 'yes'), + (3, 'Top 10 IPv4 subnets by number of hosts', 'Shows graph of top 10 IPv4 subnets by number of hosts', 'top10_hosts_v4', NULL, 'yes', '6', 'no', 'yes'), + (4, 'Top 10 IPv6 subnets by number of hosts', 'Shows graph of top 10 IPv6 subnets by number of hosts', 'top10_hosts_v6', NULL, 'yes', '6', 'no', 'yes'), + (5, 'Top 10 IPv4 subnets by usage percentage', 'Shows graph of top 10 IPv4 subnets by usage percentage', 'top10_percentage', NULL, 'yes', '6', 'no', 'yes'), + (6, 'Last 5 change log entries', 'Shows last 5 change log entries', 'changelog', NULL, 'yes', '12', 'no', 'yes'), + (7, 'Active IP addresses requests', 'Shows list of active IP address request', 'requests', NULL, 'yes', '6', 'yes', 'yes'), + (8, 'Last 5 informational logs', 'Shows list of last 5 informational logs', 'access_logs', NULL, 'yes', '6', 'yes', 'yes'), + (9, 'Last 5 warning / error logs', 'Shows list of last 5 warning and error logs', 'error_logs', NULL, 'yes', '6', 'yes', 'yes'), + (10,'Tools menu', 'Shows quick access to tools menu', 'tools', NULL, 'yes', '6', 'no', 'yes'), + (11,'IP Calculator', 'Shows IP calculator as widget', 'ipcalc', NULL, 'yes', '6', 'no', 'yes'), + (12,'IP Request', 'IP Request widget', 'iprequest', NULL, 'no', '6', 'no', 'yes'), + (13,'Threshold', 'Shows threshold usage for top 5 subnets', 'threshold', NULL, 'yes', '6', 'no', 'yes'), + (14,'Inactive hosts', 'Shows list of inactive hosts for defined period', 'inactive-hosts', 86400, 'yes', '6', 'yes', 'yes'), + (15, 'Locations', 'Shows map of locations', 'locations', NULL, 'yes', '6', 'no', 'yes'), (16, 'Bandwidth calculator', 'Calculate bandwidth', 'bw_calculator', NULL, 'no', '6', 'no', 'yes'), (17, 'Customers', 'Shows customer list', 'customers', NULL, 'yes', '6', 'no', 'yes'), - (18, 'User Instructions', 'Shows user instructions', 'instructions', NULL, 'yes', '6', 'no', 'yes'); + (18, 'User Instructions', 'Shows user instructions', 'instructions', NULL, 'yes', '6', 'no', 'yes'), + (19, 'MAC lookup', 'Shows MAC address vendor', 'mac-lookup', NULL, 'yes', '6', 'no', 'yes'); @@ -599,15 +606,15 @@ CREATE TABLE `deviceTypes` ( /* insert default values */ INSERT INTO `deviceTypes` (`tid`, `tname`, `tdescription`) VALUES - (1, 'Switch', 'Switch'), - (2, 'Router', 'Router'), - (3, 'Firewall', 'Firewall'), - (4, 'Hub', 'Hub'), - (5, 'Wireless', 'Wireless'), - (6, 'Database', 'Database'), - (7, 'Workstation', 'Workstation'), - (8, 'Laptop', 'Laptop'), - (9, 'Other', 'Other'); + (1, 'Switch', 'Switch'), + (2, 'Router', 'Router'), + (3, 'Firewall', 'Firewall'), + (4, 'Hub', 'Hub'), + (5, 'Wireless', 'Wireless'), + (6, 'Database', 'Database'), + (7, 'Workstation', 'Workstation'), + (8, 'Laptop', 'Laptop'), + (9, 'Other', 'Other'); # Dump of table loginAttempts @@ -630,17 +637,17 @@ DROP TABLE IF EXISTS `usersAuthMethod`; CREATE TABLE `usersAuthMethod` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `type` set('local','http','AD','LDAP','NetIQ','Radius','SAML2') NOT NULL DEFAULT 'local', - `params` varchar(2048) DEFAULT NULL, - `protected` set('Yes','No') NOT NULL DEFAULT 'Yes', + `type` ENUM('local','http','AD','LDAP','NetIQ','Radius','SAML2') NOT NULL DEFAULT 'local', + `params` text DEFAULT NULL, + `protected` ENUM('Yes','No') NOT NULL DEFAULT 'Yes', `description` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /* insert default values */ INSERT INTO `usersAuthMethod` (`id`, `type`, `params`, `protected`, `description`) VALUES - (1, 'local', NULL, 'Yes', 'Local database'), - (2, 'http', NULL, 'Yes', 'Apache authentication'); + (1, 'local', NULL, 'Yes', 'Local database'), + (2, 'http', NULL, 'Yes', 'Apache authentication'); # Dump of table ipTags @@ -661,10 +668,10 @@ CREATE TABLE `ipTags` ( /* insert default values */ INSERT INTO `ipTags` (`id`, `type`, `showtag`, `bgcolor`, `fgcolor`, `compress`, `locked`, `updateTag`) VALUES - (1, 'Offline', 1, '#f59c99', '#ffffff', 'No', 'Yes', 1), - (2, 'Used', 0, '#a9c9a4', '#ffffff', 'No', 'Yes', 1), - (3, 'Reserved', 1, '#9ac0cd', '#ffffff', 'No', 'Yes', 1), - (4, 'DHCP', 1, '#c9c9c9', '#ffffff', 'Yes', 'Yes', 1); + (1, 'Offline', 1, '#f59c99', '#ffffff', 'No', 'Yes', 1), + (2, 'Used', 0, '#a9c9a4', '#ffffff', 'No', 'Yes', 1), + (3, 'Reserved', 1, '#9ac0cd', '#ffffff', 'No', 'Yes', 1), + (4, 'DHCP', 1, '#c9c9c9', '#ffffff', 'Yes', 'Yes', 1); # Dump of table firewallZones @@ -709,6 +716,7 @@ DROP TABLE IF EXISTS `firewallZoneSubnet`; CREATE TABLE `firewallZoneSubnet` ( `zoneId` INT NOT NULL, `subnetId` INT(11) NOT NULL, + PRIMARY KEY (`zoneId`,`subnetId`), INDEX `fk_zoneId_idx` (`zoneId` ASC), INDEX `fk_subnetId_idx` (`subnetId` ASC), CONSTRAINT `fk_zoneId` @@ -741,7 +749,7 @@ CREATE TABLE `scanAgents` ( /* insert default values */ INSERT INTO `scanAgents` (`id`, `name`, `description`, `type`) VALUES - (1, 'localhost', 'Scanning from local machine', 'direct'); + (1, 'localhost', 'Scanning from local machine', 'direct'); # Dump of table nat @@ -807,8 +815,8 @@ CREATE TABLE `locations` ( `name` varchar(128) NOT NULL DEFAULT '', `description` text, `address` VARCHAR(128) NULL DEFAULT NULL, - `lat` varchar(12) DEFAULT NULL, - `long` varchar(12) DEFAULT NULL, + `lat` varchar(31) DEFAULT NULL, + `long` varchar(31) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -913,7 +921,8 @@ DROP TABLE IF EXISTS `circuitsLogicalMapping`; CREATE TABLE `circuitsLogicalMapping` ( `logicalCircuit_id` int(11) unsigned NOT NULL, `circuit_id` int(11) unsigned NOT NULL, - `order` int(10) unsigned DEFAULT NULL + `order` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`logicalCircuit_id`, `circuit_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -990,9 +999,64 @@ CREATE TABLE `routing_subnets` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +# Dump of table vaults +# ------------------------------------------------------------ +DROP TABLE IF EXISTS `vaults`; + +CREATE TABLE `vaults` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(64) NOT NULL DEFAULT '', + `type` enum('passwords','certificates') NOT NULL DEFAULT 'passwords', + `description` text, + `test` char(128) NOT NULL DEFAULT '', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +# Dump of table vaultItems +# ------------------------------------------------------------ +DROP TABLE IF EXISTS `vaultItems`; + +CREATE TABLE `vaultItems` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `vaultId` int(11) unsigned NOT NULL, + `type` enum('password','certificate') NOT NULL DEFAULT 'password', + `type_certificate` enum('public','pkcs12','certificate','website') NOT NULL DEFAULT 'public', + `values` text, + PRIMARY KEY (`id`), + KEY `vaultId` (`vaultId`), + CONSTRAINT `vaultItems_ibfk_1` FOREIGN KEY (`vaultId`) REFERENCES `vaults` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +# Dump of table nominatim +# ------------------------------------------------------------ +DROP TABLE IF EXISTS `nominatim`; + +CREATE TABLE `nominatim` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `url` varchar(255) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/* insert default values */ +INSERT INTO `nominatim` (`id`, `url`) VALUES (1, 'https://nominatim.openstreetmap.org/search'); + + +# Dump of table nominatim_cache +# ------------------------------------------------------------ +DROP TABLE IF EXISTS `nominatim_cache`; + +CREATE TABLE `nominatim_cache` ( + `sha256` binary(32) NOT NULL, + `date` timestamp NOT NULL DEFAULT current_timestamp(), + `query` text NOT NULL, + `lat_lng` text NOT NULL, + PRIMARY KEY (`sha256`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + # Dump of table -- for autofix comment, leave as it is # ------------------------------------------------------------ -UPDATE `settings` SET `version` = "1.43"; -UPDATE `settings` SET `dbversion` = 25; +UPDATE `settings` SET `version` = "1.52"; +UPDATE `settings` SET `dbversion` = 39; diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 278c275..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/phpipam/phpipam/releases/download/v1.5.1/phpipam-v1.5.1.zip -SOURCE_SUM=9ced23778f6455d3db8975e09bc5b2f605add9f7feda1568b716803850d19c58 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=zip -SOURCE_IN_SUBDIR=true -SOURCE_EXTRACT=true -SOURCE_FILENAME=phpipam.zip diff --git a/conf/config.dist.php b/conf/config.dist.php index 05e3088..bf5609b 100755 --- a/conf/config.dist.php +++ b/conf/config.dist.php @@ -32,20 +32,16 @@ $db['webhost'] = '%'; php 5.3.7 required ******************************/ -$db['ssl'] = false; // true/false, enable or disable SSL as a whole -$db['ssl_key'] = '/path/to/cert.key'; // path to an SSL key file. Only makes sense combined with ssl_cert -$db['ssl_cert'] = '/path/to/cert.crt'; // path to an SSL certificate file. Only makes sense combined with ssl_key -$db['ssl_ca'] = '/path/to/ca.crt'; // path to a file containing SSL CA certs -$db['ssl_capath'] = '/path/to/ca_certs'; // path to a directory containing CA certs -$db['ssl_cipher'] = 'DHE-RSA-AES256-SHA:AES128-SHA'; // one or more SSL Ciphers -$db['ssl_verify'] = 'true'; // Verify Common Name (CN) of server certificate? +$db['ssl'] = false; // true/false, enable or disable SSL as a whole +// $db['ssl_key'] = '/path/to/cert.key'; // path to an SSL key file. Only makes sense combined with ssl_cert +// $db['ssl_cert'] = '/path/to/cert.crt'; // path to an SSL certificate file. Only makes sense combined with ssl_key +// $db['ssl_ca'] = '/path/to/ca.crt'; // path to a file containing SSL CA certs +// $db['ssl_capath'] = '/path/to/ca_certs'; // path to a directory containing CA certs +// $db['ssl_cipher'] = 'HIGH:!PSK:!SHA:!MD5:!RC4:!aNULL'; // one or more SSL Ciphers, see openssl ciphers -v '....' +// $db['ssl_verify'] = 'true'; // Verify Common Name (CN) of server certificate? - -/** - * temporary table type to create slave subnets table - * (MEMORY, InnoDB) - ******************************/ -$db['tmptable_engine_type'] = "MEMORY"; +$db['tmptable_engine_type'] = "MEMORY"; // Temporary table type to construct complex queries (MEMORY, InnoDB) +$db['use_cte'] = 1; // Use recursive CTE queries [>=MariaDB 10.2.2, >=MySQL 8.0] (0=disabled, 1=autodetect, 2=force enable) /** @@ -64,6 +60,7 @@ $config['removed_addresses_timelimit'] = 86400 * 7; // int, after how many seco # resolveIPaddresses.php script parameters $config['resolve_emptyonly'] = true; // if true it will only update the ones without DNS entry! $config['resolve_verbose'] = true; // verbose response - prints results, cron will email it to you! +$config['disable_main_login_form'] = false; // disable main login form if you want use another authentification method by default (SAML, LDAP, etc.) /** @@ -75,9 +72,12 @@ $config['resolve_verbose'] = true; // verbose response - print $debugging = false; /* - * API Crypt security provider. "mcrypt" or "openssl" + * API Crypt security provider. "mcrypt" or "openssl*" + * Supported methods: + * openssl-128-cbc (alias openssl, openssl-128) *default + * openssl-256-cbc (alias openssl-256) * - * default as of 1.3.2 "openssl" + * default as of 1.3.2 "openssl-128-cbc" ******************************/ // $api_crypt_encryption_library = "mcrypt"; @@ -99,8 +99,8 @@ $phpsessname = "phpipam"; /** * Cookie SameSite settings ("None", "Lax"=Default, "Strict") * - "Strict" increases security - * - "Lax" required for SAML2 - * - "None" requires HTTPS + * - "Lax" required for SAML2, some SAML topologies may require "None". + * - "None" requires HTTPS (implies "Secure;") */ $cookie_samesite = "Lax"; @@ -109,7 +109,7 @@ $cookie_samesite = "Lax"; * * @var string */ -$session_storage = "files"; +$session_storage = "database"; /** @@ -133,32 +133,11 @@ define('BASE', "__PATH__/"); if(!defined('MCUNIQUE')) define('MCUNIQUE', "section"); - -/** - * SAML mappings - ******************************/ -if(!defined('MAP_SAML_USER')) -define('MAP_SAML_USER', true); // Enable SAML username mapping - -if(!defined('SAML_USERNAME')) -define('SAML_USERNAME', 'admin'); // Map SAML to explicit user - - /** * Permit private subpages - private apps under /app/tools/custom//index.php ******************************/ $private_subpages = array(); - -/** - * Google MAPs API key for locations to display map - * - * Obtain key: Go to your Google Console (https://console.developers.google.com) and enable "Google Maps JavaScript API" - * from overview tab, so go to Credentials tab and make an API key for your project. - ******************************/ -$gmaps_api_key = ""; -$gmaps_api_geocode_key = ""; - /** * proxy connection details ******************************/ @@ -169,12 +148,22 @@ $proxy_user = 'USERNAME'; // Proxy Username $proxy_pass = 'PASSWORD'; // Proxy Password $proxy_use_auth = false; // Enable/Disable Proxy authentication +$offline_mode = false; // Offline mode, disable server-side Internet requests (proxy/OpenStreetMap) + +/** + * Failed access + * Message to log into webserver logs in case of failed access, for further processing by tools like Fail2Ban + * The message can contain a %u parameter which will be replaced with the login user identifier. + ******************************/ +// $failed_access_message = ''; + /** * General tweaks ******************************/ $config['logo_width'] = 220; // logo width $config['requests_public'] = true; // Show IP request module on login page $config['split_ip_custom_fields'] = false; // Show custom fields in separate table when editing IP address +$config['footer_message'] = ""; // Custom message included in the footer of every page /** * PHP CLI binary for scanning and network discovery. @@ -182,7 +171,7 @@ $config['split_ip_custom_fields'] = false; // Show custom field * The default behaviour is to use the system wide default php version symlinked to php in PHP_BINDIR (/usr/bin/php). * If multiple php versions are present; overide selection with $php_cli_binary. */ -// $php_cli_binary = '/usr/bin/php7.1'; +// $php_cli_binary = '/usr/bin/php7.4'; /** * Path to mysqldump binary diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf new file mode 100644 index 0000000..017da9e --- /dev/null +++ b/conf/extra_php-fpm.conf @@ -0,0 +1,4 @@ +; Additional php.ini defines, specific to this pool of workers. + +php_admin_value[upload_max_filesize] = 256M +php_admin_value[post_max_size] = 256M diff --git a/conf/nginx.conf b/conf/nginx.conf index 179ee75..d57f644 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,11 +2,13 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/ ; + alias __INSTALL_DIR__/; index index.php; + client_max_body_size 256M; - try_files $uri $uri/ index.php; + try_files $uri $uri/ __PATH__/index.php; + location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; @@ -16,8 +18,13 @@ location __PATH__/ { fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_pass_header Authorization; } # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } + +location __PATH__/api/ { + try_files $uri $uri/ __PATH__/api/index.php; + } \ No newline at end of file diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf deleted file mode 100644 index ab1a471..0000000 --- a/conf/php-fpm.conf +++ /dev/null @@ -1,430 +0,0 @@ -; Start a new pool named 'www'. -; the variable $pool can be used in any directive and will be replaced by the -; pool name ('www' here) -[__NAMETOCHANGE__] - -; Per pool prefix -; It only applies on the following directives: -; - 'access.log' -; - 'slowlog' -; - 'listen' (unixsocket) -; - 'chroot' -; - 'chdir' -; - 'php_values' -; - 'php_admin_values' -; When not set, the global prefix (or /usr) applies instead. -; Note: This directive can also be relative to the global prefix. -; Default Value: none -;prefix = /path/to/pools/$pool - -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = __USER__ -group = __USER__ - -; The address on which to accept FastCGI requests. -; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on -; a specific port; -; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on -; a specific port; -; 'port' - to listen on a TCP socket to all addresses -; (IPv6 and IPv4-mapped) on a specific port; -; '/path/to/unix/socket' - to listen on a unix socket. -; Note: This value is mandatory. -listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock - -; Set listen(2) backlog. -; Default Value: 511 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 511 - -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. -; Default Values: user and group are set as the running user -; mode is set to 0660 -listen.owner = www-data -listen.group = www-data -;listen.mode = 0660 -; When POSIX Access Control Lists are supported you can set them using -; these options, value is a comma separated list of user/group names. -; When set, listen.owner and listen.group are ignored -;listen.acl_users = -;listen.acl_groups = - -; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. -; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original -; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address -; must be separated by a comma. If this value is left blank, connections will be -; accepted from any ip address. -; Default Value: any -;listen.allowed_clients = 127.0.0.1 - -; Specify the nice(2) priority to apply to the pool processes (only if set) -; The value can vary from -19 (highest priority) to 20 (lower priority) -; Note: - It will only work if the FPM master process is launched as root -; - The pool processes will inherit the master process priority -; unless it specified otherwise -; Default Value: no set -; process.priority = -19 - -; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user -; or group is differrent than the master process user. It allows to create process -; core dump and ptrace the process for the pool user. -; Default Value: no -; process.dumpable = yes - -; Choose how the process manager will control the number of child processes. -; Possible Values: -; static - a fixed number (pm.max_children) of child processes; -; dynamic - the number of child processes are set dynamically based on the -; following directives. With this process management, there will be -; always at least 1 children. -; pm.max_children - the maximum number of children that can -; be alive at the same time. -; pm.start_servers - the number of children created on startup. -; pm.min_spare_servers - the minimum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is less than this -; number then some children will be created. -; pm.max_spare_servers - the maximum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is greater than this -; number then some children will be killed. -; ondemand - no children are created at startup. Children will be forked when -; new requests will connect. The following parameter are used: -; pm.max_children - the maximum number of children that -; can be alive at the same time. -; pm.process_idle_timeout - The number of seconds after which -; an idle process will be killed. -; Note: This value is mandatory. -pm = dynamic - -; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. -; This value sets the limit on the number of simultaneous requests that will be -; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. -; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. The below defaults are based on a server without much resources. Don't -; forget to tweak pm.* to fit your needs. -; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' -; Note: This value is mandatory. -pm.max_children = 5 - -; The number of child processes created on startup. -; Note: Used only when pm is set to 'dynamic' -; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 -pm.start_servers = 2 - -; The desired minimum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = 1 - -; The desired maximum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = 3 - -; The number of seconds after which an idle process will be killed. -; Note: Used only when pm is set to 'ondemand' -; Default Value: 10s -;pm.process_idle_timeout = 10s; - -; The number of requests each child process should execute before respawning. -; This can be useful to work around memory leaks in 3rd party libraries. For -; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. -; Default Value: 0 -;pm.max_requests = 500 - -; The URI to view the FPM status page. If this value is not set, no URI will be -; recognized as a status page. It shows the following informations: -; pool - the name of the pool; -; process manager - static, dynamic or ondemand; -; start time - the date and time FPM has started; -; start since - number of seconds since FPM has started; -; accepted conn - the number of request accepted by the pool; -; listen queue - the number of request in the queue of pending -; connections (see backlog in listen(2)); -; max listen queue - the maximum number of requests in the queue -; of pending connections since FPM has started; -; listen queue len - the size of the socket queue of pending connections; -; idle processes - the number of idle processes; -; active processes - the number of active processes; -; total processes - the number of idle + active processes; -; max active processes - the maximum number of active processes since FPM -; has started; -; max children reached - number of times, the process limit has been reached, -; when pm tries to start more children (works only for -; pm 'dynamic' and 'ondemand'); -; Value are updated in real time. -; Example output: -; pool: www -; process manager: static -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 62636 -; accepted conn: 190460 -; listen queue: 0 -; max listen queue: 1 -; listen queue len: 42 -; idle processes: 4 -; active processes: 11 -; total processes: 15 -; max active processes: 12 -; max children reached: 0 -; -; By default the status page output is formatted as text/plain. Passing either -; 'html', 'xml' or 'json' in the query string will return the corresponding -; output syntax. Example: -; http://www.foo.bar/status -; http://www.foo.bar/status?json -; http://www.foo.bar/status?html -; http://www.foo.bar/status?xml -; -; By default the status page only outputs short status. Passing 'full' in the -; query string will also return status for each pool process. -; Example: -; http://www.foo.bar/status?full -; http://www.foo.bar/status?json&full -; http://www.foo.bar/status?html&full -; http://www.foo.bar/status?xml&full -; The Full status returns for each process: -; pid - the PID of the process; -; state - the state of the process (Idle, Running, ...); -; start time - the date and time the process has started; -; start since - the number of seconds since the process has started; -; requests - the number of requests the process has served; -; request duration - the duration in µs of the requests; -; request method - the request method (GET, POST, ...); -; request URI - the request URI with the query string; -; content length - the content length of the request (only with POST); -; user - the user (PHP_AUTH_USER) (or '-' if not set); -; script - the main script called (or '-' if not set); -; last request cpu - the %cpu the last request consumed -; it's always 0 if the process is not in Idle state -; because CPU calculation is done when the request -; processing has terminated; -; last request memory - the max amount of memory the last request consumed -; it's always 0 if the process is not in Idle state -; because memory calculation is done when the request -; processing has terminated; -; If the process is in Idle state, then informations are related to the -; last request the process has served. Otherwise informations are related to -; the current request being served. -; Example output: -; ************************ -; pid: 31330 -; state: Running -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 63087 -; requests: 12808 -; request duration: 1250261 -; request method: GET -; request URI: /test_mem.php?N=10000 -; content length: 0 -; user: - -; script: /home/fat/web/docs/php/test_mem.php -; last request cpu: 0.00 -; last request memory: 0 -; -; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: /usr/share/php/7.0/fpm/status.html -; -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;pm.status_path = /status - -; The ping URI to call the monitoring page of FPM. If this value is not set, no -; URI will be recognized as a ping page. This could be used to test from outside -; that FPM is alive and responding, or to -; - create a graph of FPM availability (rrd or such); -; - remove a server from a group if it is not responding (load balancing); -; - trigger alerts for the operating team (24/7). -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;ping.path = /ping - -; This directive may be used to customize the response of a ping request. The -; response is formatted as text/plain with a 200 response code. -; Default Value: pong -;ping.response = pong - -; The access log file -; Default: not set -;access.log = log/$pool.access.log - -; The access log format. -; The following syntax is allowed -; %%: the '%' character -; %C: %CPU used by the request -; it can accept the following format: -; - %{user}C for user CPU only -; - %{system}C for system CPU only -; - %{total}C for user + system CPU (default) -; %d: time taken to serve the request -; it can accept the following format: -; - %{seconds}d (default) -; - %{miliseconds}d -; - %{mili}d -; - %{microseconds}d -; - %{micro}d -; %e: an environment variable (same as $_ENV or $_SERVER) -; it must be associated with embraces to specify the name of the env -; variable. Some exemples: -; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e -; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e -; %f: script filename -; %l: content-length of the request (for POST request only) -; %m: request method -; %M: peak of memory allocated by PHP -; it can accept the following format: -; - %{bytes}M (default) -; - %{kilobytes}M -; - %{kilo}M -; - %{megabytes}M -; - %{mega}M -; %n: pool name -; %o: output header -; it must be associated with embraces to specify the name of the header: -; - %{Content-Type}o -; - %{X-Powered-By}o -; - %{Transfert-Encoding}o -; - .... -; %p: PID of the child that serviced the request -; %P: PID of the parent of the child that serviced the request -; %q: the query string -; %Q: the '?' character if query string exists -; %r: the request URI (without the query string, see %q and %Q) -; %R: remote IP address -; %s: status (response code) -; %t: server time the request was received -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t -; %T: time the log has been written (the request has finished) -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t -; %u: remote user -; -; Default: "%R - %u %t \"%m %r\" %s" -;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" - -; The log file for slow requests -; Default Value: not set -; Note: slowlog is mandatory if request_slowlog_timeout is set -;slowlog = log/$pool.log.slow - -; The timeout for serving a single request after which a PHP backtrace will be -; dumped to the 'slowlog' file. A value of '0s' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -;request_slowlog_timeout = 0 - -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -request_terminate_timeout = 1d - -; Set open file descriptor rlimit. -; Default Value: system defined value -;rlimit_files = 1024 - -; Set max core size rlimit. -; Possible Values: 'unlimited' or an integer greater or equal to 0 -; Default Value: system defined value -;rlimit_core = 0 - -; Chroot to this directory at the start. This value must be defined as an -; absolute path. When this value is not set, chroot is not used. -; Note: you can prefix with '$prefix' to chroot to the pool prefix or one -; of its subdirectories. If the pool prefix is not set, the global prefix -; will be used instead. -; Note: chrooting is a great security feature and should be used whenever -; possible. However, all PHP paths will be relative to the chroot -; (error_log, sessions.save_path, ...). -; Default Value: not set -;chroot = - -; Chdir to this directory at the start. -; Note: relative path can be used. -; Default Value: current directory or / when chroot -chdir = __FINALPATH__ - -; Redirect worker stdout and stderr into main error log. If not set, stdout and -; stderr will be redirected to /dev/null according to FastCGI specs. -; Note: on highloaded environement, this can cause some delay in the page -; process time (several ms). -; Default Value: no -;catch_workers_output = yes - -; Clear environment in FPM workers -; Prevents arbitrary environment variables from reaching FPM worker processes -; by clearing the environment in workers before env vars specified in this -; pool configuration are added. -; Setting to "no" will make all environment variables available to PHP code -; via getenv(), $_ENV and $_SERVER. -; Default Value: yes -;clear_env = no - -; Limits the extensions of the main script FPM will allow to parse. This can -; prevent configuration mistakes on the web server side. You should only limit -; FPM to .php extensions to prevent malicious users to use other extensions to -; execute php code. -; Note: set an empty value to allow all extensions. -; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 .php7 - -; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from -; the current environment. -; Default Value: clean env -;env[HOSTNAME] = $HOSTNAME -;env[PATH] = /usr/local/bin:/usr/bin:/bin -;env[TMP] = /tmp -;env[TMPDIR] = /tmp -;env[TEMP] = /tmp - -; Additional php.ini defines, specific to this pool of workers. These settings -; overwrite the values previously defined in the php.ini. The directives are the -; same as the PHP SAPI: -; php_value/php_flag - you can set classic ini defines which can -; be overwritten from PHP call 'ini_set'. -; php_admin_value/php_admin_flag - these directives won't be overwritten by -; PHP call 'ini_set' -; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. - -; Defining 'extension' will load the corresponding shared extension from -; extension_dir. Defining 'disable_functions' or 'disable_classes' will not -; overwrite previously defined php.ini values, but will append the new value -; instead. - -; Note: path INI options can be relative and will be expanded with the prefix -; (pool, global or /usr) - -; Default Value: nothing is defined by default except the values in php.ini and -; specified at startup with the -d argument -;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com -;php_flag[display_errors] = off -;php_admin_value[error_log] = /var/log/fpm-php.www.log -;php_admin_flag[log_errors] = on -;php_admin_value[memory_limit] = 32M - -; Common values to change to increase file upload limit -; php_admin_value[upload_max_filesize] = 50M -; php_admin_value[post_max_size] = 50M -; php_admin_flag[mail.add_x_header] = Off - -; Other common parameters -; php_admin_value[max_execution_time] = 600 -; php_admin_value[max_input_time] = 300 -; php_admin_value[memory_limit] = 256M -; php_admin_flag[short_open_tag] = On diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..e90fa60 --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1 @@ +phpIPAM is an open-source web IP address management application. Its goal is to provide light and simple IP address management application. It is ajax-based using jQuery libraries, it uses php scripts and javascript and some HTML5/CSS3 features, so some modern browser is preferred to be able to display javascript quickly and correctly. \ No newline at end of file diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index e69de29..0000000 diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..d3c541e --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1 @@ +The Default credentials for a new instance of phpIPAM are: Admin / ipamadmin \ No newline at end of file diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 455d8e1..0000000 --- a/manifest.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "phpIPAM", - "id": "phpipam", - "packaging_format": 1, - "description": { - "en": "Web IP address management application", - "fr": "Application web de gestion d'adresses IP" - }, - "version": "1.5.2~ynh1", - "url": "https://phpipam.net/", - "upstream": { - "license": "GPL-3.0-only", - "website": "https://phpipam.net", - "demo": "http://demo.phpipam.net", - "admindoc": "https://phpipam.net/documents/", - "code": "https://github.com/phpipam/phpipam" - }, - "license": "GPL-3.0-only", - "maintainer": { - "name": "liberodark", - "email": "liberodark@gmail.com" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.4-fpm", - "mysql" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/phpipam", - "default": "/phpipam" - }, - { - "name": "is_public", - "type": "boolean", - "default": true - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..70d4373 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,61 @@ +packaging_format = 2 + +id = "phpipam" +name = "phpIPAM" +description.en = "Web IP address management application" +description.fr = "Application web de gestion d'adresses IP" + +version = "1.5.2~ynh2" + +maintainers = [""] + +[upstream] +license = "GPL-3.0-only" +website = "https://phpipam.net" +demo = "http://demo.phpipam.net" +admindoc = "https://phpipam.net/documents/" +code = "https://github.com/phpipam/phpipam" + +[integration] +yunohost = ">= 11.1.19" +architectures = "all" +multi_instance = true +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/phpipam" + + [install.init_main_permission] + type = "group" + default = "visitors" + +[resources] + [resources.sources.main] + url = "https://github.com/phpipam/phpipam/releases/download/v1.5.1/phpipam-v1.5.1.zip" + sha256 = "9ced23778f6455d3db8975e09bc5b2f605add9f7feda1568b716803850d19c58" + autoupdate.strategy = "latest_github_tag" + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + api.url = "/api" + api.show_tile = false + api.allowed = "visitors" + + [resources.apt] + packages = "mariadb-server php7.4-gmp php7.4-mysql php7.4-ldap php7.4-gd php7.4-opcache php7.4-fileinfo php7.4-intl php7.4-json php7.4-cli php7.4-mbstring php7.4-xml" + + [resources.database] + type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh index d4c6ebc..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,10 +4,6 @@ # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.4" - -pkg_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-opcache php${YNH_PHP_VERSION}-fileinfo php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml" - #================================================= # PERSONAL HELPERS #================================================= @@ -19,60 +15,3 @@ pkg_dependencies="php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-mysql php${YNH #================================================= # FUTURE OFFICIAL HELPERS #================================================= - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: app_message - The message to send to the administrator. -# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` has important message for you" - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$app_message ---- -Automatic diagnosis data from YunoHost -$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - # Send the email to the recipients - echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} diff --git a/scripts/backup b/scripts/backup index 5f502ba..6039e18 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,25 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -38,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 08e9824..ad6808d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,61 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -71,29 +16,7 @@ fi #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi +ynh_change_url_nginx_config #================================================= # SPECIFIC MODIFICATIONS @@ -101,19 +24,10 @@ fi ynh_script_progression --message="Configuring $app..." --weight=1 domain="$new_domain" -path_url="$new_path" -domain_path="https://$domain$path_url" +path="$new_path" +domain_path="https://$domain$path" -ynh_add_config --template="../conf/config.dist.php" --destination="$final_path/config.php" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_add_config --template="../conf/config.dist.php" --destination="$install_dir/config.php" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 4d8a5b8..09d9691 100644 --- a/scripts/install +++ b/scripts/install @@ -9,80 +9,33 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC -phpversion=$YNH_PHP_VERSION - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= -# CREATE A MYSQL DATABASE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Creating a MySQL database..." --weight=2 +ynh_script_progression --message="Adding a configuration file..." --weight=1 -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name +ynh_add_config --template="../conf/config.dist.php" --destination="$install_dir/config.php" + +chmod 644 "$install_dir/config.php" +chown $app: "$install_dir/config.php" + +#================================================= +# DATABASE CONFIGURATION +#================================================= +ynh_script_progression --message="Adding database configuration..." --weight=1 + +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < $install_dir/db/SCHEMA.sql #================================================= # NGINX CONFIGURATION @@ -92,73 +45,12 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring PHP-FPM..." --weight=1 - # Create a dedicated PHP-FPM config -ynh_add_fpm_config -ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion - -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 - -ynh_add_config --template="../conf/config.dist.php" --destination="$final_path/config.php" - -chmod 644 "$final_path/config.php" -chown $app: "$final_path/config.php" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_add_fpm_config --usage=low --footprint=low # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - ynh_permission_update --permission="main" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# SEND A README FOR THE ADMIN -#================================================= -ynh_script_progression --message="Sending a readme for the admin..." - -message="PHPIPAM was successfully installed :) - -Please open your $app domain: https://$domain$path_url - -Complete the registration process from the setup page displayed. -Details for MySQL database to be enterted while registration process: - -Database login: $app -Database name: $app -Database password: $db_pwd - -If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/phpipam_ynh/issues" - -ynh_send_readme_to_admin "$message" - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index c4c54fc..d4f1930 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,43 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -#================================================= -# REMOVE THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Removing the MySQL database..." --weight=1 - -# Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -54,32 +17,12 @@ ynh_script_progression --message="Removing NGINX web server configuration..." -- # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Removing PHP-FPM configuration..." --weight=2 - # Remove the dedicated PHP-FPM config ynh_remove_fpm_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index a23054f..c7e8f56 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,35 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - #================================================= # STANDARD RESTORATION STEPS #================================================= @@ -48,24 +19,15 @@ ynh_script_progression --message="Restoring the NGINX configuration..." --weight ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=5 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -74,21 +36,11 @@ ynh_script_progression --message="Restoring the PHP-FPM configuration..." --weig ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE MYSQL DATABASE #================================================= ynh_script_progression --message="Restoring the MySQL database..." --weight=1 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 00c0e2f..c30ab68 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,61 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) - #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - -# Cleaning legacy permissions -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -73,12 +24,11 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod -R o-rwx "$install_dir" +chown -R $app:www-data "$install_dir" #================================================= # NGINX CONFIGURATION @@ -88,47 +38,21 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1 - # Create a dedicated PHP-FPM config -ynh_add_fpm_config +ynh_add_fpm_config --usage=low --footprint=low + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append #================================================= # UPDATE A CONFIG FILE #================================================= ynh_script_progression --message="Updating a configuration file..." --weight=1 -ynh_add_config --template="../conf/config.dist.php" --destination="$final_path/config.php" +ynh_add_config --template="../conf/config.dist.php" --destination="$install_dir/config.php" -chmod 400 "$final_path/config.php" -chown $app: "$final_path/config.php" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +chmod 400 "$install_dir/config.php" +chown $app: "$install_dir/config.php" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..cbbeef1 --- /dev/null +++ b/tests.toml @@ -0,0 +1,3 @@ +test_format = 1.0 + +[default]