Skip to content

Commit

Permalink
Merge branch 'issue/16-install'
Browse files Browse the repository at this point in the history
  • Loading branch information
cambell-prince committed Mar 24, 2019
2 parents d2a27fd + d7f3995 commit 6fc5a1e
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vstags

SGW_*.tgz
SGW_*.zip
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <[email protected]>
This program is free software; you can redistribute it and/or modify
Expand Down
18 changes: 9 additions & 9 deletions LetsEncrypt.php → SGW_LetsEncrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))
// );
}
Expand All @@ -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')
));
}
Expand Down Expand Up @@ -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')
);
Expand All @@ -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));
}
}

Expand All @@ -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')
);

Expand Down
6 changes: 3 additions & 3 deletions backend/LetsEncrypt.pm → backend/SGW_LetsEncrypt.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=head1 NAME
Plugin::LetsEncrypt
Plugin::SGW_LetsEncrypt
=cut

Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
40 changes: 40 additions & 0 deletions fred.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

global $name;

$name = 'SGW_LetsEncrypt';

function execute($cmd) {
echo $cmd . PHP_EOL;
$f = popen($cmd, 'r');
while (!feof($f)) {
echo fread($f, 1024);
}
$result = pclose($f);
if ($result !== 0) {
throw new \Exception("Task failed");
}
}

$fred->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');
});

6 changes: 3 additions & 3 deletions info.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
return array(
'author' => 'Cambell Prince',
'email' => '[email protected]',
'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'
);
10 changes: 5 additions & 5 deletions sql/001_create_letsencrypt_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
*/

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,
`domain_id` int(11) unsigned NOT NULL,
`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
'
"
);
20 changes: 20 additions & 0 deletions upload-exclude-zip.txt
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions upload-exclude.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 6fc5a1e

Please sign in to comment.