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
34 # Debian-specific script to delete plugin-specific tables
35 # Roland Mas <lolando@debian.org>
44 use vars qw/\$dbh @reqlist \$query/ ;
45 use vars qw/\$sys_default_domain \$sys_cvs_host \$sys_download_host
46 \$sys_shell_host \$sys_users_host \$sys_docs_host \$sys_lists_host
47 \$sys_dns1_host \$sys_dns2_host \$FTPINCOMING_DIR \$FTPFILES_DIR
48 \$sys_urlroot \$sf_cache_dir \$sys_name \$sys_themeroot
49 \$sys_news_group \$sys_dbhost \$sys_dbname \$sys_dbuser \$sys_dbpasswd
50 \$sys_ldap_base_dn \$sys_ldap_host \$admin_login \$admin_password
51 \$server_admin \$domain_name \$newsadmin_groupid \$statsadmin_groupid
53 use vars qw/\$pluginname/ ;
55 sub is_lesser ( \$\$ ) ;
56 sub is_greater ( \$\$ ) ;
58 sub parse_sql_file ( \$ ) ;
60 require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions
61 require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
63 debug "You'll see some debugging info during this installation." ;
64 debug "Do not worry unless told otherwise." ;
68 # debug "Connected to the database OK." ;
70 \$pluginname = "$minus" ;
72 \$dbh->{AutoCommit} = 0;
73 \$dbh->{RaiseError} = 1;
75 my (\$sth, @array, \$version, \$action, \$path, \$target, \$rname) ;
77 my \$pattern = "plugin_" . \$pluginname . '_%' ;
79 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='v'" ;
80 \$sth = \$dbh->prepare (\$query) ;
82 while (@array = \$sth->fetchrow_array ()) {
83 \$rname = \$array [0] ;
84 &drop_view_if_exists (\$rname) ;
88 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='r'" ;
89 \$sth = \$dbh->prepare (\$query) ;
91 while (@array = \$sth->fetchrow_array ()) {
92 \$rname = \$array [0] ;
93 &drop_table_if_exists (\$rname) ;
97 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='i'" ;
98 \$sth = \$dbh->prepare (\$query) ;
100 while (@array = \$sth->fetchrow_array ()) {
101 \$rname = \$array [0] ;
102 &drop_index_if_exists (\$rname) ;
106 \$query = "SELECT relname FROM pg_class WHERE relname LIKE '\$pattern' AND relkind='s'" ;
107 \$sth = \$dbh->prepare (\$query) ;
109 while (@array = \$sth->fetchrow_array ()) {
110 \$rname = \$array [0] ;
111 &drop_sequence_if_exists (\$rname) ;
118 debug "It seems your database deletion went well and smoothly. That's cool." ;
119 debug "Please enjoy using Debian GForge." ;
121 # There should be a commit at the end of every block above.
122 # If there is not, then it might be symptomatic of a problem.
123 # For safety, we roll back.
128 warn "Transaction aborted because \$@" ;
129 debug "Transaction aborted because \$@" ;
130 debug "Last SQL query was:\n\$query\n(end of query)" ;
132 debug "Please report this bug on the Debian bug-tracking system." ;
133 debug "Please include the previous messages as well to help debugging." ;
134 debug "You should not worry too much about this," ;
135 debug "your DB is still in a consistent state and should be usable." ;
145 print STDERR "\$v\n" ;
148 sub drop_table_if_exists ( \$ ) {
149 my \$tname = shift or die "Not enough arguments" ;
150 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$tname' AND relkind='r'" ;
151 my \$sth = \$dbh->prepare (\$query) ;
153 my @array = \$sth->fetchrow_array () ;
156 if (\$array [0] != 0) {
157 # debug "Dropping table \$tname" ;
158 \$query = "DROP TABLE \$tname" ;
160 \$sth = \$dbh->prepare (\$query) ;
166 sub drop_sequence_if_exists ( \$ ) {
167 my \$sname = shift or die "Not enough arguments" ;
168 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$sname' AND relkind='S'" ;
169 my \$sth = \$dbh->prepare (\$query) ;
171 my @array = \$sth->fetchrow_array () ;
174 if (\$array [0] != 0) {
175 # debug "Dropping sequence \$sname" ;
176 \$query = "DROP SEQUENCE \$sname" ;
178 \$sth = \$dbh->prepare (\$query) ;
184 sub drop_index_if_exists ( \$ ) {
185 my \$iname = shift or die "Not enough arguments" ;
186 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='i'" ;
187 my \$sth = \$dbh->prepare (\$query) ;
189 my @array = \$sth->fetchrow_array () ;
192 if (\$array [0] != 0) {
193 # debug "Dropping index \$iname" ;
194 \$query = "DROP INDEX \$iname" ;
196 \$sth = \$dbh->prepare (\$query) ;
202 sub drop_view_if_exists ( \$ ) {
203 my \$iname = shift or die "Not enough arguments" ;
204 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='v'" ;
205 my \$sth = \$dbh->prepare (\$query) ;
207 my @array = \$sth->fetchrow_array () ;
210 if (\$array [0] != 0) {
211 # debug "Dropping view \$iname" ;
212 \$query = "DROP VIEW \$iname" ;
214 \$sth = \$dbh->prepare (\$query) ;
221 echo Creating $plugdir/bin/db-upgrade.pl
222 cat > $plugdir/bin/db-upgrade.pl <<FIN
225 # Debian-specific script to upgrade the database between releases
226 # Roland Mas <lolando@debian.org>
235 use vars qw/\$dbh @reqlist \$query/ ;
236 use vars qw/\$sys_default_domain \$sys_cvs_host \$sys_download_host
237 \$sys_shell_host \$sys_users_host \$sys_docs_host \$sys_lists_host
238 \$sys_dns1_host \$sys_dns2_host \$FTPINCOMING_DIR \$FTPFILES_DIR
239 \$sys_urlroot \$sf_cache_dir \$sys_name \$sys_themeroot
240 \$sys_news_group \$sys_dbhost \$sys_dbname \$sys_dbuser \$sys_dbpasswd
241 \$sys_ldap_base_dn \$sys_ldap_host \$admin_login \$admin_password
242 \$server_admin \$domain_name \$newsadmin_groupid \$statsadmin_groupid
244 use vars qw/\$pluginname/ ;
246 sub is_lesser ( \$\$ ) ;
247 sub is_greater ( \$\$ ) ;
249 sub parse_sql_file ( \$ ) ;
251 require ("/usr/share/gforge/lib/include.pl") ; # Include a few predefined functions
252 require ("/usr/share/gforge/lib/sqlparser.pm") ; # Our magic SQL parser
254 debug "You'll see some debugging info during this installation." ;
255 debug "Do not worry unless told otherwise." ;
259 # debug "Connected to the database OK." ;
261 \$pluginname = "$minus" ;
263 \$dbh->{AutoCommit} = 0;
264 \$dbh->{RaiseError} = 1;
266 my (\$sth, @array, \$version, \$path, \$target) ;
268 &create_metadata_table ("0") ;
270 \$version = &get_db_version ;
272 if (is_lesser \$version, \$target) {
273 my @filelist = ( "/usr/share/gforge/plugins/\$pluginname/lib/\$pluginname-init.sql" ) ;
275 foreach my \$file (@filelist) {
276 debug "Processing \$file" ;
277 @reqlist = @{ &parse_sql_file (\$file) } ;
279 foreach my \$s (@reqlist) {
282 \$sth = \$dbh->prepare (\$query) ;
289 &update_db_version (\$target) ;
290 debug "Committing." ;
294 \$version = &get_db_version ;
296 if (is_lesser \$version, \$target) {
297 debug "Adding local data." ;
299 do "/etc/gforge/local.pl" or die "Cannot read /etc/gforge/local.pl" ;
301 my \$ip_address = qx/host \$domain_name | awk '{print \\$3}'/ ;
304 "INSERT INTO plugin_".\$pluginname."_sample_data (domain, ip_address) VALUES ('\$domain_name', '\$ip_address')",
307 foreach my \$s (@reqlist) {
310 \$sth = \$dbh->prepare (\$query) ;
316 &update_db_version (\$target) ;
317 debug "Committing." ;
321 debug "It seems your database install/upgrade went well and smoothly. That's cool." ;
322 debug "Please enjoy using Debian GForge." ;
324 # There should be a commit at the end of every block above.
325 # If there is not, then it might be symptomatic of a problem.
326 # For safety, we roll back.
331 warn "Transaction aborted because \$@" ;
332 debug "Transaction aborted because \$@" ;
333 debug "Last SQL query was:\n\$query\n(end of query)" ;
335 debug "Please report this bug on the Debian bug-tracking system." ;
336 debug "Please include the previous messages as well to help debugging." ;
337 debug "You should not worry too much about this," ;
338 debug "your DB is still in a consistent state and should be usable." ;
345 sub is_lesser ( \$\$ ) {
346 my \$v1 = shift || 0 ;
347 my \$v2 = shift || 0 ;
349 my \$rc = system "dpkg --compare-versions \$v1 lt \$v2" ;
354 sub is_greater ( \$\$ ) {
355 my \$v1 = shift || 0 ;
356 my \$v2 = shift || 0 ;
358 my \$rc = system "dpkg --compare-versions \$v1 gt \$v2" ;
366 print STDERR "\$v\n" ;
369 sub create_metadata_table ( \$ ) {
370 my \$v = shift || "0" ;
371 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
372 # Do we have the metadata table?
374 \$query = "SELECT count(*) FROM pg_class WHERE relname = '\$tablename' and relkind = 'r'";
376 my \$sth = \$dbh->prepare (\$query) ;
378 my @array = \$sth->fetchrow_array () ;
381 # Let's create this table if we have it not
383 if (\$array [0] == 0) {
384 debug "Creating \$tablename table." ;
385 \$query = "CREATE TABLE \$tablename (key varchar primary key, value text not null)" ;
387 \$sth = \$dbh->prepare (\$query) ;
392 \$query = "SELECT count(*) FROM \$tablename WHERE key = 'db-version'";
394 \$sth = \$dbh->prepare (\$query) ;
396 @array = \$sth->fetchrow_array () ;
399 # Empty table? We'll have to fill it up a bit
401 if (\$array [0] == 0) {
402 debug "Inserting first data into \$tablename table." ;
403 \$query = "INSERT INTO \$tablename (key, value) VALUES ('db-version', '\$v')" ;
405 \$sth = \$dbh->prepare (\$query) ;
411 sub update_db_version ( \$ ) {
412 my \$v = shift or die "Not enough arguments" ;
413 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
415 debug "Updating \$tablename table." ;
416 \$query = "UPDATE \$tablename SET value = '\$v' WHERE key = 'db-version'" ;
418 my \$sth = \$dbh->prepare (\$query) ;
423 sub get_db_version () {
424 my \$tablename = "plugin_" .\$pluginname . "_meta_data" ;
426 \$query = "SELECT value FROM \$tablename WHERE key = 'db-version'" ;
428 my \$sth = \$dbh->prepare (\$query) ;
430 my @array = \$sth->fetchrow_array () ;
433 my \$version = \$array [0] ;
438 sub drop_table_if_exists ( \$ ) {
439 my \$tname = shift or die "Not enough arguments" ;
440 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$tname' AND relkind='r'" ;
441 my \$sth = \$dbh->prepare (\$query) ;
443 my @array = \$sth->fetchrow_array () ;
446 if (\$array [0] != 0) {
447 # debug "Dropping table \$tname" ;
448 \$query = "DROP TABLE \$tname" ;
450 \$sth = \$dbh->prepare (\$query) ;
456 sub drop_sequence_if_exists ( \$ ) {
457 my \$sname = shift or die "Not enough arguments" ;
458 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$sname' AND relkind='S'" ;
459 my \$sth = \$dbh->prepare (\$query) ;
461 my @array = \$sth->fetchrow_array () ;
464 if (\$array [0] != 0) {
465 # debug "Dropping sequence \$sname" ;
466 \$query = "DROP SEQUENCE \$sname" ;
468 \$sth = \$dbh->prepare (\$query) ;
474 sub drop_index_if_exists ( \$ ) {
475 my \$iname = shift or die "Not enough arguments" ;
476 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='i'" ;
477 my \$sth = \$dbh->prepare (\$query) ;
479 my @array = \$sth->fetchrow_array () ;
482 if (\$array [0] != 0) {
483 # debug "Dropping index \$iname" ;
484 \$query = "DROP INDEX \$iname" ;
486 \$sth = \$dbh->prepare (\$query) ;
492 sub drop_view_if_exists ( \$ ) {
493 my \$iname = shift or die "Not enough arguments" ;
494 \$query = "SELECT count(*) FROM pg_class WHERE relname='\$iname' AND relkind='v'" ;
495 my \$sth = \$dbh->prepare (\$query) ;
497 my @array = \$sth->fetchrow_array () ;
500 if (\$array [0] != 0) {
501 # debug "Dropping view \$iname" ;
502 \$query = "DROP VIEW \$iname" ;
504 \$sth = \$dbh->prepare (\$query) ;
510 sub bump_sequence_to ( \$\$ ) {
511 my (\$sth, @array, \$seqname, \$targetvalue) ;
514 \$targetvalue = shift ;
517 \$query = "select nextval ('\$seqname')" ;
518 \$sth = \$dbh->prepare (\$query) ;
520 @array = \$sth->fetchrow_array () ;
522 } until \$array[0] >= \$targetvalue ;
526 echo Creating $plugdir/bin/$minus
527 cat > $plugdir/bin/$minus <<FIN
532 do "/etc/gforge/plugins/$minus/$minus.conf"
533 or die "Cannot read /etc/gforge/plugins/$minus/$minus.conf" ;
535 print STDOUT "\$world on STDOUT!\n" ;
536 print STDERR "\$world on STDERR!\n" ;
539 echo Creating $plugdir/etc/plugins/$minus/$minus.conf
540 cat > $plugdir/etc/plugins/$minus/$minus.conf <<FIN
544 echo Creating $plugdir/etc/plugins/$minus/config.php
545 cat > $plugdir/etc/plugins/$minus/config.php <<FIN
551 echo Creating $plugdir/httpd.conf
552 cat > $plugdir/httpd.conf <<FIN
553 <Location /plugins/$minus/>
554 SetEnv PLUGINNAME $minus
555 SetEnv PLUGINVERSION 0.1-1
559 echo Creating $plugdir/debian/README.Debian
560 cat > $plugdir/debian/README.Debian <<FIN
561 gforge-plugin-$minus for Debian
562 ----------------------------------------
564 <possible notes regarding this package - if none, delete this file>
566 -- Roland Mas <lolando@debian.org>, Tue, 26 Nov 2002 21:31:00 +0100
569 echo Creating $plugdir/debian/changelog
570 cat > $plugdir/debian/changelog <<FIN
571 gforge-plugin-$minus (0.1-1) unstable; urgency=low
575 -- Roland Mas <lolando@debian.org> Tue, 26 Nov 2002 21:31:00 +0100
579 echo Creating $plugdir/debian/control
580 cat > $plugdir/debian/control <<FIN
581 Source: gforge-plugin-$minus
584 Maintainer: Roland Mas <lolando@debian.org>
585 Build-Depends-Indep: debhelper (>> 4.0.0)
586 Standards-Version: 3.5.8
588 Package: gforge-plugin-$minus
590 Depends: gforge-common, gforge-db-postgresql | gforge-db, gforge-web-apache | gforge-web
591 Description: The ${fullname} plugin for GForge
592 This is intended as an example for developers of GForge plugins,
593 as well as an experimental area for the GForge plugin subsystem.
596 echo Creating $plugdir/debian/copyright
597 cat > $plugdir/debian/copyright <<FIN
598 This package was debianized by Roland Mas <lolando@debian.org> on
599 Tue, 26 Nov 2002 21:31:00 +0100.
601 It was downloaded from <http://savannah.nongnu.org/projects/debian-sf>
603 Upstream Author: Roland Mas <lolando@debian.org>
607 This package is free software; you can redistribute it and/or modify
608 it under the terms of the GNU General Public License as published by
609 the Free Software Foundation; version 2 dated June, 1991.
611 This package is distributed in the hope that it will be useful,
612 but WITHOUT ANY WARRANTY; without even the implied warranty of
613 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
614 GNU General Public License for more details.
616 You should have received a copy of the GNU General Public License
617 along with this package; if not, write to the Free Software
618 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
621 On Debian GNU/Linux systems, the complete text of the GNU General
622 Public License can be found in '/usr/share/common-licenses/GPL'.
626 echo Creating $plugdir/debian/cron.d
627 cat > $plugdir/debian/cron.d <<FIN
628 0 0 * * * gforge [ -x /usr/share/gforge/plugins/$minus/bin/$minus ] && /usr/share/gforge/plugins/$minus/bin/$minus > /dev/null 2>&1
631 echo Creating $plugdir/debian/dirs
632 cat > $plugdir/debian/dirs <<FIN
636 etc/gforge/httpd.secrets.d
638 etc/gforge/plugins/$minus
642 usr/lib/gforge/plugins/
643 usr/lib/gforge/plugins/$minus
644 usr/lib/gforge/plugins/$minus/bin
645 usr/lib/gforge/plugins/$minus/include
646 usr/lib/gforge/plugins/$minus/include/languages
647 usr/lib/gforge/plugins/$minus/lib
648 usr/lib/gforge/cgi-bin
652 usr/share/gforge/www/plugins
653 usr/share/gforge/www/plugins/$minus
656 echo Creating $plugdir/debian/postinst
657 cat > $plugdir/debian/postinst <<FIN
659 # postinst script for gforge-plugin-$minus
661 # see: dh_installdeb(1)
665 # summary of how this script can be called:
666 # * <postinst> 'configure' <most-recently-configured-version>
667 # * <old-postinst> 'abort-upgrade' <new version>
668 # * <conflictor's-postinst> 'abort-remove' 'in-favour' <package>
670 # * <deconfigured's-postinst> 'abort-deconfigure' 'in-favour'
671 # <failed-install-package> <version> 'removing'
672 # <conflicting-package> <version>
673 # for details, see http://www.debian.org/doc/debian-policy/ or
674 # the debian-policy package
676 # quoting from the policy:
677 # Any necessary prompting should almost always be confined to the
678 # post-installation script, and should be protected with a conditional
679 # so that unnecessary prompting doesn't happen if a package's
680 # installation fails and the 'postinst' is called with 'abort-upgrade',
681 # 'abort-remove' or 'abort-deconfigure'.
685 /usr/share/gforge/plugins/$minus/bin/db-upgrade.pl
686 /usr/share/gforge/bin/register-plugin $minus "${fullname}"
687 invoke-rc.d apache reload
690 abort-upgrade|abort-remove|abort-deconfigure)
695 echo "postinst called with unknown argument \'\$1'" >&2
700 # dh_installdeb will replace this with shell code automatically
701 # generated by other debhelper scripts.
710 echo Creating $plugdir/debian/postrm.ex
711 cat > $plugdir/debian/postrm.ex <<FIN
713 # postrm script for gforge-plugin-$minus
715 # see: dh_installdeb(1)
719 # summary of how this script can be called:
720 # * <postrm> 'remove'
722 # * <old-postrm> 'upgrade' <new-version>
723 # * <new-postrm> 'failed-upgrade' <old-version>
724 # * <new-postrm> 'abort-install'
725 # * <new-postrm> 'abort-install' <old-version>
726 # * <new-postrm> 'abort-upgrade' <old-version>
727 # * <disappearer's-postrm> 'disappear' <r>overwrit>r> <new-version>
728 # for details, see http://www.debian.org/doc/debian-policy/ or
729 # the debian-policy package
733 purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
739 echo "postrm called with unknown argument \'\$1'" >&2
744 # dh_installdeb will replace this with shell code automatically
745 # generated by other debhelper scripts.
752 echo Creating $plugdir/debian/preinst.ex
753 cat > $plugdir/debian/preinst.ex <<FIN
755 # preinst script for gforge-plugin-$minus
757 # see: dh_installdeb(1)
761 # summary of how this script can be called:
762 # * <new-preinst> 'install'
763 # * <new-preinst> 'install' <old-version>
764 # * <new-preinst> 'upgrade' <old-version>
765 # * <old-preinst> 'abort-upgrade' <new-version>
767 # for details, see http://www.debian.org/doc/debian-policy/ or
768 # the debian-policy package
773 # if [ "\$1" = "upgrade" ]
775 # start-stop-daemon --stop --quiet --oknodo \
776 # --pidfile /var/run/gforge-plugin-$minus.pid \
777 # --exec /usr/sbin/gforge-plugin-$minus 2>/dev/null || true
785 echo "preinst called with unknown argument \'\$1'" >&2
790 # dh_installdeb will replace this with shell code automatically
791 # generated by other debhelper scripts.
800 echo Creating $plugdir/debian/prerm
801 cat > $plugdir/debian/prerm <<FIN
803 # prerm script for gforge-plugin-$minus
805 # see: dh_installdeb(1)
809 # summary of how this script can be called:
811 # * <old-prerm> 'upgrade' <new-version>
812 # * <new-prerm> 'failed-upgrade' <old-version>
813 # * <conflictor's-prerm> 'remove' 'in-favour' <package> <new-version>
814 # * <deconfigured's-prerm> 'deconfigure' 'in-favour'
815 # <package-being-installed> <version> 'removing'
816 # <conflicting-package> <version>
817 # for details, see http://www.debian.org/doc/debian-policy/ or
818 # the debian-policy package
823 /usr/share/gforge/bin/unregister-plugin $minus
824 invoke-rc.d apache reload
825 /usr/share/gforge/plugins/$minus/bin/db-delete.pl
827 upgrade|failed-upgrade)
830 echo "prerm called with unknown argument \'\$1'" >&2
835 # dh_installdeb will replace this with shell code automatically
836 # generated by other debhelper scripts.
845 echo Creating $plugdir/debian/rules
846 cat > $plugdir/debian/rules <<FIN
848 # Sample debian/rules that uses debhelper.
849 # GNU copyright 1997 to 1999 by Joey Hess.
851 # Uncomment this to turn on verbose mode.
854 # This is the debhelper compatibility version to use.
859 configure: configure-stamp
862 # Add here commands to configure the package.
863 touch configure-stamp
867 build-stamp: configure-stamp
874 rm -f build-stamp configure-stamp
877 DESTDIR=\$(CURDIR)/debian/gforge-plugin-\$(PLUGIN)
885 cp -r bin/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/bin/
886 cp -r include/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/include/
887 cp -r lib/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/lib/
888 # cp -r cgi-bin/* \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/cgi-bin/
889 cp -r etc/* \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/
890 cp -r www/* \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/
891 install -m 0644 httpd.conf \$(DESTDIR)/etc/gforge/httpd.d/50\$(PLUGIN)
892 # install -m 0600 httpd.secrets \$(DESTDIR)/etc/gforge/httpd.secrets.d/50\$(PLUGIN)
893 find \$(DESTDIR)/ -name CVS -type d | xargs rm -rf
894 find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/bin/ -type f | xargs chmod 0755
895 find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/include/ -type f | xargs chmod 0644
896 find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/lib/ -type f | xargs chmod 0644
897 # find \$(DESTDIR)/usr/share/gforge/plugins/\$(PLUGIN)/cgi-bin/ -type f | xargs chmod 0755
898 find \$(DESTDIR)/etc/gforge/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
899 find \$(DESTDIR)/usr/share/gforge/www/plugins/\$(PLUGIN)/ -type f | xargs chmod 0644
902 # Build architecture-independent files here.
903 binary-indep: build install
904 # We have nothing to do by default.
906 # Build architecture-dependent files here.
907 binary-arch: build install
914 # dh_installlogrotate
936 binary: binary-indep binary-arch
937 .PHONY: build clean binary-indep binary-arch binary install configure
940 echo Creating $plugdir/include/${fullname}Plugin.class
941 cat > $plugdir/include/${fullname}Plugin.class <<FIN
944 class ${fullname}Plugin extends Plugin {
945 function ${fullname}Plugin () {
947 \$this->name = "$minus" ;
948 \$this->hooks[] = "usermenu" ;
951 function CallHook (\$hookname, \$params) {
952 global \$G_SESSION, \$HTML ;
953 if (\$hookname == "usermenu") {
954 \$text = "${fullname}" ;
955 if (\$G_SESSION->usesPlugin("$minus")) {
960 echo ' | ' . \$HTML->PrintSubMenu (array (\$text),
961 array ('/plugins/$minus/index.php?user_id=' . \$G_SESSION->getId()));
962 } elseif (\$hookname == "blahblahblah") {
970 // c-file-style: "bsd"
976 echo Creating $plugdir/include/$minus-init.php
977 cat > $plugdir/include/$minus-init.php <<FIN
980 require_once (\$GLOBALS['sys_plugins_path'].'/$minus/include/${fullname}Plugin.class') ;
982 \$${fullname}PluginObject = new ${fullname}Plugin() ;
984 register_plugin (\$${fullname}PluginObject) ;
988 // c-file-style: "bsd"
994 echo Creating $plugdir/lib/$minus-init.sql
995 cat > $plugdir/lib/$minus-init.sql <<FIN
996 CREATE TABLE plugin_${minus}_sample_data (
1002 echo Creating $plugdir/www/index.php
1003 cat > $plugdir/www/index.php <<FIN
1006 * ${fullname} plugin
1008 * Roland Mas <lolando@debian.org>
1011 require_once('pre.php');
1014 exit_error('Error','No User Id Provided');
1017 \$user = user_get_object(\$user_id);
1020 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1021 exit_error("Invalid User", "That user does not exist.");
1023 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1024 \$user_name = \$user->getRealName();
1026 if (\$user->usesPlugin("$minus")) {
1027 print \$HTML->boxTop("\$user_name says ${fullname}!");
1029 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1031 print '<A HREF="toggle.php?user_id='.\$user_id.'">Toggle!</A>' ;
1032 print "This is the $minus plugin. I hope you enjoy it." ;
1033 print '<A HREF="/my/">Back to My Peronal Page.</A>' ;
1034 print \$HTML->boxBottom();
1035 print \$HTML->footer(array());
1040 // c-file-style: "bsd"
1046 echo Creating $plugdir/www/toggle.php
1047 cat > $plugdir/www/toggle.php <<FIN
1050 * ${fullname} plugin
1052 * Roland Mas <lolando@debian.org>
1055 require_once('pre.php');
1058 exit_error('Error','No User Id Provided');
1061 \$user = user_get_object(\$user_id);
1064 if (!\$user || !is_object(\$user) || \$user->isError() || !\$user->isActive()) {
1065 exit_error("Invalid User", "That user does not exist.");
1067 print \$HTML->header(array('title'=>'${fullname}','pagename'=>'$minus'));
1068 \$user_name = \$user->getRealName();
1070 if (\$user->usesPlugin("$minus")) {
1071 print \$HTML->boxTop("\$user_name says ${fullname}!");
1073 print \$HTML->boxTop("\$user_name does not say ${fullname}...");
1075 print "And now, I'm toggling the use of the ${fullname} plugin...\n" ;
1076 \$user->setPluginUse("$minus", !\$user->usesPlugin("$minus")) ;
1077 print "done. Let's try it out.\n" ;
1079 if (\$user->usesPlugin("$minus")) {
1080 print \$HTML->boxMiddle("\$user_name now says ${fullname}!");
1082 print \$HTML->boxMiddle("\$user_name now does not say ${fullname}...");
1084 print '<A HREF="index.php?user_id='.\$user_id.'">Back to index.</A>' ;
1085 print \$HTML->boxBottom();
1086 print \$HTML->footer(array());
1091 // c-file-style: "bsd"
1108 echo $minus already exist, Aborting....