Преглед изворни кода

At least we are 500ing on page load now, kappa

Thomas A. Baugh пре 5 година
родитељ
комит
58ce341507

+ 18 - 0
Makefile

@@ -0,0 +1,18 @@
+.PHONY: all install test uninstall
+all: install
+
+install:
+	/usr/local/cpanel/3rdparty/bin/perl install/install.pl
+	/usr/local/cpanel/bin/register_appconfig ./plugin/better_postgres.conf
+
+uninstall:
+	/usr/local/cpanel/bin/unregister_appconfig better_postgres
+	rm -rf /var/cpanel/perl/Troglodyne
+	rm -rf /var/cpanel/templates/troglodyne
+	rm -rf /usr/local/cpanel/whostmgr/docroot/templates/troglodyne
+	rm -rf /usr/local/cpanel/whostmgr/docroot/cgi/troglodyne
+	rm -f /usr/local/cpanel/whostmgr/docroot/addon_plugins/troglophant.png
+
+test:
+	[ ! -x /usr/local/cpanel/3rdparty/bin/prove ] || /usr/local/cpanel/3rdparty/bin/prove t/*.t
+	[ -x /usr/local/cpanel/3rdparty/bin/prove ] || prove t/*.t

+ 3 - 0
README.md

@@ -12,6 +12,9 @@ The Plan
 * Implement the "bone stock" path in the UI as well, have it be default option
   for install.
 * Testing. Lots of testing.
+* RPMification. Makefile needs to bundle shit into SOURCES and then run specfile(s) in SPECS.
+  Copy rpmbuild artifacts to dist folder or whatever.
+  Maybe a publish rule for yum repo?
 
 Other Ambitions
 ---------------

+ 24 - 0
cgi/pgupgrade.cgi

@@ -0,0 +1,24 @@
+#!/usr/local/cpanel/3rdparty/bin/perl
+package Troglodyne::CGI::PgUpgrade;
+
+# TODO move to lib/ and just symlink it into cgi? lol
+use strict;
+use warnings;
+
+use Cpanel::Template::Simple ();
+ 
+run() unless caller();
+ 
+sub run {
+    print "Content-type: text/html\r\n\r\n";
+    Cpanel::Template::process_template(
+        'whostmgr',
+        {
+            'template_file' => 'troglodyne/pgupgrade.tmpl',
+            'print'         => 1,
+        }
+    );
+    exit;
+}
+
+1;

BIN
img/troglophant.png


+ 23 - 0
install/install.pl

@@ -0,0 +1,23 @@
+#!/usr/local/cpanel/3rdparty/bin/perl
+
+use strict;
+use warnings;
+
+use Cwd ();
+use Git ();
+use File::Basename ();
+
+use Cpanel::Mkdir ();
+
+my $repo_dir = Cwd::abs_path(File::Basename::dirname(__FILE__) . "/../");
+Cpanel::Mkdir::ensure_directory_existence_and_mode("/var/cpanel/apps", 0755);
+my %install_to = qw{lib /var/cpanel/perl templates/config /var/cpanel/templates/troglodyne templates/ui /usr/local/cpanel/whostmgr/docroot/templates/troglodyne cgi /usr/local/cpanel/whostmgr/docroot/cgi/troglodyne img /usr/local/cpanel/whostmgr/docroot/addon_plugins};
+foreach my $dir ( keys(%install_to) ) {
+    Cpanel::Mkdir::ensure_directory_existence_and_mode( $install_to{$dir}, 0755 );
+    my @cmd = ( qw{rsync -r}, "$repo_dir/$dir/", $install_to{$dir} );
+    print join( " ", @cmd ) . "\n";
+    my $ret = system( @cmd );
+    die if $ret != 0;
+}
+
+0;

+ 8 - 0
lib/Troglodyne/CGI.pm

@@ -0,0 +1,8 @@
+package Troglodyne::CGI;
+
+use strict;
+use warnings;
+
+
+
+1;

+ 6 - 0
lib/Troglodyne/CpPostgreSQL.pm

@@ -0,0 +1,6 @@
+package Troglodyne::CpPostgresQL;
+
+use strict;
+use warnings;
+
+1;

+ 8 - 0
plugin/better_postgres.conf

@@ -0,0 +1,8 @@
+service=whostmgr
+user=root
+url=/cgi/troglodyne/pgupgrade.cgi
+acls=all
+entryurl=troglodyne/pgupgrade.cgi
+displayname=PostgreSQL Upgrade
+icon=troglophant.png
+target=_self

+ 4 - 0
templates/config/main.default

@@ -0,0 +1,4 @@
+# So far just mirroring what cPanel's template does.
+[% FOREACH h IN hba %]
+[% h.type %] [% h.database %] [% h.user %] [% IF h.ip.defined %] [% h.ip %] [% END %] [% IF h.mask.defined %] [% h.mask %] [% END %]  [% h.method %] [% IF h.option.defined %] [% h.option %] [% END -%]
+[% END %]

+ 24 - 0
templates/ui/pgupgrade.tmpl

@@ -0,0 +1,24 @@
+[%
+USE Whostmgr;
+USE JSON;
+ 
+IF locale.get_html_dir_attr() == 'rtl';
+SET rtl_bootstrap = Whostmgr.find_file_url('/3rdparty/bootstrap-rtl/optimized/dist/css/bootstrap-rtl.min.css');
+END;
+ 
+SET styleSheets = [
+    rtl_bootstrap,
+    '/libraries/fontawesome/css/font-awesome.min.css'
+];
+ 
+WRAPPER 'master_templates/master.tmpl'
+    header = locale.maketext("WHM Example Plugin")
+    stylesheets = styleSheets,
+    theme='bootstrap';
+%]
+ 
+<div class="callout callout-info">
+Test.
+</div>
+ 
+[% END %]