[freeside-commits] freeside/debian README.Debian, 1.1, 1.1.14.1 TODO, NONE, 1.1.2.2 changelog, 1.2, 1.2.6.1 compat, NONE, 1.1.2.2 conffiles.ex, 1.1, NONE config, NONE, 1.1.2.2 control, 1.3, 1.3.4.1 copyright, 1.1, 1.1.14.1 cron.d, NONE, 1.1.2.2 cron.d.ex, 1.1, NONE dbconfig-common.install, NONE, 1.1.2.2 dbconfig-common.upgrade, NONE, 1.1.2.2 dirs, 1.1, NONE docs, 1.1, NONE ex.doc-base.package, 1.1, NONE freeside-doc.docs, 1.1, NONE freeside-doc.files, 1.1, NONE freeside-webui.links, NONE, 1.1.2.2 freeside.apache-alias.conf, NONE, 1.1.2.2 freeside.default, NONE, 1.1.2.2 freeside.docs, NONE, 1.1.2.2 init.d.ex, 1.1, 1.1.14.1 init.d.lsb.ex, NONE, 1.1.2.2 manpage.1.ex, 1.1, NONE manpage.sgml.ex, 1.1, NONE menu.ex, 1.1, NONE postinst, NONE, 1.1.2.2 postinst.ex, 1.1, NONE postrm, NONE, 1.1.2.2 postrm.ex, 1.1, NONE preinst, NONE, 1.1.2.2 preinst.ex, 1.1, NONE prerm, NONE, 1.1.2.2 prerm.ex, 1.1, NONE rules, 1.1, 1.1.14.1 templates, NONE, 1.1.2.2 watch.ex, 1.1, NONE

Ivan,,, ivan at wavetail.420.am
Mon Apr 7 22:49:23 PDT 2008


Update of /home/cvs/cvsroot/freeside/debian
In directory wavetail.420.am:/tmp/cvs-serv14878

Modified Files:
      Tag: FREESIDE_1_7_BRANCH
	README.Debian changelog control copyright init.d.ex rules 
Added Files:
      Tag: FREESIDE_1_7_BRANCH
	TODO compat config cron.d dbconfig-common.install 
	dbconfig-common.upgrade freeside-webui.links 
	freeside.apache-alias.conf freeside.default freeside.docs 
	init.d.lsb.ex postinst postrm preinst prerm templates 
Removed Files:
      Tag: FREESIDE_1_7_BRANCH
	conffiles.ex cron.d.ex dirs docs ex.doc-base.package 
	freeside-doc.docs freeside-doc.files manpage.1.ex 
	manpage.sgml.ex menu.ex postinst.ex postrm.ex preinst.ex 
	prerm.ex watch.ex 
Log Message:
debian packages!

Index: control
===================================================================
RCS file: /home/cvs/cvsroot/freeside/debian/control,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -d -r1.3 -r1.3.4.1
--- control	23 Jan 2004 00:49:36 -0000	1.3
+++ control	8 Apr 2008 05:49:20 -0000	1.3.4.1
@@ -1,59 +1,59 @@
 Source: freeside
-Section: admin
-Priority: optional
+Section: misc
+Priority: extra
 Maintainer: Ivan Kohler <ivan-debian at 420.am>
-Build-Depends: debhelper (>> 3.0.0)
-Standards-Version: 3.5.2
+Build-Depends: debhelper (>= 5), perl (>= 5.8)
+Standards-Version: 3.7.2
+Homepage: http://www.freeside.biz/freeside
+Vcs-Browser: http://www.freeside.biz/cgi-bin/viewvc.cgi/freeside/
+Vcs-Cvs: :pserver:anonymous:anonymous at cvs.420.am:/home/cvs/cvsroot freeside
 
 Package: freeside
-Architecture: any
-Depends: freeside-lib
-Recommends: freeside-doc, freeside-ui-web
-Suggests: freeside-selfservice-server
-Description: Billing and administration package for ISPs.
- Freeside is a billing and account administration package for ISPs.  It stores
- customer information in an SQL database, and will update UNIX passwd and
- shadow files, RADIUS users file and SQL databases, and configuration for
- sendmail, qmail, BIND and/or Apache.  It is also useful as a central database
- of accounts/domains/web-space for a large number of machines.
-
-Package: freeside-doc
 Architecture: all
-Description: Documentation for freeside
- This package provides the HTML documentation for Freeside, a billing and
- account administration package for ISPs.
+Pre-Depends: freeside-lib, dbconfig-common
+Depends: ${perl:Depends}, ${shlibs:Depends}, ${misc:Depends}, freeside-webui, debconf, adduser (>= 3.11)
+Recommends: cron
+Suggests: gnupg
+Description: Billing and trouble ticketing for service providers
+ Freeside is a web-based billing and trouble ticketing application.  It
+ includes features for ISPs, hosting providers, and VoIP providers, but can
+ also be used as a generic customer database, invoicing and membership
+ application.  If you like buzzwords, call it an "BSS/OSS and CRM solution".
 
 Package: freeside-lib
 Architecture: all
-Depends: libmime-base64-perl, libdigest-md5-perl, liburi-perl, libhtml-tagset-perl, libhtml-parser-perl, libnet-perl, liblocale-codes-perl, libnet-whois-perl, libwww-perl, libbusiness-creditcard-perl, libmailtools-perl, libtimedate-perl, libdate-manip-perl, libfile-counterfile-perl, libfreezethaw-perl, libtext-template-perl, libdbd-pg-perl, libdbix-datasource-perl, libdbix-dbschema-perl, libnet-ssh-perl, libnet-scp-perl, libapache-asp-perl, libtie-ixhash-perl, libtime-duration-perl, libhtml-widgets-selectlayers-perl, libstorable-perl, libapache-dbi-perl
-Description: Freeside libraries and extension API
- This package contains the libraries which implement the business logic and
- backend functions of Freeside, a billing and account administration package
- for ISPs.  This package also contains the manual pages for the library API.
- (? like a libmodule-perl package)
-
-Package: freeside-ui-web
-Architecture: all
-Depends: libhtml-mason-perl, libstring-approx-perl, freeside-lib, libapache-mod-perl|apache-perl
-Suggests: libapache-mod-ssl|apache-ssl
-Description: Easy-to-use web interface for Freeside
- This package contains the web interface for Freeside, a billing and account
- administration package for ISPs.  This is what sales or support folks will
- typically use to add new accounts, edit exiting accounts and so on.
+Depends: ghostscript | gs-gpl, gsfonts, tetex-base, tetex-bin, libbusiness-creditcard-perl, libcache-cache-perl, libcache-simple-timedexpiry-perl, libclass-returnvalue-perl, libcrypt-passwdmd5-perl, libdate-manip-perl, libdbd-pg-perl | libdbd-mysql-perl, libdbi-perl, libdbix-dbschema-perl (>= 0.35), libdbix-searchbuilder-perl, libdigest-sha1-perl, libfile-counterfile-perl, libfile-rsync-perl, libfrontier-rpc-perl, libhtml-format-perl, libhtml-tree-perl, libipc-run3-perl, libipc-sharelite-perl,  liblingua-en-nameparse-perl, liblocale-maketext-fuzzy-perl, liblocale-maketext-lexicon-perl, liblocale-subcountry-perl, liblog-dispatch-perl, libmailtools-perl (>= 2), libmime-perl (>= 5.424) | libmime-perl (< 5.421), libnet-scp-perl, libnet-ssh-perl, libnet-whois-raw-perl, libnetaddr-ip-perl, libnumber-format-perl, libregexp-common-perl, libstring-approx-perl, libstring-shellquote-perl, libterm-readkey-perl, libtest-inline-perl, libtext-autoformat-perl, libtext-csv-perl, libtext-template-perl, libtext-wrapper-perl, libtie-ixhash-perl, libtime-duration-perl, libtime-modules-perl, libtimedate-perl, libuniversal-require-perl, liburi-perl, libwant-perl, libwww-perl
+Recommends: libdbd-pg-perl, libdbd-mysql-perl, rsync
+Suggests: libbusiness-onlinepayment-perl
+Description: Libraries for Freeside billing and trouble ticketing
+ Freeside is a web-based billing and trouble ticketing application.
+ .
+ This package provides the perl libraries and command line utilities.
 
-Package: freeside-selfservice-server
-Architecture: all
-Depends: freeside-lib, libnet-ssh-perl, ssh
-Description:
- This package contains the server side of the customer self-service interface.
- It is installed on a private backend machine, and opens an outgoing ssh
- connection to one or more public web server(s).
+#Package: freeside-bin
+#Architecture: all
+#Depends: freeside-lib
+#Description: Command line tools for Freeside billing and trouble ticketing
+# Freeside is a web-based billing and trouble ticketing application.
+# .
+# This package provides the command-line utilities.
 
-Package: freeside-selfservice-client
+Package: freeside-webui
 Architecture: all
-Depends: libstorable-perl, libhttp-browserdetect-perl, libbusiness-creditcard-perl, ssh
-Description:
- This package contains the client side of the customer self-service interface.
- It is typically installed on a public webserver and interfaces with
- freeside-selfservice-server installed on a private backend machine.
+Depends: freeside-lib, apache2, libapache2-mod-perl2, libapache2-request-perl, libapache-session-perl, libchart-perl, libcolor-scheme-perl, libdatetime-perl, libdatetime-format-strptime-perl, libgd-gd2-noxpm-perl | libgd-gd2-perl, libgd-graph-perl, libhtml-mason-perl, libhtml-scrubber-perl, libhtml-widgets-selectlayers-perl, libio-stringy-perl, libjson-perl, liblingua-en-inflect-perl, libmodule-versions-report-perl, libspreadsheet-writeexcel-perl, libtree-simple-perl, libyaml-perl
+Recommends: libapache-dbi-perl
+Description: Web interface for Freeside billing and trouble ticketing
+ Freeside is a web-based billing and trouble ticketing application.
+ .
+ This package provides the web interface for employees.
 
+#Package: freeside-selfservice-client
+#Architecture: all
+#Description: End-customer interface to Freeside billing and trouble ticketing
+# Freeside is a web-based billing and trouble ticketing application.
+# .
+# This package provides customer signup and self-service web interfaces and
+# XML-RPC, PHP and Perl APIs.
+# .
+# In production use, this package is typically installed on a public web server,
+# separate from the rest of the freeside-* packages.

--- dirs DELETED ---

--- conffiles.ex DELETED ---

--- freeside-doc.docs DELETED ---

--- prerm.ex DELETED ---

--- manpage.1.ex DELETED ---

--- NEW FILE: freeside-webui.links ---
etc/freeside/apache2/freeside-alias.conf etc/apache2/conf.d/freeside-alias.conf
etc/freeside/apache2/freeside-base2.conf etc/apache2/conf.d/freeside-base2.conf
etc/freeside/apache2/freeside-rt.conf    etc/apache2/conf.d/freeside-rt.conf


--- NEW FILE: prerm ---
#!/bin/sh
# prerm script for freeside
#
# see: dh_installdeb(1)

set -e

# source debconf stuff
. /usr/share/debconf/confmodule
# source dbconfig-common stuff
. /usr/share/dbconfig-common/dpkg/prerm 
dbc_go freeside $@

# summary of how this script can be called:
#        * <prerm> `remove'
#        * <old-prerm> `upgrade' <new-version>
#        * <new-prerm> `failed-upgrade' <old-version>
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
#          <package-being-installed> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    remove|upgrade|deconfigure)
    ;;

    failed-upgrade)
    ;;

    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0



--- NEW FILE: dbconfig-common.install ---
#!/bin/sh

. /etc/dbconfig-common/freeside.conf

DB_USER=$dbc_dbuser
DB_PASSWORD=$dbc_dbpass

# -- can't find a better place to hook this in.  dammit.

[ "$dbc_dbtype" = "pgsql" ] && DB_TYPE=Pg
[ "$dbc_dbtype" = "mysql" ] && DB_TYPE=mysql
#XXX ask dbc about a remote database etc.
DATASOURCE=DBI:${DB_TYPE}:dbname=${dbc_dbname}
    
#debian/rules
FREESIDE_CONF=/etc/freeside
FREESIDE_CACHE=/var/cache/freeside
#XXX huh?
FREESIDE_EXPORT=/var/spool/freeside
DEFAULT_CONF=/usr/share/freeside/default_conf
    
#XXX this rather seriously needs proper debian-style config file handling.
    
#shamelessly lifted from Makefile create-config target
[ -e ${FREESIDE_CONF} ] || install -d -o freeside ${FREESIDE_CONF}
    
touch ${FREESIDE_CONF}/secrets
chown freeside ${FREESIDE_CONF}/secrets
chmod 600 ${FREESIDE_CONF}/secrets
    
[ -s ${FREESIDE_CONF}/secrets ] || echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
chmod 600 ${FREESIDE_CONF}/secrets
chown freeside ${FREESIDE_CONF}/secrets
    
#XXX yuck!  this too!
[ -e /var/opt/freeside/rt/etc/RT_Config.pm.dbc ] || cp /var/opt/freeside/rt/etc/RT_Config.pm.dbc.generic /var/opt/freeside/rt/etc/RT_Config.pm.dbc
perl -pi.generic -e "s/^\\s*Set\\s*\\(\s*\\\$DatabaseType.*\$/Set(\\\$DatabaseType, '$DB_TYPE');/" /var/opt/freeside/rt/etc/RT_Config.pm.dbc
mv /var/opt/freeside/rt/etc/RT_Config.pm.dbc /var/opt/freeside/rt/etc/RT_Config.pm
perl -pi -e "\
  s'_DBC_DBUSER_'${dbc_dbuser}'g;\
  s'_DBC_DBPASS_'${dbc_dbpass}'g;\
  s'_DBC_DBNAME_'${dbc_dbname}'g;\
" /var/opt/freeside/rt/etc/RT_Config.pm
 
#dunno how to hook this in where i need it...
#dbc_generate_include="template:/var/opt/freeside/rt/etc/RT_Config.pm"
#dbc_generate_include_args="-o template_infile=/var/opt/freeside/rt/etc/RT_Config.pm.dbc"
	    
install -o freeside -d "${FREESIDE_CACHE}/counters.${DATASOURCE}"
install -o freeside -d "${FREESIDE_CACHE}/cache.${DATASOURCE}"
install -o freeside -d "${FREESIDE_EXPORT}/export.${DATASOURCE}"
	    
if [ ! -d "${FREESIDE_CONF}/conf.${DATASOURCE}" ] ; then #don't clobber conf
install -o freeside -d "${FREESIDE_CONF}/conf.${DATASOURCE}"
#cp conf/[a-z]* "${FREESIDE_CONF}/conf.${DATASOURCE}"
cp -i `ls -d ${DEFAULT_CONF}/[a-z]* | grep -v CVS` "${FREESIDE_CONF}/conf.${DATASOURCE}" #-i just in case
chown -R freeside "${FREESIDE_CONF}/conf.${DATASOURCE}"
fi
	
# -- back to your regularly schedule program... go ahead, create the db

DOMAIN=`dnsdomainname`
if [ "$DOMAIN" = "localdomain" ]; then #freeside needs a valid domain
  DOMAIN='example.com'
fi

# XXX this should probably be handled by the _install_...
# dpkg-statoverride or something
chown freeside /etc/freeside

su freeside -c "/usr/bin/freeside-setup -d $DOMAIN"
su freeside -c '/usr/bin/freeside-adduser -g 1 fs_queue'
su freeside -c '/usr/bin/freeside-adduser -g 1 fs_daily'
su freeside -c '/usr/bin/freeside-adduser -g 1 fs_selfservice'
su freeside -c '/usr/bin/freeside-adduser -g 1 fs_upgrade'

#RT paths are bunk for deb proper

chown freeside /var/opt/freeside/rt/etc/RT_Config.pm

su freeside -c "/var/opt/freeside/rt/sbin/rt-setup-database --dba '$DB_USER' --dba-password '$DB_PASSWORD' --action schema"

su freeside -c '/var/opt/freeside/rt/sbin/rt-setup-database --action insert_initial'

su freeside -c '/var/opt/freeside/rt/sbin/rt-setup-database --action insert --datafile /var/opt/freeside/rt/etc/initialdata'

#XXX this totally doesn't belong here, but what the hey
chown -R freeside /var/cache/freeside/masondata

exit 0

--- NEW FILE: config ---
#!/bin/sh
# config script for freeside

set -e

# source debconf stuff
. /usr/share/debconf/confmodule

# source dbconfig-common shell library, and call the hook function
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
   # we support mysql and pgsql
   dbc_dbtypes="pgsql, mysql"

   # source dbconfig-common stuff
   . /usr/share/dbconfig-common/dpkg/config 
   dbc_go freeside $@
fi

# ... rest of your code ...

Index: README.Debian
===================================================================
RCS file: /home/cvs/cvsroot/freeside/debian/README.Debian,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -d -r1.1 -r1.1.14.1
--- README.Debian	5 Jun 2001 21:40:55 -0000	1.1
+++ README.Debian	8 Apr 2008 05:49:19 -0000	1.1.14.1
@@ -1,6 +1,25 @@
-freeside for Debian
+Freeside for Debian
 -------------------
 
-<possible notes regarding this package - if none, delete this file>
+1.
+Edit /etc/apache2/envvars or /etc/apache2/apache2.conf and set User and Group
+to freeside
 
- -- Ivan Kohler <ivan-debian at 420.am>, Thu, 12 Apr 2001 15:49:17 -0700
+2.
+/etc/init.d/apache2 restart
+
+3.
+Create one or more Freeside users (your internal sales/tech folks, not customer accounts): 
+$ su
+# su freeside
+$ freeside-adduser -g 1 desired_username
+$ htpasswd /etc/freeside/htpasswd username
+(enter password)
+
+4.
+Go to http://your.host.name/freeside and log in.
+
+Optional but recommended.
+(Hopefully) get an SSL certificate setup and change that to https://
+
+ -- Ivan Kohler <ivan-debian at 420.am>  Wed, 02 Apr 2008 01:46:20 -0700

--- NEW FILE: compat ---
5

--- menu.ex DELETED ---

Index: copyright
===================================================================
RCS file: /home/cvs/cvsroot/freeside/debian/copyright,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -d -r1.1 -r1.1.14.1
--- copyright	5 Jun 2001 21:40:55 -0000	1.1
+++ copyright	8 Apr 2008 05:49:20 -0000	1.1.14.1
@@ -1,10 +1,45 @@
 This package was debianized by Ivan Kohler <ivan-debian at 420.am> on
-Thu, 12 Apr 2001 15:49:17 -0700.
+Wed, 02 Apr 2008 01:46:20 -0700.
 
-It was downloaded from <fill in ftp site>
+It was downloaded from <http://www.freeside.biz/freeside>
 
-Upstream Author(s): <put author(s) name and email here>
+Upstream Author(s): 
 
-Copyright:
+    Freeside Internet Services, Inc.
+
+Copyright: 
+
+Copyright (C) 2005-2008 Freeside Internet Services, Inc.
+Copyright (C) 2000-2005 Ivan Kohler
+Copyright (C) 1999 Silicon Interactive Software Design
+All rights reserved
+
+before uploading to debian proper: <likewise for all other copyrights from httemplate/docs/license.html>
+
+License:
+
+    This package is free software; you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published
+    by the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+ 
+    This package is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+ 
+    You should have received a copy of the GNU Affero General Public License
+    along with this package; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+On Debian systems, the complete text of the GNU Affero General
+Public License may someday be found in `/usr/share/common-licenses/AGPL'.
+Until then, you can find it in `/usr/share/doc/freeside/AGPL'.
+
+The Debian packaging is (C) 2008, Ivan Kohler <ivan-debian at 420.am> and
+is licensed under the AGPL, see above.
+
+before uploading to debian proper, from httemplate/docs/license.html:
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
 
-<Must follow here>

--- freeside-doc.files DELETED ---

--- postinst.ex DELETED ---

--- postrm.ex DELETED ---

--- NEW FILE: dbconfig-common.upgrade ---
#!/bin/sh
su freeside -c '/usr/bin/freeside-upgrade fs_upgrade'
#RT upgrade

--- NEW FILE: preinst ---
#!/bin/sh
# preinst script for freeside
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    install|upgrade)

       # If the package has default file it could be sourced, so that
       # the local admin can overwrite the defaults
     
       [ -f "/etc/default/freeside" ] && . /etc/default/freeside
     
       # Sane defaults:
     
       [ -z "$FREESIDE_HOME" ] && FREESIDE_HOME=/home/freeside
       [ -z "$FREESIDE_USER" ] && FREESIDE_USER=freeside
       [ -z "$FREESIDE_NAME"   ] && FREESIDE_NAME="Freeside"
       [ -z "$FREESIDE_GROUP"  ] && FREESIDE_GROUP=freeside

       [ -z "$RT_GROUP"  ] && RT_GROUP=rt
     
       # Groups that the user will be added to, if undefined, then none.
       ADDGROUP="rt"
     
       # create user to avoid running server as root
       # 1. create group if not existing
       if ! getent group | grep -q "^$FREESIDE_GROUP:" -; then
          echo -n "Adding group $FREESIDE_GROUP.."
          addgroup --quiet --system $FREESIDE_GROUP 2>/dev/null ||true
          echo "..done"
       fi
       if ! getent group | grep -q "^$RT_GROUP:" -; then
          echo -n "Adding group $RT_GROUP.."
          addgroup --quiet --system $RT_GROUP 2>/dev/null ||true
          echo "..done"
       fi
       # 2. create homedir if not existing
       test -d $FREESIDE_HOME || mkdir $FREESIDE_HOME
       # 3. create user if not existing
       if ! getent passwd | grep -q "^$FREESIDE_USER:" -; then
         echo -n "Adding system user $FREESIDE_USER.."
         adduser --quiet \
                 --system \
                 --ingroup $FREESIDE_GROUP \
                 --shell /bin/sh \
                 --no-create-home \
                 --disabled-password \
                 $FREESIDE_USER 2>/dev/null || true
         echo "..done"
       fi
       # 4. adjust passwd entry
       usermod -c "$FREESIDE_NAME" \
               -d $FREESIDE_HOME   \
               -g $FREESIDE_GROUP  \
                  $FREESIDE_USER
       # 5. adjust file and directory permissions
       if ! dpkg-statoverride --list $FREESIDE_HOME >/dev/null
       then
           chown -R $FREESIDE_USER:adm $FREESIDE_HOME
           chmod u=rwx,g=rxs,o= $FREESIDE_HOME
       fi
       # 6. Add the user to the ADDGROUP group
       if test -n $ADDGROUP
       then
           if ! groups $FREESIDE_USER | cut -d: -f2 | \
              grep -qw $ADDGROUP -; then
                adduser $FREESIDE_USER $ADDGROUP
           fi
       fi
    ;;

    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0



--- NEW FILE: freeside.apache-alias.conf ---
Alias /freeside/ /usr/share/freeside/www/

--- NEW FILE: templates ---

Index: rules
===================================================================
RCS file: /home/cvs/cvsroot/freeside/debian/rules,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -d -r1.1 -r1.1.14.1
--- rules	5 Jun 2001 21:40:55 -0000	1.1
+++ rules	8 Apr 2008 05:49:21 -0000	1.1.14.1
@@ -1,113 +1,229 @@
 #!/usr/bin/make -f
-# Sample debian/rules that uses debhelper. 
-# GNU copyright 1997 by Joey Hess.
-#
-# This version is for a hypothetical package that builds an
-# architecture-dependant package, as well as an architecture-independent
-# package.
+# -*- makefile -*-
 
-# Uncomment this to turn on verbose mode. 
+# Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
-# This is the debhelper compatability version to use.
-export DH_COMPAT=3
+# If set to a true value then MakeMaker's prompt function will
+# always return the default without waiting for user input.
+#export PERL_MM_USE_DEFAULT=1
+
+PERL   ?= /usr/bin/perl
+#PACKAGE = $(shell dh_listpackages)
+PACKAGE = freeside
+TMP     = $(CURDIR)/debian/$(PACKAGE)
+DBC_SCRIPTS = $(TMP)/usr/share/dbconfig-common/scripts/freeside
+
+#this is gotten from dbconfig-common
+DB_TYPE = db_type_is_configured_during_pkg_install_by_dbconfig-common_not_at_build_time
+
+#no chance, it doesn't get backslash-interpolted now...
+#DEBVERSION                    = `head -1 debian/changelog | cut -d')' -f1 | cut -c11-`
+DEBVERSION                    = 1.7.3~rc2-1
+export VERSION                = $(DEBVERSION) (Debian)
+
+export FREESIDE_CONF          = /etc/freeside
+export FREESIDE_LOG           = /var/log/freeside
+export FREESIDE_LOCK          = /var/lock/freeside
+export FREESIDE_CACHE         = $(TMP)/var/cache/freeside
+FREESIDE_CACHE         = $(TMP)/var/cache/freeside
+
+#XXX huh?
+export FREESIDE_EXPORT        = /var/spool/freeside
+
+#XXX own subdir?
+export MASON_HANDLER          = $(TMP)-webui/usr/share/freeside/handler.pl
+
+export APACHE_VERSION         = 2
+export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui/usr/share/freeside/www
+export INIT_FILE              = $(TMP).init
+export INIT_INSTALL           = /bin/true
+export HTTPD_RESTART          = /bin/true
+#export APACHE_CONF            = $(TMP)-webui/etc/apache2/conf.d
+export APACHE_CONF            = $(TMP)-webui/etc/freeside/apache2
+export FREESIDE_RESTART       = /bin/true
+
+#XXX root?
+export INSTALLGROUP           = adm
+
+export SELFSERVICE_MACHINES   = 
+
+#prompt ?   XXX these are runtime, not buildtime :/
+export RT_DOMAIN              = `dnsdomainname`
+export RT_TIMEZONE            = `cat /etc/timezone`
+
+export HOSTNAME               = `hostname -f`
+export FREESIDE_URL           = http://$(HOSTNAME)/freeside/
+
+#specific to deb pkg, for purposes of saving off a permanent copy of default
+#config for postinst and that sort of thing
+export DEFAULT_CONF           = $(TMP)/usr/share/freeside/default_conf
+
+#XXX yuck.  proper RT layout is entirely necessary
+#this seems to infect way to much of RT with the build location, requiring
+# a kludge to hack it out afterwords.  look into using fakeroot (didn't
+# realize it would need to be explicit argh)
+# (but leaving it for now, otherwise can't get RT to put files where we need em)
+export RT_PATH                = $(TMP)/var/opt/freeside/rt
+
+# This has to be exported to make some magic below work.
+export DH_OPTIONS
 
 configure: configure-stamp
 configure-stamp:
 	dh_testdir
 	# Add here commands to configure the package.
 	
-
 	touch configure-stamp
 
-build: configure-stamp build-stamp
-build-stamp:
+
+build: build-stamp
+build-stamp: 
 	dh_testdir
+	# Add commands to compile the package here
+	
+	( cd FS/ && $(PERL) Makefile.PL INSTALLDIRS=vendor )
 
-	# Add here commands to compile the package.
-	$(MAKE)
+	$(MAKE) -e perl-modules
 
-	touch build-stamp
+	#TEST#
+
+	touch $@
 
 clean:
 	dh_testdir
 	dh_testroot
-	rm -f build-stamp configure-stamp
+	dh_clean build-stamp install-stamp
 
 	# Add here commands to clean up after the build process.
-	-$(MAKE) clean
+	$(MAKE) -e clean
+	#|| true #XXX freeside clean target fucked
 
-	dh_clean
+	dh_clean 
 
-install: DH_OPTIONS=
-install: build
+install: install-stamp
+install-stamp: build-stamp
 	dh_testdir
 	dh_testroot
 	dh_clean -k
 	dh_installdirs
 
-	# Add here commands to install the package into debian/freeside.
-	$(MAKE) install DESTDIR=$(CURDIR)/debian/freeside
+	# Add here commands to install package into
+	# debian/<package>-whatever.
+	( cd FS/ && $(MAKE) -e DESTDIR=$(TMP)-lib install )
 
-	dh_movefiles
+	#install this for postinst later (no create-config)
+	install -d $(DEFAULT_CONF)
+	#install conf/[a-z]* $(DEFAULT_CONF)
+	#CVS is not [a-z]
+	install `ls -d conf/[a-z]* | grep -v CVS` $(DEFAULT_CONF)
 
-# Build architecture-independent files here.
-# Pass -i to all debhelper commands in this target to reduce clutter.
-binary-indep: build install
-	dh_testdir -i
-	dh_testroot -i
-#	dh_installdebconf -i
-	dh_installdocs -i
-	dh_installexamples -i
-	dh_installmenu -i
-#	dh_installlogrotate -i
-#	dh_installemacsen -i
-#	dh_installpam -i
-#	dh_installmime -i
-#	dh_installinit -i
-	dh_installcron -i
-#	dh_installman -i
-	dh_installinfo -i
-#	dh_undocumented -i
-	dh_installchangelogs  -i
-	dh_link -i
-	dh_compress -i
-	dh_fixperms -i
-	dh_installdeb -i
-#	dh_perl -i
-	dh_gencontrol -i
-	dh_md5sums -i
-	dh_builddeb -i
+	install -d $(FREESIDE_DOCUMENT_ROOT)
+	install -d $(FREESIDE_CACHE)/masondata #MASONDATA
+	$(MAKE) -e install-docs
 
-# Build architecture-dependent files here.
-binary-arch: build install
-	dh_testdir -a
-	dh_testroot -a
-#	dh_installdebconf -a
-	dh_installdocs -a
-	dh_installexamples -a
-	dh_installmenu -a
-#	dh_installlogrotate -a
-#	dh_installemacsen -a
-#	dh_installpam -a
-#	dh_installmime -a
-#	dh_installinit -a
-	dh_installcron -a
-#	dh_installman -a
-	dh_installinfo -a
-#	dh_undocumented -a
-	dh_installchangelogs  -a
-	dh_strip -a
-	dh_link -a
-	dh_compress -a
-	dh_fixperms -a
-#	dh_makeshlibs -a
-	dh_installdeb -a
-#	dh_perl -a
-	dh_shlibdeps -a
-	dh_gencontrol -a
-	dh_md5sums -a
-	dh_builddeb -a
+	#hack the build dir out of Freeside too.  oh yeah, sucky.
+	perl -p -i -e "\
+	  s'${TMP}(-webui)?''g;\
+	" ${TMP}-webui/usr/share/freeside/handler.pl \
+	  ${TMP}/usr/share/perl5/FS/* \
+	  ${TMP}/usr/share/perl5/FS/*/* \
+	  ${TMP}/usr/bin/*
+
+	rm -r $(FREESIDE_DOCUMENT_ROOT).*
+
+	install -d $(APACHE_CONF)
+	install debian/freeside.apache-alias.conf $(APACHE_CONF)/freeside-alias.conf
+	FREESIDE_DOCUMENT_ROOT=/usr/share/freeside/www MASON_HANDLER=/usr/share/freeside/handler.pl FREESIDE_CONF=/etc/freeside $(MAKE) -e install-apache
+
+	$(MAKE) -e install-init
+
+	#RT
+	#(configure-rt)
+
+	# XXX need to adjust db-type, db-database, db-rt-user, db-rt-pass
+	# based on info from dbc
+	( cd rt; \
+	  cp config.layout.in config.layout; \
+	  perl -p -i -e "\
+	    s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g;\
+	    s'%%%MASONDATA%%%'${FREESIDE_CACHE}/masondata'g;\
+	  " config.layout; \
+	  ./configure --prefix=${RT_PATH} \
+	              --enable-layout=Freeside \
+	              --with-db-type=Pg \
+	              --with-db-dba=freeside \
+	              --with-db-database=_DBC_DBNAME_ \
+	              --with-db-rt-user=_DBC_DBUSER_ \
+	              --with-db-rt-pass=_DBC_DBPASS_ \
+	              --with-web-user=freeside \
+	              --with-web-group=freeside \
+	              --with-rt-group=freeside \
+	)
+
+	#(create-rt)
+	install -d $(RT_PATH)
+	( cd rt; make install )
+	#hack the build dir out of RT.  yeah, sucky.
+	perl -p -i -e "\
+	  s'${TMP}''g;\
+	" ${RT_PATH}/etc/RT_Config.pm \
+	  ${RT_PATH}/lib/RT.pm \
+	  ${RT_PATH}/bin/mason_handler.fcgi \
+	  ${RT_PATH}/bin/mason_handler.scgi \
+	  ${RT_PATH}/bin/standalone_httpd \
+	  ${RT_PATH}/bin/webmux.pl \
+	  ${RT_PATH}/bin/rt-crontool \
+	  ${RT_PATH}/sbin/rt-dump-database \
+	  ${RT_PATH}/sbin/rt-setup-database
+	
+	#hack @INC dir out of RT (well, handler.pl) too.
+	perl -p -i -e "\
+	  s'/opt/rt3/'/var/opt/freeside/rt/'g;\
+	" ${TMP}-webui/usr/share/freeside/handler.pl
+
+	mv ${RT_PATH}/etc/RT_Config.pm ${RT_PATH}/etc/RT_Config.pm.dbc
+
+	perl -p -i -e "\
+	  s'%%%RT_DOMAIN%%%'${RT_DOMAIN}'g;\
+	  s'%%%RT_TIMEZONE%%%'${RT_TIMEZONE}'g;\
+	  s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
+	" ${RT_PATH}/etc/RT_SiteConfig.pm
+
+	install -D debian/dbconfig-common.install $(DBC_SCRIPTS)/install/pgsql
+	install -D debian/dbconfig-common.install $(DBC_SCRIPTS)/install/mysql
+	
+	install -D debian/dbconfig-common.upgrade $(DBC_SCRIPTS)/upgrade/pgsql/$(DEBVERSION)
+	install -D debian/dbconfig-common.upgrade $(DBC_SCRIPTS)/upgrade/mysql/$(DEBVERSION)
+	
+	dh_install
+
+	touch $@
+
+binary-arch:
+# We have nothing to do here for an architecture-independent package
+
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs ChangeLog
+	dh_installdocs #freeside.docs README AGPL
+	dh_installexamples eg/*
+#	dh_installmenu
+	dh_installdebconf	
+#	dh_installlogrotate	
+	dh_installinit
+	dh_installcron
+#	dh_installinfo
+	dh_installman
+	dh_perl
+	dh_link
+	dh_compress 
+	dh_fixperms
+	dh_installdeb
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
 
 binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+.PHONY: build clean binary-indep binary-arch binary install

--- docs DELETED ---

--- NEW FILE: freeside.default ---
# Defaults for freeside initscript
# sourced by /etc/init.d/freeside
# installed at /etc/default/freeside by the maintainer scripts

#
# This is a POSIX shell fragment
#

# Additional options that are passed to the Freeside startup scripts.
SELFSERVICE_MACHINES=""

#start freeside-sqlradius-radacctd from here too, etc.

--- NEW FILE: freeside.docs ---
README

--- NEW FILE: postrm ---
#!/bin/sh
# postrm script for freeside
#
# see: dh_installdeb(1)

set -e

# source debconf stuff
. /usr/share/debconf/confmodule

# source dbconfig-common stuff
if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
  . /usr/share/dbconfig-common/dpkg/postrm 
  dbc_go freeside $@
fi

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package


case "$1" in
    purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0



--- NEW FILE: cron.d ---
#
# Regular cron jobs for the freeside package
#
0 0	* * *	freeside	/usr/bin/freeside-daily fs_daily

--- NEW FILE: TODO ---

test) freeside-webui /etc/apache/conf.d/freeside.conf
  AuthUserFile is wrong (just fucked)

test its working) somes sort of Alias /freeside /usr/share/freeside/www is needed

test in postinst) freeside package var/cache/freeside/cache.<datasrc is missing>

test RT is missing.  doh.  get it working.

test actually installing!

--- rc2... right? ---

freeside-selfservice-client doesn't install at all

start freeside-sqlradius-radacctd from /etc/default/freeside too

Added to README.Debian... do something else?
Ensure apache is set to run as User freeside.

init script doesn't need to add /usr/local/bin.  could start over from 
init.d.ex or init.d.lsb.ex

finish 

RT install locations (or for now: disable for unstable, enable for
experiemental.  but try to get it finished off in time for lenny)

debian/copyright administrivia

AGPL drama

upload

AGPL drama or silent waiting for days or years

profit!  err

--- watch.ex DELETED ---

--- preinst.ex DELETED ---

Index: changelog
===================================================================
RCS file: /home/cvs/cvsroot/freeside/debian/changelog,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -d -r1.2 -r1.2.6.1
--- changelog	1 Apr 2003 01:22:24 -0000	1.2
+++ changelog	8 Apr 2008 05:49:19 -0000	1.2.6.1
@@ -1,9 +1,6 @@
-freeside (1.4.1-1) unstable; urgency=low
+freeside (1.7.3~rc2-1) unstable; urgency=low
 
-  * Initial Release.
+  * Initial release
 
- -- Ivan Kohler <ivan-debian at 420.am>  Thu, 12 Apr 2001 15:49:17 -0700
+ -- Ivan Kohler <ivan-debian at 420.am>  Wed, 02 Apr 2008 01:46:20 -0700
 
-Local variables:
-mode: debian-changelog
-End:

Index: init.d.ex
===================================================================
RCS file: /home/cvs/cvsroot/freeside/debian/init.d.ex,v
retrieving revision 1.1
retrieving revision 1.1.14.1
diff -u -d -r1.1 -r1.1.14.1
--- init.d.ex	5 Jun 2001 21:40:55 -0000	1.1
+++ init.d.ex	8 Apr 2008 05:49:21 -0000	1.1.14.1
@@ -4,35 +4,106 @@
 #		This file should be used to construct scripts for /etc/init.d.
 #
 #		Written by Miquel van Smoorenburg <miquels at cistron.nl>.
-#		Modified for Debian GNU/Linux
+#		Modified for Debian 
 #		by Ian Murdock <imurdock at gnu.ai.mit.edu>.
+#               Further changes by Javier Fernandez-Sanguino <jfs at debian.org>
 #
-# Version:	@(#)skeleton  1.8  03-Mar-1998  miquels at cistron.nl
+# Version:	@(#)skeleton  1.9  26-Feb-2001  miquels at cistron.nl
 #
-# This file was automatically customized by dh-make on Thu, 12 Apr 2001 15:49:17 -0700
 
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/sbin/freeside
 NAME=freeside
 DESC=freeside
 
-test -f $DAEMON || exit 0
+test -x $DAEMON || exit 0
+
+LOGDIR=/var/log/freeside
+PIDFILE=/var/run/$NAME.pid
+DODTIME=1                   # Time to wait for the server to die, in seconds
+                            # If this value is set too low you might not
+                            # let some servers to die gracefully and
+                            # 'restart' will not work
+
+# Include freeside defaults if available
+if [ -f /etc/default/freeside ] ; then
+	. /etc/default/freeside
+fi
 
 set -e
 
+running_pid()
+{
+    # Check if a given process pid's cmdline matches a given name
+    pid=$1
+    name=$2
+    [ -z "$pid" ] && return 1 
+    [ ! -d /proc/$pid ] &&  return 1
+    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
+    # Is this the expected child?
+    [ "$cmd" != "$name" ] &&  return 1
+    return 0
+}
+
+running()
+{
+# Check if the process is running looking at /proc
+# (works for all users)
+
+    # No pidfile, probably no daemon present
+    [ ! -f "$PIDFILE" ] && return 1
+    # Obtain the pid and check it against the binary name
+    pid=`cat $PIDFILE`
+    running_pid $pid $NAME || return 1
+    return 0
+}
+
+force_stop() {
+# Forcefully kill the process
+    [ ! -f "$PIDFILE" ] && return
+    if running ; then
+        kill -15 $pid
+        # Is it really dead?
+        [ -n "$DODTIME" ] && sleep "$DODTIME"s
+        if running ; then
+            kill -9 $pid
+            [ -n "$DODTIME" ] && sleep "$DODTIME"s
+            if running ; then
+                echo "Cannot kill $LABEL (pid=$pid)!"
+                exit 1
+            fi
+        fi
+    fi
+    rm -f $PIDFILE
+    return 0
+}
+
 case "$1" in
   start)
 	echo -n "Starting $DESC: "
-	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
-		--exec $DAEMON
-	echo "$NAME."
+	start-stop-daemon --start --quiet --pidfile $PIDFILE \
+		--exec $DAEMON -- $DAEMON_OPTS
+        if running then
+            echo "$NAME."
+        else
+            echo " ERROR."
+        fi
 	;;
   stop)
 	echo -n "Stopping $DESC: "
-	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
+	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
 		--exec $DAEMON
 	echo "$NAME."
 	;;
+  force-stop)
+	echo -n "Forcefully stopping $DESC: "
+        force_stop
+        if ! running then
+            echo "$NAME."
+        else
+            echo " ERROR."
+        fi
+	;;
   #reload)
 	#
 	#	If the daemon can reload its config files on the fly
@@ -45,24 +116,40 @@
 	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
 	#	/var/run/$NAME.pid --exec $DAEMON
   #;;
-  restart|force-reload)
+  force-reload)
 	#
 	#	If the "reload" option is implemented, move the "force-reload"
 	#	option to the "reload" entry above. If not, "force-reload" is
-	#	just the same as "restart".
-	#
-	echo -n "Restarting $DESC: "
+	#	just the same as "restart" except that it does nothing if the
+	#   daemon isn't already running.
+	# check wether $DAEMON is running. If so, restart
+	start-stop-daemon --stop --test --quiet --pidfile \
+		/var/run/$NAME.pid --exec $DAEMON \
+	&& $0 restart \
+	|| exit 0
+	;;
+  restart)
+    echo -n "Restarting $DESC: "
 	start-stop-daemon --stop --quiet --pidfile \
 		/var/run/$NAME.pid --exec $DAEMON
-	sleep 1
+	[ -n "$DODTIME" ] && sleep $DODTIME
 	start-stop-daemon --start --quiet --pidfile \
-		/var/run/$NAME.pid --exec $DAEMON
+		/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
 	echo "$NAME."
 	;;
+  status)
+    echo -n "$LABEL is "
+    if running ;  then
+        echo "running"
+    else
+        echo " not running."
+        exit 1
+    fi
+    ;;
   *)
 	N=/etc/init.d/$NAME
 	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
-	echo "Usage: $N {start|stop|restart|force-reload}" >&2
+	echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
 	exit 1
 	;;
 esac

--- manpage.sgml.ex DELETED ---

--- NEW FILE: init.d.lsb.ex ---
#!/bin/sh 
#
# Example init.d script with LSB support.
#
# Please read this init.d carefully and modify the sections to
# adjust it to the program you want to run.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs at debian.org>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.
#
# This is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License with
# the Debian operating system, in /usr/share/common-licenses/GPL;  if
# not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
#
### BEGIN INIT INFO
# Provides:          freeside
# Required-Start:    $network $local_fs
# Required-Stop:     
# Should-Start:      $named
# Should-Stop:       
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: <Enter a short description of the sortware>
# Description:       <Enter a long description of the software>
#                    <...>
#                    <...>
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/sbin/freeside # Introduce the server's location here
NAME=#PACKAGE              # Introduce the short server's name here
DESC=#PACKAGE              # Introduce a short description here
LOGDIR=/var/log/freeside  # Log directory to use

PIDFILE=/var/run/$NAME.pid 

test -x $DAEMON || exit 0
test -x $DAEMON_WRAPPER || exit 0

. /lib/lsb/init-functions

# Default options, these can be overriden by the information
# at /etc/default/$NAME
DAEMON_OPTS=""          # Additional options given to the server 

DODTIME=10              # Time to wait for the server to die, in seconds
                        # If this value is set too low you might not
                        # let some servers to die gracefully and
                        # 'restart' will not work
                        
LOGFILE=$LOGDIR/$NAME.log  # Server logfile
#DAEMONUSER=freeside   # Users to run the daemons as. If this value
                        # is set start-stop-daemon will chuid the server

# Include defaults if available
if [ -f /etc/default/$NAME ] ; then
	. /etc/default/$NAME
fi

# Use this if you want the user to explicitly set 'RUN' in 
# /etc/default/
#if [ "x$RUN" != "xyes" ] ; then
#    log_failure_msg "$NAME disabled, please adjust the configuration to your needs "
#    log_failure_msg "and then set RUN to 'yes' in /etc/default/$NAME to enable it."
#    exit 1
#fi

# Check that the user exists (if we set a user)
# Does the user exist?
if [ -n "$DAEMONUSER" ] ; then
    if getent passwd | grep -q "^$DAEMONUSER:"; then
        # Obtain the uid and gid
        DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
        DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
    else
        log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
        exit 1
    fi
fi


set -e

running_pid() {
# Check if a given process pid's cmdline matches a given name
    pid=$1
    name=$2
    [ -z "$pid" ] && return 1 
    [ ! -d /proc/$pid ] &&  return 1
    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
    # Is this the expected server
    [ "$cmd" != "$name" ] &&  return 1
    return 0
}

running() {
# Check if the process is running looking at /proc
# (works for all users)

    # No pidfile, probably no daemon present
    [ ! -f "$PIDFILE" ] && return 1
    pid=`cat $PIDFILE`
    running_pid $pid $DAEMON_WRAPPER || return 1
    return 0
}

start_server() {
# Start the process using the wrapper
        if [ -z "$DAEMONUSER" ] ; then
            start-stop-daemon --start --quiet --pidfile $PIDFILE \
                        --exec $DAEMON -- $DAEMON_OPTS
            errcode=$?
        else
# if we are using a daemonuser then change the user id
            start-stop-daemon --start --quiet --pidfile $PIDFILE \
                        --chuid $DAEMONUSER \
                        --exec $DAEMON -- $DAEMON_OPTS
            errcode=$?
        fi
	return $errcode
}

stop_server() {
# Stop the process using the wrapper
        if [ -z "$DAEMONUSER" ] ; then
            start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                        --exec $DAEMON
            errcode=$
        else
# if we are using a daemonuser then look for process that match
            start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                        --user $DAEMONUSER \
                        --exec $DAEMON
            errcode=$
        fi

	return $errcode
}

reload_server() {
    [ ! -f "$PIDFILE" ] && return 1
    pid=`cat $PIDFILE` # This is the daemon's pid
    # Send a SIGHUP
    kill -1 $pid
    return $?
}

force_stop() {
# Force the process to die killing it manually
	[ ! -e "$PIDFILE" ] && return
	if running ; then
		kill -15 $pid
	# Is it really dead?
		sleep "$DIETIME"s
		if running ; then
			kill -9 $pid
			sleep "$DIETIME"s
			if running ; then
				echo "Cannot kill $NAME (pid=$pid)!"
				exit 1
			fi
		fi
	fi
	rm -f $PIDFILE
}


case "$1" in
  start)
	log_daemon_msg "Starting $DESC " "$NAME"
        # Check if it's running first
        if running ;  then
            log_progress_msg "apparently already running"
            log_end_msg 0
            exit 0
        fi
        if start_server && running ;  then
            # It's ok, the server started and is running
            log_end_msg 0
        else
            # Either we could not start it or it is not running
            # after we did
            # NOTE: Some servers might die some time after they start,
            # this code does not try to detect this and might give
            # a false positive (use 'status' for that)
            log_end_msg 1
        fi
	;;
  stop)
        log_daemon_msg "Stopping $DESC" "$NAME"
        if running ; then
            # Only stop the server if we see it running
            stop_server
            log_end_msg $?
        else
            # If it's not running don't do anything
            log_progress_msg "apparently not running"
            log_end_msg 0
            exit 0
        fi
        ;;
  force-stop)
        # First try to stop gracefully the program
        $0 stop
        if running; then
            # If it's still running try to kill it more forcefully
            log_daemon_msg "Stopping (force) $DESC" "$NAME"
            force_stop
            log_end_msg $?
        fi
	;;
  restart|force-reload)
        log_daemon_msg "Restarting $DESC" "$NAME"
        stop_server
        # Wait some sensible amount, some server need this
        [ -n "$DIETIME" ] && sleep $DIETIME
        start_server
        running
        log_end_msg $?
	;;
  status)

        log_daemon_msg "Checking status of $DESC" "$NAME"
        if running ;  then
            log_progress_msg "running"
            log_end_msg 0
        else
            log_progress_msg "apparently not running"
            log_end_msg 1
            exit 1
        fi
        ;;
  # Use this if the daemon cannot reload
  reload)
        log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
        log_warning_msg "cannot re-read the config file (use restart)."
        ;;
  # And this if it cann
  #reload)
          #
          # If the daemon can reload its config files on the fly
          # for example by sending it SIGHUP, do it here.
          #
          # If the daemon responds to changes in its config file
          # directly anyway, make this a do-nothing entry.
          #
          # log_daemon_msg "Reloading $DESC configuration files" "$NAME"
          # if running ; then
          #    reload_server
          #    if ! running ;  then
          # Process died after we tried to reload
          #       log_progress_msg "died on reload"
          #       log_end_msg 1
          #       exit 1
          #    fi
          # else
          #    log_progress_msg "server is not running"
          #    log_end_msg 1
          #    exit 1
          # fi
                                                                                    #;;

  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0

--- cron.d.ex DELETED ---

--- ex.doc-base.package DELETED ---

--- NEW FILE: postinst ---
#!/bin/sh
# postinst script for freeside
#
# see: dh_installdeb(1)

set -e

# source debconf stuff
. /usr/share/debconf/confmodule

# source dbconfig-common stuff
. /usr/share/dbconfig-common/dpkg/postinst 

dbc_pgsql_createdb_encoding='sql_ascii'

#echo "i should create the db here"
dbc_go freeside $@
#echo "db should be craeted now"

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

case "$1" in
    configure)

    a2enmod perl

    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0




More information about the freeside-commits mailing list