From d83a35cf2e34d3e1ea322144088d5f0c8fc4de6b Mon Sep 17 00:00:00 2001 From: cambell Date: Sat, 23 Mar 2019 23:27:18 +0700 Subject: [PATCH 1/4] feature/install: Fixes for installation - Fix sql --- LetsEncrypt.php | 16 ++++++++-------- sql/001_create_letsencrypt_table.php | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/LetsEncrypt.php b/LetsEncrypt.php index 1c86504..478009a 100644 --- a/LetsEncrypt.php +++ b/LetsEncrypt.php @@ -137,7 +137,7 @@ public function onClientScriptStart() public function onAfterDeleteCustomer(iMSCP_Events_Event $event) { // exec_query( - // 'UPDATE letsencrypt SET letsencrypt_status = ? WHERE customer_id = ?', + // 'UPDATE letsencrypt SET status = ? WHERE customer_id = ?', // array('todelete', $event->getParam('customerId')) // ); } @@ -150,7 +150,7 @@ public function onAfterDeleteCustomer(iMSCP_Events_Event $event) */ public function onAfterDeleteDomainAlias(iMSCP_Events_Event $event) { - exec_query('UPDATE letsencrypt SET letsencrypt_status = ? WHERE alias_id = ?', array( + exec_query('UPDATE letsencrypt SET status = ? WHERE alias_id = ?', array( 'todelete', $event->getParam('domainAliasId') )); } @@ -180,9 +180,9 @@ public function getItemWithErrorStatus() { $stmt = exec_query( " - SELECT letsencrypt_id AS item_id, letsencrypt_status AS status, domain_name AS item_name, - 'letsencrypt' AS `table`, 'letsencrypt_status' AS field - FROM letsencrypt WHERE letsencrypt_status NOT IN(?, ?, ?, ?, ?, ?, ?) + SELECT letsencrypt_id AS item_id, cert_name AS item_name, + 'letsencrypt' AS `table`, 'status' AS field + FROM letsencrypt WHERE status NOT IN(?, ?, ?, ?, ?, ?, ?) ", array('ok', 'disabled', 'toadd', 'tochange', 'toenable', 'todisable', 'todelete') ); @@ -204,8 +204,8 @@ public function getItemWithErrorStatus() */ public function changeItemStatus($table, $field, $itemId) { - if ($table == 'letsencrypt' && $field == 'letsencrypt_status') { - exec_query('UPDATE letsencrypt SET letsencrypt_status = ? WHERE letsencrypt_id = ?', array('tochange', $itemId)); + if ($table == 'letsencrypt' && $field == 'status') { + exec_query('UPDATE letsencrypt SET `status` = ? WHERE letsencrypt_id = ?', array('tochange', $itemId)); } } @@ -217,7 +217,7 @@ public function changeItemStatus($table, $field, $itemId) public function getCountRequests() { $stmt = exec_query( - 'SELECT COUNT(letsencrypt_id) AS cnt FROM letsencrypt WHERE letsencrypt_status IN (?, ?, ?, ?, ?)', + 'SELECT COUNT(letsencrypt_id) AS cnt FROM letsencrypt WHERE `status` IN (?, ?, ?, ?, ?)', array('toadd', 'tochange', 'toenable', 'todisable', 'todelete') ); diff --git a/sql/001_create_letsencrypt_table.php b/sql/001_create_letsencrypt_table.php index 5fa0ace..25b0066 100644 --- a/sql/001_create_letsencrypt_table.php +++ b/sql/001_create_letsencrypt_table.php @@ -19,7 +19,7 @@ */ return array( - 'up' => ' + 'up' => " CREATE TABLE IF NOT EXISTS `letsencrypt` ( `letsencrypt_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `admin_id` int(11) unsigned NOT NULL, @@ -27,14 +27,14 @@ `alias_id` int(11) unsigned DEFAULT NULL, `subdomain_id` int(11) unsigned DEFAULT NULL, `cert_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, - `http_forward` tinyint(1) NOT NULL DEFAULT \'0\', + `http_forward` tinyint(1) NOT NULL DEFAULT '0', `status` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `state` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (letsencrypt_id), KEY letsencrypt_id (letsencrypt_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; - ', - 'down' => ' + ", + 'down' => " DROP TABLE IF EXISTS letsencrypt - ' + " ); From 1549eceb229dca9ab10b8275ec0ca9db37090877 Mon Sep 17 00:00:00 2001 From: cambell Date: Sun, 24 Mar 2019 08:38:12 +0700 Subject: [PATCH 2/4] feature/install: Renaming the plugin SGW_LetsEncrypt --- LetsEncrypt.php => SGW_LetsEncrypt.php | 2 +- backend/{LetsEncrypt.pm => SGW_LetsEncrypt.pm} | 6 +++--- info.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) rename LetsEncrypt.php => SGW_LetsEncrypt.php (99%) rename backend/{LetsEncrypt.pm => SGW_LetsEncrypt.pm} (99%) diff --git a/LetsEncrypt.php b/SGW_LetsEncrypt.php similarity index 99% rename from LetsEncrypt.php rename to SGW_LetsEncrypt.php index 478009a..aa165ab 100644 --- a/LetsEncrypt.php +++ b/SGW_LetsEncrypt.php @@ -21,7 +21,7 @@ /** * Class iMSCP_Plugin_LetsEncrypt */ -class iMSCP_Plugin_LetsEncrypt extends iMSCP_Plugin_Action +class iMSCP_Plugin_SGW_LetsEncrypt extends iMSCP_Plugin_Action { /** * Plugin initialization diff --git a/backend/LetsEncrypt.pm b/backend/SGW_LetsEncrypt.pm similarity index 99% rename from backend/LetsEncrypt.pm rename to backend/SGW_LetsEncrypt.pm index fc36e51..6d0185a 100644 --- a/backend/LetsEncrypt.pm +++ b/backend/SGW_LetsEncrypt.pm @@ -1,6 +1,6 @@ =head1 NAME - Plugin::LetsEncrypt + Plugin::SGW_LetsEncrypt =cut @@ -21,7 +21,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -package Plugin::LetsEncrypt; +package Plugin::SGW_LetsEncrypt; use strict; use warnings; @@ -280,7 +280,7 @@ sub _init # testmode enables the mocked certbot-auto that creates self-signed certificates # enabled = 1, disabled = 0 - $self->{'testmode'} = 0; + $self->{'testmode'} = 1; $self->{'db'} = iMSCP::Database->factory(); $self->{'httpd'} = Servers::httpd->factory(); diff --git a/info.php b/info.php index c06c29c..a2ef3ed 100644 --- a/info.php +++ b/info.php @@ -21,10 +21,10 @@ return array( 'author' => 'Cambell Prince', 'email' => 'cambell.prince@gmail.com', - 'version' => '1.4.0', + 'version' => '1.4.10', 'require_api' => '1.0.5', - 'date' => '2018-07-18', - 'name' => 'LetsEncrypt', + 'date' => '2019-03-25', + 'name' => 'SGW_LetsEncrypt', 'desc' => 'Plugin that provides LetsEncrypt SSL certificates.', 'url' => 'https://github.com/saygoweb/imscp-plugin-letsencrypt' ); From 704a73fe97c774af24ff1212c108899ca83ba91d Mon Sep 17 00:00:00 2001 From: cambell Date: Sun, 24 Mar 2019 12:12:16 +0700 Subject: [PATCH 3/4] feature/install: packaging and version bump 1.5.0 --- .gitignore | 3 ++- fred.php | 40 ++++++++++++++++++++++++++++++++++++++++ info.php | 2 +- upload-exclude-zip.txt | 20 ++++++++++++++++++++ upload-exclude.txt | 17 +++++++++++++++++ 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 fred.php create mode 100644 upload-exclude-zip.txt create mode 100644 upload-exclude.txt diff --git a/.gitignore b/.gitignore index 82d2cb4..c4872a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vstags - +SGW_*.tgz +SGW_*.zip diff --git a/fred.php b/fred.php new file mode 100644 index 0000000..e47f652 --- /dev/null +++ b/fred.php @@ -0,0 +1,40 @@ +task('db-backup', function () use ($fred) { + $user = getenv('USER'); + $password_db = getenv('password_db'); + execute("/usr/bin/mysqldump -u $user --password=$password_db imscp | gzip > data/imscp_dev.sql.gz"); +}); + +$fred->task('package-zip', function () use ($fred) { + global $name; + execute("rm -f *.zip && zip -r -x@./upload-exclude-zip.txt -y -q ./$name.zip ."); +}); + +$fred->task('package-tar', function () use ($fred) { + global $name; + execute("rm -f *.tgz && tar -cvzf ./$name.tgz --transform 's|./|$name/|' -X upload-exclude.txt ./*"); +}); + +$fred->task('package', function () use ($fred) { + // Note: Only tgz / bzip2 are supported for upload as iMSCP plugins + // $fred->execute('package-zip'); + $fred->execute('package-tar'); +}); + diff --git a/info.php b/info.php index a2ef3ed..019133b 100644 --- a/info.php +++ b/info.php @@ -21,7 +21,7 @@ return array( 'author' => 'Cambell Prince', 'email' => 'cambell.prince@gmail.com', - 'version' => '1.4.10', + 'version' => '1.5.0', 'require_api' => '1.0.5', 'date' => '2019-03-25', 'name' => 'SGW_LetsEncrypt', diff --git a/upload-exclude-zip.txt b/upload-exclude-zip.txt new file mode 100644 index 0000000..4c85f20 --- /dev/null +++ b/upload-exclude-zip.txt @@ -0,0 +1,20 @@ +.git/* +*/.git/* +.gitignore +.vscode/* +node_modules/* +composer.* +package.json +*/test/* +test/* +phpunit.xml +Vagrantfile +build* +.travis.yml +*.zip +*.tgz +gulpfile.js +fred.php +upload-exclude.txt +upload-exclude-zip.txt +phpunit.xml diff --git a/upload-exclude.txt b/upload-exclude.txt new file mode 100644 index 0000000..15d0942 --- /dev/null +++ b/upload-exclude.txt @@ -0,0 +1,17 @@ +.git +.gitignore +.vscocde +node_modules +composer.* +package.json +test +phpunit.xml +Vagrantfile +build* +.travis.yml +*.zip +*.tgz +gulpfile.js +fred.php +upload-exclude.txt +upload-exclude-zip.txt From d7f3995baec003039fcbb2a99c07ea9394e0cf8a Mon Sep 17 00:00:00 2001 From: cambell Date: Sun, 24 Mar 2019 17:50:35 +0700 Subject: [PATCH 4/4] feature/install: Update README --- README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0b1e5c1..ca548ba 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,19 @@ Testing and bug reports are welcome. ## Requirements -* i-MSCP 1.5.x (plugin version v1.4.x) -* i-MSCP 1.4.x (plugin version v1.4.x) +* i-MSCP 1.5.x (plugin version v1.5.x) +* i-MSCP 1.4.x (plugin version v1.5.x) * i-MSCP 1.3.x (up to version v1.1.1) -Plugin version 1.4.0 has been tested with i-MSCP version 1.4.7 on Debian Stretch 9.4 +Plugin version 1.4.x has been tested with i-MSCP version 1.4.7 on Debian Stretch 9.4 -Plugin version 1.4.0 has been tested with i-MSCP version 1.5.x on Debian Stretch 9.4 +Plugin version 1.5.x has been tested with i-MSCP version 1.5.x on Debian Stretch 9.4 ## Installation +Download the SGW_LetsEncrypt.tgz release file from the releases page. Don't download the Git source archive if +you plan to upload using hte plugin management interface. + 1. Upload the plugin through the plugin management interface 2. Install the plugin through the plugin management interface @@ -31,7 +34,7 @@ Plugin version 1.4.0 has been tested with i-MSCP version 1.5.x on Debian Stretch ## License ``` -i-MSCP LetsEncrypt plugin +i-MSCP SGW_LetsEncrypt plugin Copyright (C) 2017 Cambell Prince This program is free software; you can redistribute it and/or modify