Hi, How do I correct the BASEDIR value, so that it is not //etc/postfix/distconf rather /etc/postfix/distconf???
Because of: #!/bin/sh BASEDIR=/ cp -p \$BASEDIR/etc/postfix/distconf/post-install \$BASEDIR/etc/postfix, the output become: //etc/postfix/distconf/: does not exist I am using makePostfixPkg.sh from ihsan.dogan.ch to package Postfix. After I ran the script, the output is: Do you want to continue with the installation of <CNDpostfix> [y,n,?] y http://www.postfix.org/ packaged by Ihsan Dogan Using as the package base directory. ## Processing package information. ## Processing system information. 5 package pathnames are already properly installed. ## Verifying package dependencies. ## Verifying disk space requirements. ## Checking for conflicts with packages already installed. ## Checking for setuid/setgid programs. This package contains scripts which will be executed with super-user permission during the process of installing this package. Do you want to continue with the installation of <CNDpostfix> [y,n,?] y Installing Postfix MTA as <CNDpostfix> ## Executing preinstall script. ## Installing part 1 of 1. [ verifying class <none> ] ## Executing postinstall script. /var/sadm/pkg/CNDpostfix/install/postinstall: //etc/postfix/distconf/: does not exist pkgadd: ERROR: postinstall script did not complete successfully Installation of <CNDpostfix> failed. Regards, Terence P.S. Enclosed please find the script: #!/bin/sh ########################################################################### # # Execute this script in the top-level Postfix source directory. # This script has been tested with Postfix version 2.5.6 # # This script was originally written by Victor Didovicher and kept updated by # Ihsan Dogan. # # Script version 0.3.2 # (c) Victor Didovicher <vkd79 at yahoo.com> # (c) Mark Phillips - 360is.com # (c) CND AG, Switzerland, http://www.cnd-ag.ch/ # (c) Ihsan Dogan <ihsan at dogan.ch> # ########################################################################### # # ChangeLog: # * 22.04.2009 v0.3.2 (Ihsan Dogan) # - fixed chroot execution in postinstall and preinstall scripts # (Bug report from Niklas Edmundsson) # - Set permission for all directories in /var/spool/postfix # - Added script version to pkginfo. # # * 19.04.2009 v0.3.1 (Ihsan Dogan) # - fixed several directory permissions (prototype) # - setting uid and gid for the postfix user and postdrop group to 26 # - fixed postinstall script (check if group exists) # - commands in preinstall, postinstall and preremove are executed now in # a chroot. (Bug report from Niklas Edmundsson) # # * 11.09.2008 v0.3.1pre (Ihsan Dogan) # - fixed permission for /var/lib (prototype) # # * 18.07.2008 v0.3.1pre (Ihsan Dogan) # - postinstall creates now a /etc/mail/aliases file if it doesn't exist # - postinstall executes now newaliases # # * 02.01.2008 v0.3 (Ihsan Dogan) # - Added a preremove script to unregister the Postfix SMF manifest during # the package uninstallation # - Postfix is disabled in the preremove script before the uninstallation # - removed all SysV init stuff # - postinstall script is now quiet (no message about checking permissions) # - we verify now if $src_dir/$packageName exists, before executing rm # - added a message how to start Postfix with SMF to the postinstall script # - Changed directions to fit in one line # # * 28.12.2007 v0.3pre (Ihsan Dogan) # - Changed paths in the smf manifest from /opt/csw to /usr # - Changed smf_dir to /var/svc/manifest # - added variable smf_category and set it to 'network' # # * 26.11.2007 v0.3pre (Mark Phillips) # - Solaris 10 only version - SMF manifest added # - postconf -dh instead of sed business # - added OS version to $pkgFileName # # * 22.10.2007 v0.2.4 (Ihsan Dogan) # - Fixed VERSION in pkginfo # # * 08.05.2007 v0.2.3 (Ihsan Dogan) # - Postinstall is now copying post* files allways to /etc/postfix # - Fixed the SUNWman hack: removed entry for the mailq manpage in # postfix-files # # * 07.05.2007 v0.2.2 (Ihsan Dogan) # - Changed manpage directory to /usr/share/man # - Added a revision number to pkginfo and to the filename # # * 06.05.2007 v0.2.1 (Ihsan Dogan) # - Tested with Postfix 2.4.1 # - The required postfix user and postdrop group are now added by the # postinstall script # - Fixed init script # - Added HOTLINE and VENDOR to the pkginfo # - Added the architecture to the package filename # - Added package incompatibility to SUNWsndmr and SUNWsndmu # # * 10.04.2007 v0.2 (Ihsan Dogan) # - Added dependencies for SUNW and CSW packages # - config files are not anymore part of the package and are copied by # the postinstall script # # * 28.02.2007 v0.1.7 (Ihsan Dogan) # - Made it work with Postfix 2.3.x # - changed PATH variable to use /opt/csw instead of /usr/local # # * 28/02/2002 v0.1.6 # - Fixed permissions for some of the /usr/* dirs # ########################################################################### # # Please contact me at ihsan at dogan.ch for bug reports and questions. # ########################################################################### # ------------------------------------------------------------------------ # User Configurable Area # ------------------------------------------------------------------------ # if possible, please don't change this values mail_owner=postfix setgid_group=postdrop # ------------------------------------------------------------------------ # No editing should be needed below this line # ------------------------------------------------------------------------ scriptversion=0.3.2 PATH=/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/csw/bin:/opt/csw/sbin ########################################################################### # Create Build directory and package directory ########################################################################### echo " ----------------- PREPARING TEMP FILES ----------------- " packageName=CNDpostfix pkgVersion=`./bin/postconf -dh mail_version` pkgRevision=`date '+%yy%mm%dd' | sed s/y// | sed s/m// | sed s/d//` pkgFileName=$packageName-$pkgVersion\,REV\=$pkgRevision-`uname -s``uname -r`-`uname -p` src_dir=`/bin/pwd` bld_dir=$src_dir/$packageName/build pkg_dir=$src_dir/$packageName/package distconf_dir=$src_dir/$packageName/build/etc/postfix/distconf conf_dir=$src_dir/$packageName/build/etc/postfix smf_dir=$bld_dir/var/svc/manifest smf_category=network if [ -d $src_dir/$packageName ]; then rm -rf $src_dir/$packageName fi mkdir -p $bld_dir $pkg_dir $smf_dir/$smf_category ########################################################################### # Copy Postfix Files ########################################################################### make non-interactive-package install_root=$bld_dir manpage_directory=/usr/share/man # ------------------------------------------------------------------------- # dirty hack to fix a conflict with SUNWman # ------------------------------------------------------------------------- rm $bld_dir/usr/share/man/man1/mailq.1 grep -v '$manpage_directory/man1/mailq.1:f:root:-:644' $bld_dir/etc/postfix/postfix-files > /tmp/postfix-files.tmp mv /tmp/postfix-files.tmp $bld_dir/etc/postfix/postfix-files # ------------------------------------------------------------------------- # move config files to etc/postfix/distconf and install them with the # postinstall script to avoid that the files will be overwritten during an # upgrade # ------------------------------------------------------------------------- mkdir $distconf_dir mv `find $conf_dir -type f` $distconf_dir ########################################################################### # Create smf manifest ########################################################################### cat > $smf_dir/$smf_category/postfix.xml << __EOF__ <?xml version="1.0"?> <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> <!-- PostFix Manifest for TSISpostfix: Mark Phillips - 360is.com --> <!-- Based on original by Ben Rockwood - cuddletech.com --> <service_bundle type='manifest' name='postfix'> <service name='network/postfix' type='service' version='1'> <create_default_instance enabled='false'/> <single_instance/> <dependency name='config-file' grouping='require_all' restart_on='none' type='path'> <service_fmri value='file:///etc/postfix/main.cf'/> </dependency> <dependency name='loopback' grouping='require_all' restart_on='error' type='service'> <service_fmri value='svc:/network/loopback:default'/> </dependency> <dependency name='physical' grouping='require_all' restart_on='error' type='service'> <service_fmri value='svc:/network/physical:default'/> </dependency> <dependency name='fs-local' grouping='require_all' restart_on='none' type='service'> <service_fmri value='svc:/system/filesystem/local'/> </dependency> <exec_method type='method' name='start' exec='/usr/sbin/postfix start' timeout_seconds='60' /> <exec_method type='method' name='stop' exec='/usr/sbin/postfix stop' timeout_seconds='60' /> <exec_method type='method' name='refresh' exec='/usr/sbin/postfix reload' timeout_seconds='60' /> <stability value='Unstable' /> <template> <common_name> <loctext xml:lang='C'>Postfix SMTP Server</loctext> </common_name> <documentation> <manpage title='postfix' section='1' /> <doc_link name='postfix.org' uri='http://www.postfix.org/documentation.html' /> </documentation> </template> </service> </service_bundle> __EOF__ ########################################################################### # Strip Binary executable files (little addition from Viktor Duchovni) # GNU strip seemed to do freaky things. I force to SUN's strip here. ########################################################################### find $bld_dir -type f | xargs file | awk -F: '/not stripped/{print $1}' | xargs /usr/ccs/bin/strip ########################################################################### ############## CREATING SOLARIS PACKAGE FROM BUILD DIRECTORY ############## ########################################################################### echo " ------------------- BUILDING PACKAGE ------------------- " # ------------------------------------------------------------------------- # Create package prototype file # ------------------------------------------------------------------------- ( cd $bld_dir # Get rid of first / since pkgproto does not show it cmd_dir=`echo $command_directory | sed -e 's;^/;;'` #que_dir=`echo $queue_directory | sed -e 's;^/;;'` find . ! -name prototype | sort | pkgproto | nawk ' { $5="root"; $6="other"; } $3 ~ /^usr$/ { $6="sys"; } $3 ~ /^usr\/bin/ { $6="bin"; } $3 ~ /^usr\/lib/ { $6="bin"; } $3 ~ /^usr\/sbin/ { $6="bin"; } $3 ~ /^usr\/share/ { $6="sys"; } $3 ~ /^usr\/share\/man/ { $6="bin"; } $3 ~ /^etc/ { $6="sys"; } $3 ~ /^var/ { $6="sys"; } $3 ~ /^var\/lib/ { $6="other"; } $3 ~ /^var\/lib\/postfix/ { $5="postfix"; $6="other"; } $3 ~ /^var\/spool\/postfix\/active/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/bounce/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/corrupt/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/defer/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/deferred/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/flush/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/hold/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/incoming/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/private/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/saved/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/trace/ { $5="postfix"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/pid/ { $5="root"; $6="sys"; } $3 ~ /^var\/spool\/postfix\/maildrop/ { $5="postfix"; $6="postdrop"; } $3 ~ /^var\/spool\/postfix\/postdrop/ { $5="postfix"; $6="postdrop"; } $3 ~ /^var\/spool\/postfix\/public/ { $5="postfix"; $6="postdrop"; } $3 == "var/spool" { $6="bin"; } $3 == "opt" { $4="0775"; $6="sys"; } # Set proper group for command executables # Postinstall should correct these but # forcing group ownership here is just a safeguard $3 ~ "'"$cmd_dir"'/postdrop$" { $4="2755"; $6=PGROUP; } $3 ~ "'"$cmd_dir"'/postqueue$" { $4="2755"; $6=PGROUP; } { print; } END { print "i pkginfo=info"; print "i postinstall=postinstall"; print "i preinstall=preinstall"; print "i preremove=preremove"; print "i depend=depend"; } ' POWNER=$mail_owner PGROUP=$setgid_group > prototype ) # ------------------------------------------------------------------------- # Create package info file # ------------------------------------------------------------------------- cat > $bld_dir/info << __EOF__ PKG=$packageName NAME=Postfix MTA CATEGORY=application CLASSES=none ARCH=`uname -p` VERSION=$pkgVersion,REV=$pkgRevision-$scriptversion PSTAMP=`./bin/postconf -d | grep mail_release_date | sed -e 's/[a-zA-Z_]* = \([0-9.]*\)/postfix\1/g'` BASEDIR=/ VENDOR=http://www.postfix.org/ packaged by Ihsan Dogan HOTLINE=ihsan at dogan.ch __EOF__ # ------------------------------------------------------------------------- # Create depend file # ------------------------------------------------------------------------- cat > $bld_dir/depend << __EOF__ P SUNWcsl P SUNWcslr P SUNWlibmsr P SUNWopenssl-libraries P SUNWlibsasl P SUNWpr P SUNWtls I SUNWsndmr I SUNWsndmu __EOF__ # ------------------------------------------------------------------------- # Create preinstall script to create users # ------------------------------------------------------------------------- cat > $bld_dir/preinstall << __EOF__ #!/bin/sh # check, if the postdrop group does exist grep '^postdrop:' \$PKG_ROOT_DIR/etc/group >/dev/null if [ \$? -ne 0 ] ; then \/usr/sbin/chroot \/ /usr/bin/getent group $setgid_group >/dev/null if [ \$? -ne 0 ] ; then NEEDGROUP=1 fi fi # check, if the postfix user does exist grep '^$mail_owner:' \$PKG_ROOT_DIR/etc/passwd >/dev/null if [ \$? -ne 0 ] ; then \/usr/sbin/chroot \/ /usr/bin/getent passwd $mail_owner >/dev/null if [ \$? -ne 0 ] ; then NEEDUSER=1 fi fi # create the postdrop group, if NEEDGROUP=1 if [ "\$NEEDGROUP" = 1 ] ; then echo Adding required $setgid_group group \/usr/sbin/chroot \/ /usr/sbin/groupadd -g 26 $setgid_group fi # create the postfix user, if NEEDUSER=1 if [ "\$NEEDUSER" = 1 ] ; then echo Adding required $mail_owner user # create the $mail_owner user \/usr/sbin/chroot \/ /usr/sbin/useradd -u 26 -d / -c 'Postfix pseudo-user' -s /bin/false $mail_owner fi __EOF__ # ------------------------------------------------------------------------- # Create postinstall script to fix permissions / check queue dir, # copy config files and register the SMF manifest # ------------------------------------------------------------------------- cat > $bld_dir/postinstall << __EOF__ #!/bin/sh cd \/etc/postfix/distconf/ for i in * ; do if [ ! -f \/etc/postfix/\$i ]; then cp -p \$i \/etc/postfix fi done cp -p \/etc/postfix/distconf/post-install \/etc/postfix cp -p \/etc/postfix/distconf/postfix-files \/etc/postfix cp -p \/etc/postfix/distconf/postfix-script \/etc/postfix \/usr/sbin/chroot \/ /usr/sbin/postfix set-permissions upgrade-configuration \ setgid_group=$setgid_group mail_owner=$mail_owner \/usr/sbin/chroot \/ /usr/sbin/svccfg import /var/svc/manifest/network/postfix.xml if [ ! -f \/etc/mail/aliases ]; then cat > \/etc/mail/aliases << _EOF_ postmaster: root MAILER-DAEMON: postmaster bin: root daemon: root system: root toor: root uucp: root manager: root dumper: root operator: root decode: root nobody: /dev/null _EOF_ fi \/usr/sbin/chroot \/ /usr/bin/newaliases echo echo To start Postfix, execute \'svcadm enable svc:/network/postfix:default\' __EOF__ # ------------------------------------------------------------------------- # Create preremove script to unregister the SMF manifest # ------------------------------------------------------------------------- cat > $bld_dir/preremove << __EOF__ #!/bin/sh \/usr/sbin/chroot \/ /usr/sbin/svcadm disable svc:/network/postfix:default \/usr/sbin/chroot \/ /usr/sbin/svccfg delete svc:/network/postfix:default __EOF__ # ------------------------------------------------------------------------- # Create the package stream # ------------------------------------------------------------------------- pkgmk -d $pkg_dir -f $bld_dir/prototype -r $bld_dir -o echo | pkgtrans -os $pkg_dir $src_dir/$pkgFileName.pkg >/dev/null 2>&1 ########################################################################### ######################### DONE: Show Directions ########################### ########################################################################### echo echo ".:: makePostfixPkg.sh Version $scriptversion ::." echo echo "+-----------------------------------------------------------------------" echo "| Package File: $pkgFileName.pkg" echo "| To Install: pkgadd -d $pkgFileName.pkg" echo "+-----------------------------------------------------------------------" echo echo "(c) Ihsan Dogan <ihsan at dogan.ch>" echo "(c) CND AG, Switzerland, http://www.cnd-ag.ch/" echo "(c) Victor Didovicher <vkd79 at yahoo.com> (initial script)" echo "(c) Mark Phillips - 360is.com (SMF integration)" echo ########################################################################### # Clean up used tmp dirs ########################################################################### /bin/rm -rf $src_dir/$packageName exit 0 -- This message posted from opensolaris.org