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/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 diff --git a/LetsEncrypt.php b/SGW_LetsEncrypt.php similarity index 92% rename from LetsEncrypt.php rename to SGW_LetsEncrypt.php index 1c86504..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 @@ -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/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/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 c06c29c..019133b 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.5.0', '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' ); 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 - ' + " ); 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