3 # TODO : missing copyright
5 # You should instead probably use ../src/utils/createplugin.sh that is more up-to-date
8 echo Usage: $0 PluginName
11 echo "Plugin template creator"
17 minus=`echo $1 | tr '[A-Z]' '[a-z]'`
18 plugdir=gforge-plugin-$minus
19 echo "Creating $1 plugin"
20 echo "Creating directory $plugdir"
26 mkdir $plugdir/etc/plugins
27 mkdir $plugdir/etc/plugins/$minus
29 mkdir $plugdir/include
30 mkdir $plugdir/include/languages
34 echo Creating $plugdir/bin/db-delete.pl
35 cat > $plugdir/bin/db-delete.pl <<FIN
38 # Debian-specific script to delete plugin-specific tables
39 # Roland Mas <lolando@debian.org>
48 use vars qw/\$dbh @reqlist \$query/ ;
49 use vars qw/\$sys_default_domain \$sys_cvs_host \$sys_download_host
50 \$sys_shell_host \$sys_users_host \$sys_docs_host \$sys_lists_host
51 \$sys_dns1_host \$sys_dns2_host \$FTPINCOMING_DIR \$FTPFILES_DIR
52 \$sys_urlroot \$sf_cache_dir \$sys_name \$sys_themeroot
53 \$sys_news_group \$sys_dbhost \$sys_dbname \$sys_dbuser \$sys_dbpasswd
54 \$sys_ldap_base_dn \$sys_ldap_host \$admin_login \$admin_password
55 \$server_admin \$domain_name \$newsadmin_groupid \$statsadmin_groupid
57 use vars qw/\$pluginname/ ;
59 sub is_lesser ( \$\$ ) ;
60 sub is_greater ( \$\$ ) ;
62 sub parse_sql_file ( \$ ) ;
64 require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions
65 require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
67 debug "You'll see some debugging info during this installation." ;
68 debug "Do not worry unless told otherwise." ;
72 # debug "Connected to the database OK." ;
74 \$pluginname = "$minus" ;
76 \$dbh->{AutoCommit} = 0;
77 \$dbh->{RaiseError} = 1;
79 my (\$sth, @array, \$version, \$action, \$path, \$target, \$rname) ;
81 my \$pattern = "plugin_" . \$pluginname . '_%' ;
83 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='v'" ;
84 \$sth = \$dbh->prepare (\$query) ;
86 while (@array = \$sth->fetchrow_array ()) {
87 \$rname = \$array [0] ;
88 &drop_view_if_exists (\$rname) ;
92 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='r'" ;
93 \$sth = \$dbh->prepare (\$query) ;
95 while (@array = \$sth->fetchrow_array ()) {
96 \$rname = \$array [0] ;
97 &drop_table_if_exists (\$rname) ;
101 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='i'" ;
102 \$sth = \$dbh->prepare (\$query) ;
104 while (@array = \$sth->fetchrow_array ()) {
105 \$rname = \$array [0] ;
106 &drop_index_if_exists (\$rname) ;
110 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='s'" ;
111 \$sth = \$dbh->prepare (\$query) ;
113 while (@array = \$sth->fetchrow_array ()) {
114 \$rname = \$array [0] ;
115 &drop_sequence_if_exists (\$rname) ;
122 debug "It seems your database deletion went well and smoothly. That's cool." ;
123 debug "Please enjoy using Debian GForge." ;
125 # There should be a commit at the end of every block above.
126 # If there is not, then it might be symptomatic of a problem.
127 # For safety, we roll back.
132 warn "Transaction aborted because \$@" ;
133 debug "Transaction aborted because \$@" ;
134 debug "Last SQL query was:\n\$query\n(end of query)" ;
136 debug "Please report this bug on the Debian bug-tracking system." ;
137 debug "Please include the previous messages as well to help debugging." ;
138 debug "You should not worry too much about this," ;
139 debug "your DB is still in a consistent state and should be usable." ;
149 print STDERR "\$v\n" ;
152 sub drop_table_if_exists ( \$ ) {
153 my \$tname = shift or die "Not enough arguments" ;
154 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$tname' AND relkind='r'" ;
155 my \$sth = \$dbh->prepare (\$query) ;
157 my @array = \$sth->fetchrow_array () ;
160 if (\$array [0] != 0) {
161 # debug "Dropping table \$tname" ;
162 \$query = "DROP TABLE \$tname" ;
164 \$sth = \$dbh->prepare (\$query) ;
170 sub drop_sequence_if_exists ( \$ ) {
171 my \$sname = shift or die "Not enough arguments" ;
172 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$sname' AND relkind='S'" ;
173 my \$sth = \$dbh->prepare (\$query) ;
175 my @array = \$sth->fetchrow_array () ;
178 if (\$array [0] != 0) {
179 # debug "Dropping sequence \$sname" ;
180 \$query = "DROP SEQUENCE \$sname" ;
182 \$sth = \$dbh->prepare (\$query) ;
188 sub drop_index_if_exists ( \$ ) {
189 my \$iname = shift or die "Not enough arguments" ;
190 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='i'" ;
191 my \$sth = \$dbh->prepare (\$query) ;
193 my @array = \$sth->fetchrow_array () ;
196 if (\$array [0] != 0) {
197 # debug "Dropping index \$iname" ;
198 \$query = "DROP INDEX \$iname" ;
200 \$sth = \$dbh->prepare (\$query) ;
206 sub drop_view_if_exists ( \$ ) {
207 my \$iname = shift or die "Not enough arguments" ;
208 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='v'" ;
209 my \$sth = \$dbh->prepare (\$query) ;
211 my @array = \$sth->fetchrow_array () ;
214 if (\$array [0] != 0) {
215 # debug "Dropping view \$iname" ;
216 \$query = "DROP VIEW \$iname" ;
218 \$sth = \$dbh->prepare (\$query) ;
225 echo Creating $plugdir/bin/db-upgrade.pl
226 cat > $plugdir/bin/db-upgrade.pl <<FIN
229 # Debian-specific script to upgrade the database between releases
230 # Roland Mas <lolando@debian.org>
239 use vars qw/\$dbh @reqlist \$query/ ;
240 use vars qw/\$sys_default_domain \$sys_cvs_host \$sys_download_host
241 \$sys_shell_host \$sys_users_host \$sys_docs_host \$sys_lists_host
242 \$sys_dns1_host \$sys_dns2_host \$FTPINCOMING_DIR \$FTPFILES_DIR
243 \$sys_urlroot \$sf_cache_dir \$sys_name \$sys_themeroot
244 \$sys_news_group \$sys_dbhost \$sys_dbname \$sys_dbuser \$sys_dbpasswd
245 \$sys_ldap_base_dn \$sys_ldap_host \$admin_login \$admin_password
246 \$server_admin \$domain_name \$newsadmin_groupid \$statsadmin_groupid
248 use vars qw/\$pluginname/ ;
250 sub is_lesser ( \$\$ ) ;
251 sub is_greater ( \$\$ ) ;
253 sub parse_sql_file ( \$ ) ;
255 require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions
256 require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
258 debug "You'll see some debugging info during this installation." ;
259 debug "Do not worry unless told otherwise." ;
263 # debug "Connected to the database OK." ;
265 \$pluginname = "$minus" ;
267 \$dbh->{AutoCommit} = 0;
268 \$dbh->{RaiseError} = 1;
270 my (\$sth, @array, \$version, \$path, \$target) ;
272 &create_metadata_table ("0") ;
274 \$version = &get_db_version ;
276 if (is_lesser \$version, \$target) {
277 my @filelist = ( "/usr/share/gforge/plugins/\$pluginname/lib/\$pluginname-init.sql" ) ;
279 foreach my \$file (@filelist) {
280 debug "Processing \$file" ;
281 @reqlist = @{ &parse_sql_file (\$file) } ;
283 foreach my \$s (@reqlist) {
286 \$sth = \$dbh->prepare (\$query) ;
293 &update_db_version (\$target) ;
294 debug "Committing." ;
298 \$version = &get_db_version ;
300 if (is_lesser \$version, \$target) {
301 debug "Adding local data." ;
303 do "/etc/gforge/local.pl" or die "Cannot read /etc/gforge/local.pl" ;
305 my \$ip_address = qx/host \$domain_name | awk '{print \\$3}'/ ;
308 "INSERT INTO plugin_".\$pluginname."_sample_data (domain, ip_address) VALUES ('\$domain_name', '\$ip_address')",
311 foreach my \$s (@reqlist) {
314 \$sth = \$dbh->prepare (\$query) ;
320 &update_db_version (\$target) ;
321 debug "Committing." ;
325 debug "It seems your database install/upgrade went well and smoothly. That's cool." ;
326 debug "Please enjoy using Debian GForge." ;
328 # There should be a commit at the end of every block above.
329 # If there is not, then it might be symptomatic of a problem.
330 # For safety, we roll back.
335 warn "Transaction aborted because \$@" ;
336 debug "Transaction aborted because \$@" ;
337 debug "Last SQL query was:\n\$query\n(end of query)" ;
339 debug "Please report this bug on the Debian bug-tracking system." ;
340 debug "Please include the previous messages as well to help debugging." ;
341 debug "You should not worry too much about this," ;
342 debug "your DB is still in a consistent state and should be usable." ;
349 sub is_lesser ( \$\$ ) {
350 my \$v1 = shift || 0 ;
351 my \$v2 = shift || 0 ;
353 my \$rc = system "dpkg --compare-versions \$v1 lt \$v2" ;
358 sub is_greater ( \$\$ ) {
359 my \$v1 = shift || 0 ;
360 my \$v2 = shift || 0 ;
362 my \$rc = system "dpkg --compare-versions \$v1 gt \$v2" ;
370 print STDERR "\$v\n" ;
373 sub create_metadata_table ( \$ ) {
374 my \$v = shift || "0" ;
375 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
376 # Do we have the metadata table?
378 \$query = "SELECT count(*) FROM pg_class WHERE relname = '\$tablename' and relkind = 'r'";
380 my \$sth = \$dbh->prepare (\$query) ;
382 my @array = \$sth->fetchrow_array () ;
385 # Let's create this table if we have it not
387 if (\$array [0] == 0) {
388 debug "Creating \$tablename table." ;
389 \$query = "CREATE TABLE \$tablename (key varchar primary key, value text not null)" ;
391 \$sth = \$dbh->prepare (\$query) ;
396 \$query = "SELECT count(*) FROM \$tablename WHERE key = 'db-version'";
398 \$sth = \$dbh->prepare (\$query) ;
400 @array = \$sth->fetchrow_array () ;
403 # Empty table? We'll have to fill it up a bit
405 if (\$array [0] == 0) {
406 debug "Inserting first data into \$tablename table." ;
407 \$query = "INSERT INTO \$tablename (key, value) VALUES ('db-version', '\$v')" ;
409 \$sth = \$dbh->prepare (\$query) ;
415 sub update_db_version ( \$ ) {
416 my \$v = shift or die "Not enough arguments" ;
417 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
419 debug "Updating \$tablename table." ;
420 \$query = "UPDATE \$tablename SET value = '\$v' WHERE key = 'db-version'" ;
422 my \$sth = \$dbh->prepare (\$query) ;
427 sub get_db_version () {
428 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
430 \$query = "SELECT value FROM \$tablename WHERE key = 'db-version'" ;
432 my \$sth = \$dbh->prepare (\$query) ;
434 my @array = \$sth->fetchrow_array () ;
437 my \$version = \$array [0] ;
442 sub drop_table_if_exists ( \$ ) {
443 my \$tname = shift or die "Not enough arguments" ;
444 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$tname' AND relkind='r'" ;
445 my \$sth = \$dbh->prepare (\$query) ;
447 my @array = \$sth->fetchrow_array () ;
450 if (\$array [0] != 0) {
451 # debug "Dropping table \$tname" ;
452 \$query = "DROP TABLE \$tname" ;
454 \$sth = \$dbh->prepare (\$query) ;
460 sub drop_sequence_if_exists ( \$ ) {
461 my \$sname = shift or die "Not enough arguments" ;
462 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$sname' AND relkind='S'" ;
463 my \$sth = \$dbh->prepare (\$query) ;
465 my @array = \$sth->fetchrow_array () ;
468 if (\$array [0] != 0) {
469 # debug "Dropping sequence \$sname" ;
470 \$query = "DROP SEQUENCE \$sname" ;
472 \$sth = \$dbh->prepare (\$query) ;
478 sub drop_index_if_exists ( \$ ) {
479 my \$iname = shift or die "Not enough arguments" ;
480 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='i'" ;
481 my \$sth = \$dbh->prepare (\$query) ;
483 my @array = \$sth->fetchrow_array () ;
486 if (\$array [0] != 0) {
487 # debug "Dropping index \$iname" ;
488 \$query = "DROP INDEX \$iname" ;
490 \$sth = \$dbh->prepare (\$query) ;
496 sub drop_view_if_exists ( \$ ) {
497 my \$iname = shift or die "Not enough arguments" ;
498 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='v'" ;
499 my \$sth = \$dbh->prepare (\$query) ;
501 my @array = \$sth->fetchrow_array () ;
504 if (\$array [0] != 0) {
505 # debug "Dropping view \$iname" ;
506 \$query = "DROP VIEW \$iname" ;
508 \$sth = \$dbh->prepare (\$query) ;
514 sub bump_sequence_to ( \$\$ ) {
515 my (\$sth, @array, \$seqname, \$targetvalue) ;
518 \$targetvalue = shift ;
521 \$query = "select nextval ('\$seqname')" ;
522 \$sth = \$dbh->prepare (\$query) ;
524 @array = \$sth->fetchrow_array () ;
526 } until \$array[0] >= \$targetvalue ;
530 echo Creating $plugdir/bin/$minus
531 cat > $plugdir/bin/$minus <<FIN
536 do "/etc/gforge/plugins/$minus/$minus.conf"
537 or die "Cannot read /etc/gforge/plugins/$minus/$minus.conf" ;
539 print STDOUT "\$world on STDOUT!\n" ;
540 print STDERR "\$world on STDERR!\n" ;
543 echo Creating $plugdir/etc/plugins/$minus/$minus.conf
544 cat > $plugdir/etc/plugins/$minus/$minus.conf <<FIN
548 echo Creating $plugdir/etc/plugins/$minus/config.php
549 cat > $plugdir/etc/plugins/$minus/config.php <<FIN
555 echo Creating $plugdir/httpd.conf
556 cat > $plugdir/httpd.conf <<FIN
557 <Location /plugins/$minus/>
558 SetEnv PLUGINNAME $minus
559 SetEnv PLUGINVERSION 0.1-1
563 echo Creating $plugdir/debian/README.Debian
564 cat > $plugdir/debian/README.Debian <<FIN
565 gforge-plugin-$minus for Debian
566 ----------------------------------------
568 <possible notes regarding this package - if none, delete this file>
570 -- Roland Mas <lolando@debian.org>, Tue, 26 Nov 2002 21:31:00 +0100
573 echo Creating $plugdir/debian/changelog
574 cat > $plugdir/debian/changelog <<FIN
575 gforge-plugin-$minus (0.1-1) unstable; urgency=low
579 -- Roland Mas <lolando@debian.org> Tue, 26 Nov 2002 21:31:00 +0100
583 echo Creating $plugdir/debian/control
584 cat > $plugdir/debian/control <<FIN
585 Source: gforge-plugin-$minus
588 Maintainer: Roland Mas <lolando@debian.org>
589 Build-Depends-Indep: debhelper (>> 4.0.0)
590 Standards-Version: 3.5.8
592 Package: gforge-plugin-$minus
594 Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache | gforge-web
595 Description: The ${fullname} plugin for GForge
596 This is intended as an example for developers of GForge plugins,
597 as well as an experimental area for the GForge plugin subsystem.
600 echo Creating $plugdir/debian/copyright
601 cat > $plugdir/debian/copyright <<FIN
602 This package was debianized by Roland Mas <lolando@debian.org> on
603 Tue, 26 Nov 2002 21:31:00 +0100.
605 It was downloaded from <http://savannah.nongnu.org/projects/debian-sf>
607 Upstream Author: Roland Mas <lolando@debian.org>
611 This package is free software; you can redistribute it and/or modify
612 it under the terms of the GNU General Public License as published by
613 the Free Software Foundation; version 2 dated June, 1991.
615 This package is distributed in the hope that it will be useful,
616 but WITHOUT ANY WARRANTY; without even the implied warranty of
617 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
618 GNU General Public License for more details.
620 You should have received a copy of the GNU General Public License along
621 with this program; if not, write to the Free Software Foundation, Inc.,
622 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
624 On Debian GNU/Linux systems, the complete text of the GNU General
625 Public License can be found in '/usr/share/common-licenses/GPL'.
629 echo Creating $plugdir/debian/cron.d
630 cat > $plugdir/debian/cron.d <<FIN
631 0 0 * * * gforge [ -x /usr/share/gforge/plugins/$minus/bin/$minus ] && /usr/share/gforge/plugins/$minus/bin/$minus > /dev/null 2>&1
634 echo Creating $plugdir/debian/dirs
635 cat > $plugdir/debian/dirs <<FIN
639 etc/gforge/httpd.secrets.d
641 etc/gforge/plugins/$minus
645 usr/lib/gforge/plugins/
646 usr/lib/gforge/plugins/$minus
647 usr/lib/gforge/plugins/$minus/bin
648 usr/lib/gforge/plugins/$minus/include
649 usr/lib/gforge/plugins/$minus/include/languages
650 usr/lib/gforge/plugins/$minus/lib
651 usr/lib/gforge/cgi-bin
655 usr/share/gforge/www/plugins
656 usr/share/gforge/www/plugins/$minus
659 echo Creating $plugdir/debian/postinst
660 cat > $plugdir/debian/postinst <<FIN
662 # postinst script for gforge-plugin-$minus
664 # see: dh_installdeb(1)
668 # summary of how this script can be called:
669 # * <postinst> 'configure' <most-recently-configured-version>
670 # * <old-postinst> 'abort-upgrade' <new version>
671 # * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
673 # * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
674 # <failed-install-package> <version> 'removing'
675 # <conflicting-package> <version>
676 # for details, see http://www.debian.org/doc/debian-policy/ or
677 # the debian-policy package
679 # quoting from the policy:
680 # Any necessary prompting should almost always be confined to the
681 # post-installation script, and should be protected with a conditional
682 # so that unnecessary prompting doesn't happen if a package's
683 # installation fails and the 'postinst' is called with 'abort-upgrade',
684 # 'abort-remove' or 'abort-deconfigure'.
688 /usr/share/gforge/plugins/$minus/bin/db-upgrade.pl
689 /usr/share/gforge/bin/register-plugin $minus "${fullname}"
690 invoke-rc.d apache reload
693 abort-upgrade|abort-remove|abort-deconfigure)
698 echo "postinst called with unknown argument \'\$1'" >&2
703 # dh_installdeb will replace this with shell code automatically
704 # generated by other debhelper scripts.
713 echo Creating $plugdir/debian/postrm.ex
714 cat > $plugdir/debian/postrm.ex <<FIN
716 # postrm script for gforge-plugin-$minus
718 # see: dh_installdeb(1)
722 # summary of how this script can be called:
723 # * <postrm> 'remove'
725 # * <old-postrm> 'upgrade' <new-version>
726 # * <new-postrm> 'failed-upgrade' <old-version>
727 # * <new-postrm> 'abort-install'
728 # * <new-postrm> 'abort-install' <old-version>
729 # * <new-postrm> 'abort-upgrade' <old-version>
730 # * <disappearer's-postrm> 'disappear' <r>overwrit>r> <new-version>
731 # for details, see http://www.debian.org/doc/debian-policy/ or
732 # the debian-policy package
736 purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
742 echo "postrm called with unknown argument \'\$1'" >&2
747 # dh_installdeb will replace this with shell code automatically
748 # generated by other debhelper scripts.
755 echo Creating $plugdir/debian/preinst.ex
756 cat > $plugdir/debian/preinst.ex <<FIN
758 # preinst script for gforge-plugin-$minus
760 # see: dh_installdeb(1)
764 # summary of how this script can be called:
765 # * <new-preinst> 'install'
766 # * <new-preinst> 'install' <old-version>
767 # * <new-preinst> 'upgrade' <old-version>
768 # * <old-preinst> 'abort-upgrade' <new-version>
770 # for details, see http://www.debian.org/doc/debian-policy/ or
771 # the debian-policy package
776 # if [ "\$1" = "upgrade" ]
778 # start-stop-daemon --stop --quiet --oknodo \
779 # --pidfile /var/run/gforge-plugin-$minus.pid \
780 # --exec /usr/sbin/gforge-plugin-$minus 2>/dev/null || true
788 echo "preinst called with unknown argument \'\$1'" >&2
793 # dh_installdeb will replace this with shell code automatically
794 # generated by other debhelper scripts.
803 echo Creating $plugdir/debian/prerm
804 cat > $plugdir/debian/prerm <<FIN
806 # prerm script for gforge-plugin-$minus
808 # see: dh_installdeb(1)
812 # summary of how this script can be called:
814 # * <old-prerm> 'upgrade' <new-version>
815 # * <new-prerm> 'failed-upgrade' <old-version>
816 # * <conflictor's-prerm> 'remove' 'in-favour' <package> <new-version>
817 # * <deconfigured's-prerm> 'deconfigure' 'in-favour'
818 # <package-being-installed> <version> 'removing'
819 # <conflicting-package> <version>
820 # for details, see http://www.debian.org/doc/debian-policy/ or
821 # the debian-policy package
826 /usr/share/gforge/bin/unregister-plugin $minus
827 invoke-rc.d apache reload
828 /usr/share/gforge/plugins/$minus/bin/db-delete.pl
830 upgrade|failed-upgrade)
833 echo "prerm called with unknown argument \'\$1'" >&2
838 # dh_installdeb will replace this with shell code automatically
839 # generated by other debhelper scripts.
848 echo Creating $plugdir/debian/rules
849 cat > $plugdir/debian/rules <<FIN
851 # Sample debian/rules that uses debhelper.
852 # GNU copyright 1997 to 1999 by Joey Hess.
854 # Uncomment this to turn on verbose mode.
857 # This is the debhelper compatibility version to use.
862 configure: configure-stamp
865 # Add here commands to configure the package.
866 touch configure-stamp
870 build-stamp: configure-stamp
877 rm -f build-stamp configure-stamp
880 DESTDIR=\$(CURDIR)/debian/gforge-plugin-\$(PLUGIN)
888 cp -r bin/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/bin/
889 cp -r include/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/include/
890 cp -r lib/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/lib/
891 # cp -r cgi-bin/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/cgi-bin/
892 cp -r etc/* \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/
893 cp -r www/* \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/
894 install -m 0644 httpd.conf \$(DESTDIR)/etc/gforge/httpd.d/50\$(PLUGIN)
895 # install -m 0600 httpd.secrets \$(DESTDIR)/etc/gforge/httpd.secrets.d/50\$(PLUGIN)
896 find \$(DESTDIR)/ -name CVS -type d | xargs rm -rf
897 find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/bin/ -type f | xargs chmod 0755
898 find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/include/ -type f | xargs chmod 0644
899 find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/lib/ -type f | xargs chmod 0644
900 # find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/cgi-bin/ -type f | xargs chmod 0755
901 find \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
902 find \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
905 # Build architecture-independent files here.
906 binary-indep: build install
907 # We have nothing to do by default.
909 # Build architecture-dependent files here.
910 binary-arch: build install
917 # dh_installlogrotate
939 binary: binary-indep binary-arch
940 .PHONY: build clean binary-indep binary-arch binary install configure
943 echo Creating $plugdir/include/${fullname}Plugin.class
944 cat > $plugdir/include/${fullname}Plugin.class <<FIN
947 class ${fullname}Plugin extends Plugin {
948 function ${fullname}Plugin () {
950 \$this->name = "$minus" ;
951 \$this->hooks[] = "usermenu" ;
954 function CallHook (\$hookname, \$params) {
955 global \$G_SESSION, \$HTML ;
956 if (\$hookname == "usermenu") {
957 \$text = "${fullname}" ;
958 if (\$G_SESSION->usesPlugin("$minus")) {
963 echo ' | ' . \$HTML->PrintSubMenu (array (\$text),
964 array ('/plugins/$minus/index.php?user_id=' . \$G_SESSION->getId()));
965 } elseif (\$hookname == "blahblahblah") {
973 // c-file-style: "bsd"
979 echo Creating $plugdir/include/$minus-init.php
980 cat > $plugdir/include/$minus-init.php <<FIN
983 require_once (\$GLOBALS['sys_plugins_path'].'/$minus/include/${fullname}Plugin.class') ;
985 \$${fullname}PluginObject = new ${fullname}Plugin() ;
987 register_plugin (\$${fullname}PluginObject) ;
991 // c-file-style: "bsd"
997 echo Creating $plugdir/lib/$minus-init.sql
998 cat > $plugdir/lib/$minus-init.sql <<FIN
999 CREATE TABLE plugin_${minus}_sample_data (
1005 echo Creating $plugdir/www/index.php
1006 cat > $plugdir/www/index.php <<FIN
1009 * ${fullname} plugin
1011 * Roland Mas <lolando@debian.org>
1014 require_once('pre.php');
1017 exit_error('Error','No User Id Provided');
1020 \$user = user_get_object(\$user_id);
1023 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1024 exit_error("Invalid User", "That user does not exist.");
1026 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1027 \$user_name = \$user->getRealName();
1029 if (\$user->usesPlugin("$minus")) {
1030 print \$HTML->boxTop("\$user_name says ${fullname}!");
1032 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1034 print '<A HREF="toggle.php?user_id='.\$user_id.'">Toggle!</A>' ;
1035 print "This is the $minus plugin. I hope you enjoy it." ;
1036 print '<A HREF="/my/">Back to My Peronal Page.</A>' ;
1037 print \$HTML->boxBottom();
1038 print \$HTML->footer(array());
1043 // c-file-style: "bsd"
1049 echo Creating $plugdir/www/toggle.php
1050 cat > $plugdir/www/toggle.php <<FIN
1053 * ${fullname} plugin
1055 * Roland Mas <lolando@debian.org>
1058 require_once('pre.php');
1061 exit_error('Error','No User Id Provided');
1064 \$user = user_get_object(\$user_id);
1067 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1068 exit_error("Invalid User", "That user does not exist.");
1070 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1071 \$user_name = \$user->getRealName();
1073 if (\$user->usesPlugin("$minus")) {
1074 print \$HTML->boxTop("\$user_name says ${fullname}!");
1076 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1078 print "And now, I'm toggling the use of the ${fullname} plugin...\n" ;
1079 \$user->setPluginUse("$minus", !\$user->usesPlugin("$minus")) ;
1080 print "done. Let's try it out.\n" ;
1082 if (\$user->usesPlugin("$minus")) {
1083 print \$HTML->boxMiddle("\$user_name now says ${fullname}!");
1085 print \$HTML->boxMiddle("\$user_name now does not say ${fullname}...");
1087 print '<A HREF="index.php?user_id='.\$user_id.'">Back to index.</A>' ;
1088 print \$HTML->boxBottom();
1089 print \$HTML->footer(array());
1094 // c-file-style: "bsd"
1111 echo $minus already exist, Aborting....