4 echo Usage: $0 PluginName
7 echo "Plugin template creator"
13 minus=`echo $1 | tr '[A-Z]' '[a-z]'`
14 plugdir=gforge-plugin-$minus
15 echo "Creating $1 plugin"
16 echo "Creating directory $plugdir"
22 mkdir $plugdir/etc/plugins
23 mkdir $plugdir/etc/plugins/$minus
25 mkdir $plugdir/include
26 mkdir $plugdir/include/languages
30 echo Creating $plugdir/bin/db-delete.pl
31 cat > $plugdir/bin/db-delete.pl <<FIN
36 # Debian-specific script to delete plugin-specific tables
37 # Roland Mas <lolando@debian.org>
46 use vars qw/\$dbh @reqlist \$query/ ;
47 use vars qw/\$sys_default_domain \$sys_cvs_host \$sys_download_host
48 \$sys_shell_host \$sys_users_host \$sys_docs_host \$sys_lists_host
49 \$sys_dns1_host \$sys_dns2_host \$FTPINCOMING_DIR \$FTPFILES_DIR
50 \$sys_urlroot \$sf_cache_dir \$sys_name \$sys_themeroot
51 \$sys_news_group \$sys_dbhost \$sys_dbname \$sys_dbuser \$sys_dbpasswd
52 \$sys_ldap_base_dn \$sys_ldap_host \$admin_login \$admin_password
53 \$server_admin \$domain_name \$newsadmin_groupid \$statsadmin_groupid
55 use vars qw/\$pluginname/ ;
57 sub is_lesser ( \$\$ ) ;
58 sub is_greater ( \$\$ ) ;
60 sub parse_sql_file ( \$ ) ;
62 require ("/usr/lib/gforge/lib/include.pl") ; # Include a few predefined functions
63 require ("/usr/lib/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
65 debug "You'll see some debugging info during this installation." ;
66 debug "Do not worry unless told otherwise." ;
70 # debug "Connected to the database OK." ;
72 \$pluginname = "$minus" ;
74 \$dbh->{AutoCommit} = 0;
75 \$dbh->{RaiseError} = 1;
77 my (\$sth, @array, \$version, \$action, \$path, \$target, \$rname) ;
79 my \$pattern = "plugin_" . \$pluginname . '_%' ;
81 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='v'" ;
82 \$sth = \$dbh->prepare (\$query) ;
84 while (@array = \$sth->fetchrow_array ()) {
85 \$rname = \$array [0] ;
86 &drop_view_if_exists (\$rname) ;
90 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='r'" ;
91 \$sth = \$dbh->prepare (\$query) ;
93 while (@array = \$sth->fetchrow_array ()) {
94 \$rname = \$array [0] ;
95 &drop_table_if_exists (\$rname) ;
99 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='i'" ;
100 \$sth = \$dbh->prepare (\$query) ;
102 while (@array = \$sth->fetchrow_array ()) {
103 \$rname = \$array [0] ;
104 &drop_index_if_exists (\$rname) ;
108 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='s'" ;
109 \$sth = \$dbh->prepare (\$query) ;
111 while (@array = \$sth->fetchrow_array ()) {
112 \$rname = \$array [0] ;
113 &drop_sequence_if_exists (\$rname) ;
120 debug "It seems your database deletion went well and smoothly. That's cool." ;
121 debug "Please enjoy using Debian GForge." ;
123 # There should be a commit at the end of every block above.
124 # If there is not, then it might be symptomatic of a problem.
125 # For safety, we roll back.
130 warn "Transaction aborted because \$@" ;
131 debug "Transaction aborted because \$@" ;
132 debug "Last SQL query was:\n\$query\n(end of query)" ;
134 debug "Please report this bug on the Debian bug-tracking system." ;
135 debug "Please include the previous messages as well to help debugging." ;
136 debug "You should not worry too much about this," ;
137 debug "your DB is still in a consistent state and should be usable." ;
147 print STDERR "\$v\n" ;
150 sub drop_table_if_exists ( \$ ) {
151 my \$tname = shift or die "Not enough arguments" ;
152 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$tname' AND relkind='r'" ;
153 my \$sth = \$dbh->prepare (\$query) ;
155 my @array = \$sth->fetchrow_array () ;
158 if (\$array [0] != 0) {
159 # debug "Dropping table \$tname" ;
160 \$query = "DROP TABLE \$tname" ;
162 \$sth = \$dbh->prepare (\$query) ;
168 sub drop_sequence_if_exists ( \$ ) {
169 my \$sname = shift or die "Not enough arguments" ;
170 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$sname' AND relkind='S'" ;
171 my \$sth = \$dbh->prepare (\$query) ;
173 my @array = \$sth->fetchrow_array () ;
176 if (\$array [0] != 0) {
177 # debug "Dropping sequence \$sname" ;
178 \$query = "DROP SEQUENCE \$sname" ;
180 \$sth = \$dbh->prepare (\$query) ;
186 sub drop_index_if_exists ( \$ ) {
187 my \$iname = shift or die "Not enough arguments" ;
188 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='i'" ;
189 my \$sth = \$dbh->prepare (\$query) ;
191 my @array = \$sth->fetchrow_array () ;
194 if (\$array [0] != 0) {
195 # debug "Dropping index \$iname" ;
196 \$query = "DROP INDEX \$iname" ;
198 \$sth = \$dbh->prepare (\$query) ;
204 sub drop_view_if_exists ( \$ ) {
205 my \$iname = shift or die "Not enough arguments" ;
206 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='v'" ;
207 my \$sth = \$dbh->prepare (\$query) ;
209 my @array = \$sth->fetchrow_array () ;
212 if (\$array [0] != 0) {
213 # debug "Dropping view \$iname" ;
214 \$query = "DROP VIEW \$iname" ;
216 \$sth = \$dbh->prepare (\$query) ;
223 echo Creating $plugdir/bin/db-upgrade.pl
224 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/lib/gforge/lib/include.pl") ; # Include a few predefined functions
256 require ("/usr/lib/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/lib/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
621 along with this package; if not, write to the Free Software
622 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
625 On Debian GNU/Linux systems, the complete text of the GNU General
626 Public License can be found in '/usr/share/common-licenses/GPL'.
630 echo Creating $plugdir/debian/cron.d
631 cat > $plugdir/debian/cron.d <<FIN
632 0 0 * * * gforge [ -x /usr/lib/gforge/plugins/$minus/bin/$minus ] && /usr/lib/gforge/plugins/$minus/bin/$minus > /dev/null 2>&1
635 echo Creating $plugdir/debian/dirs
636 cat > $plugdir/debian/dirs <<FIN
640 etc/gforge/httpd.secrets.d
642 etc/gforge/plugins/$minus
646 usr/lib/gforge/plugins/
647 usr/lib/gforge/plugins/$minus
648 usr/lib/gforge/plugins/$minus/bin
649 usr/lib/gforge/plugins/$minus/include
650 usr/lib/gforge/plugins/$minus/include/languages
651 usr/lib/gforge/plugins/$minus/lib
652 usr/lib/gforge/cgi-bin
656 usr/share/gforge/www/plugins
657 usr/share/gforge/www/plugins/$minus
660 echo Creating $plugdir/debian/postinst
661 cat > $plugdir/debian/postinst <<FIN
663 # postinst script for gforge-plugin-$minus
665 # see: dh_installdeb(1)
669 # summary of how this script can be called:
670 # * <postinst> 'configure' <most-recently-configured-version>
671 # * <old-postinst> 'abort-upgrade' <new version>
672 # * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
674 # * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
675 # <failed-install-package> <version> 'removing'
676 # <conflicting-package> <version>
677 # for details, see http://www.debian.org/doc/debian-policy/ or
678 # the debian-policy package
680 # quoting from the policy:
681 # Any necessary prompting should almost always be confined to the
682 # post-installation script, and should be protected with a conditional
683 # so that unnecessary prompting doesn't happen if a package's
684 # installation fails and the 'postinst' is called with 'abort-upgrade',
685 # 'abort-remove' or 'abort-deconfigure'.
689 /usr/lib/gforge/plugins/$minus/bin/db-upgrade.pl
690 /usr/lib/gforge/bin/register-plugin $minus "${fullname}"
691 invoke-rc.d apache reload
694 abort-upgrade|abort-remove|abort-deconfigure)
699 echo "postinst called with unknown argument \'\$1'" >&2
704 # dh_installdeb will replace this with shell code automatically
705 # generated by other debhelper scripts.
714 echo Creating $plugdir/debian/postrm.ex
715 cat > $plugdir/debian/postrm.ex <<FIN
717 # postrm script for gforge-plugin-$minus
719 # see: dh_installdeb(1)
723 # summary of how this script can be called:
724 # * <postrm> 'remove'
726 # * <old-postrm> 'upgrade' <new-version>
727 # * <new-postrm> 'failed-upgrade' <old-version>
728 # * <new-postrm> 'abort-install'
729 # * <new-postrm> 'abort-install' <old-version>
730 # * <new-postrm> 'abort-upgrade' <old-version>
731 # * <disappearer's-postrm> 'disappear' <r>overwrit>r> <new-version>
732 # for details, see http://www.debian.org/doc/debian-policy/ or
733 # the debian-policy package
737 purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
743 echo "postrm called with unknown argument \'\$1'" >&2
748 # dh_installdeb will replace this with shell code automatically
749 # generated by other debhelper scripts.
756 echo Creating $plugdir/debian/preinst.ex
757 cat > $plugdir/debian/preinst.ex <<FIN
759 # preinst script for gforge-plugin-$minus
761 # see: dh_installdeb(1)
765 # summary of how this script can be called:
766 # * <new-preinst> 'install'
767 # * <new-preinst> 'install' <old-version>
768 # * <new-preinst> 'upgrade' <old-version>
769 # * <old-preinst> 'abort-upgrade' <new-version>
771 # for details, see http://www.debian.org/doc/debian-policy/ or
772 # the debian-policy package
777 # if [ "\$1" = "upgrade" ]
779 # start-stop-daemon --stop --quiet --oknodo \
780 # --pidfile /var/run/gforge-plugin-$minus.pid \
781 # --exec /usr/sbin/gforge-plugin-$minus 2>/dev/null || true
789 echo "preinst called with unknown argument \'\$1'" >&2
794 # dh_installdeb will replace this with shell code automatically
795 # generated by other debhelper scripts.
804 echo Creating $plugdir/debian/prerm
805 cat > $plugdir/debian/prerm <<FIN
807 # prerm script for gforge-plugin-$minus
809 # see: dh_installdeb(1)
813 # summary of how this script can be called:
815 # * <old-prerm> 'upgrade' <new-version>
816 # * <new-prerm> 'failed-upgrade' <old-version>
817 # * <conflictor's-prerm> 'remove' 'in-favour' <package> <new-version>
818 # * <deconfigured's-prerm> 'deconfigure' 'in-favour'
819 # <package-being-installed> <version> 'removing'
820 # <conflicting-package> <version>
821 # for details, see http://www.debian.org/doc/debian-policy/ or
822 # the debian-policy package
827 /usr/lib/gforge/bin/unregister-plugin $minus
828 invoke-rc.d apache reload
829 /usr/lib/gforge/plugins/$minus/bin/db-delete.pl
831 upgrade|failed-upgrade)
834 echo "prerm called with unknown argument \'\$1'" >&2
839 # dh_installdeb will replace this with shell code automatically
840 # generated by other debhelper scripts.
849 echo Creating $plugdir/debian/rules
850 cat > $plugdir/debian/rules <<FIN
852 # Sample debian/rules that uses debhelper.
853 # GNU copyright 1997 to 1999 by Joey Hess.
855 # Uncomment this to turn on verbose mode.
858 # This is the debhelper compatibility version to use.
863 configure: configure-stamp
866 # Add here commands to configure the package.
867 touch configure-stamp
871 build-stamp: configure-stamp
878 rm -f build-stamp configure-stamp
881 DESTDIR=\$(CURDIR)/debian/gforge-plugin-\$(PLUGIN)
889 cp -r bin/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/bin/
890 cp -r include/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/include/
891 cp -r lib/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/lib/
892 # cp -r cgi-bin/* \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/cgi-bin/
893 cp -r etc/* \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/
894 cp -r www/* \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/
895 install -m 0644 httpd.conf \$(DESTDIR)/etc/gforge/httpd.d/50\$(PLUGIN)
896 # install -m 0600 httpd.secrets \$(DESTDIR)/etc/gforge/httpd.secrets.d/50\$(PLUGIN)
897 find \$(DESTDIR)/ -name CVS -type d | xargs rm -rf
898 find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/bin/ -type f | xargs chmod 0755
899 find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/include/ -type f | xargs chmod 0644
900 find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/lib/ -type f | xargs chmod 0644
901 # find \$(DESTDIR)/usr/lib/gforge/plugins/\$(PLUGIN)/cgi-bin/ -type f | xargs chmod 0755
902 find \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
903 find \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
906 # Build architecture-independent files here.
907 binary-indep: build install
908 # We have nothing to do by default.
910 # Build architecture-dependent files here.
911 binary-arch: build install
918 # dh_installlogrotate
940 binary: binary-indep binary-arch
941 .PHONY: build clean binary-indep binary-arch binary install configure
944 echo Creating $plugdir/include/${fullname}Plugin.class
945 cat > $plugdir/include/${fullname}Plugin.class <<FIN
948 class ${fullname}Plugin extends Plugin {
949 function ${fullname}Plugin () {
951 \$this->name = "$minus" ;
952 \$this->hooks[] = "usermenu" ;
955 function CallHook (\$hookname, \$params) {
956 global \$Language, \$G_SESSION, \$HTML ;
957 if (\$hookname == "usermenu") {
958 \$text = "${fullname}" ;
959 if (\$G_SESSION->usesPlugin("$minus")) {
964 echo ' | ' . \$HTML->PrintSubMenu (array (\$text),
965 array ('/plugins/$minus/index.php?user_id=' . \$G_SESSION->getId()));
966 } elseif (\$hookname == "blahblahblah") {
974 // c-file-style: "bsd"
980 echo Creating $plugdir/include/$minus-init.php
981 cat > $plugdir/include/$minus-init.php <<FIN
984 require_once (\$GLOBALS['sys_plugins_path'].'/$minus/include/${fullname}Plugin.class') ;
986 \$${fullname}PluginObject = new ${fullname}Plugin() ;
988 register_plugin (\$${fullname}PluginObject) ;
992 // c-file-style: "bsd"
998 echo Creating $plugdir/lib/$minus-init.sql
999 cat > $plugdir/lib/$minus-init.sql <<FIN
1000 CREATE TABLE plugin_${minus}_sample_data (
1006 echo Creating $plugdir/www/index.php
1007 cat > $plugdir/www/index.php <<FIN
1010 * ${fullname} plugin
1012 * Roland Mas <lolando@debian.org>
1015 require_once('pre.php');
1018 exit_error('Error','No User Id Provided');
1021 \$user = user_get_object(\$user_id);
1024 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1025 exit_error("Invalid User", "That user does not exist.");
1027 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1028 \$user_name = \$user->getRealName();
1030 if (\$user->usesPlugin("$minus")) {
1031 print \$HTML->boxTop("\$user_name says ${fullname}!");
1033 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1035 print '<A HREF="toggle.php?user_id='.\$user_id.'">Toggle!</A>' ;
1036 print "This is the $minus plugin. I hope you enjoy it." ;
1037 print '<A HREF="/my/">Back to My Peronal Page.</A>' ;
1038 print \$HTML->boxBottom();
1039 print \$HTML->footer(array());
1044 // c-file-style: "bsd"
1050 echo Creating $plugdir/www/toggle.php
1051 cat > $plugdir/www/toggle.php <<FIN
1054 * ${fullname} plugin
1056 * Roland Mas <lolando@debian.org>
1059 require_once('pre.php');
1062 exit_error('Error','No User Id Provided');
1065 \$user = user_get_object(\$user_id);
1068 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1069 exit_error("Invalid User", "That user does not exist.");
1071 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1072 \$user_name = \$user->getRealName();
1074 if (\$user->usesPlugin("$minus")) {
1075 print \$HTML->boxTop("\$user_name says ${fullname}!");
1077 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1079 print "And now, I'm toggling the use of the ${fullname} plugin...\n" ;
1080 \$user->setPluginUse("$minus", !\$user->usesPlugin("$minus")) ;
1081 print "done. Let's try it out.\n" ;
1083 if (\$user->usesPlugin("$minus")) {
1084 print \$HTML->boxMiddle("\$user_name now says ${fullname}!");
1086 print \$HTML->boxMiddle("\$user_name now does not say ${fullname}...");
1088 print '<A HREF="index.php?user_id='.\$user_id.'">Back to index.</A>' ;
1089 print \$HTML->boxBottom();
1090 print \$HTML->footer(array());
1095 // c-file-style: "bsd"
1112 echo $minus already exist, Aborting....