wok-6.x rev 12043

dovecot: Add initscript. Improve receipt
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Wed Mar 07 17:24:26 2012 +0100 (2012-03-07)
parents c4e464160942
children 3d13d460f4df
files dovecot/receipt dovecot/stuff/init.d/dovecot
line diff
     1.1 --- a/dovecot/receipt	Wed Mar 07 17:41:19 2012 +0100
     1.2 +++ b/dovecot/receipt	Wed Mar 07 17:24:26 2012 +0100
     1.3 @@ -35,13 +35,63 @@
     1.4  # Rules to gen a SliTaz package suitable for Tazpkg.
     1.5  genpkg_rules()
     1.6  {
     1.7 -	mkdir -p $fs/usr/lib
     1.8 +	mkdir -p $fs/usr/lib \
     1.9 +		$fs/var/log/dovecot \
    1.10 +		$fs/var/run/dovecot 
    1.11 +
    1.12  	
    1.13  	cp -a $install/usr/sbin $fs/usr
    1.14  	cp -a $install/usr/lib $fs/usr
    1.15  	cp -a $install/etc $fs/
    1.16  	
    1.17 +	cp -pa $stuff/init.d $fs/etc
    1.18 +
    1.19 +	cp -pa $fs/etc/dovecot/dovecot-example.conf $fs/etc/dovecot/dovecot.conf
    1.20 +	
    1.21  	# Remove archive file *.*a
    1.22  	find $fs -name "*.*a" -exec rm -f {} \;
    1.23  	
    1.24  }
    1.25 +
    1.26 +#nd post install commands for Tazpkg.
    1.27 +post_install()
    1.28 +{
    1.29 +	local user
    1.30 +	local group
    1.31 +	
    1.32 +	user=dovecot
    1.33 +	group=dovecot
    1.34 +	
    1.35 +	if ! grep -q $user $1/etc/passwd; then
    1.36 +		echo -n "Adding user/group $user..."
    1.37 +		chroot $1/ addgroup -S $group
    1.38 +		chroot $1/ adduser -S -D -H -G $group $user
    1.39 +		status
    1.40 +	fi
    1.41 +	
    1.42 +
    1.43 +	# Set perms for files and directories
    1.44 +	chroot $1/ chown -R ${user}.${group} /var/log/${user} \
    1.45 +		/var/run/${user} 
    1.46 +
    1.47 +	cat <<EOF
    1.48 +----
    1.49 +To start $PACKAGE server you can run :
    1.50 +
    1.51 +    /etc/init.d/$PACKAGE start
    1.52 +
    1.53 +Or add $PACKAGE to RUN_DAEMONS in /etc/rcS.conf
    1.54 +----
    1.55 +EOF
    1.56 +}
    1.57 +
    1.58 +
    1.59 +post_remove()
    1.60 +{
    1.61 +	echo "Removing stalled files..."
    1.62 +	test -d /var/log/dovecot && rm -rf /var/log/dovecot
    1.63 +	test -d /var/run/dovecot && rm -rf /var/run/dovecot
    1.64 +	
    1.65 +	echo "Removing user/group daemon"
    1.66 +	deluser dovecot 
    1.67 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/dovecot/stuff/init.d/dovecot	Wed Mar 07 17:24:26 2012 +0100
     2.3 @@ -0,0 +1,55 @@
     2.4 +#!/bin/sh
     2.5 +# /etc/init.d/dovecot : Start, stop and restart Dovecotserver on SliTaz, at 
     2.6 +# boot time or with the command line.
     2.7 +#
     2.8 +# To start SSH server at boot time, just put dovecot in the $RUN_DAEMONS
     2.9 +# variable of /etc/rcS.conf and configure options with /etc/daemons.conf
    2.10 +#
    2.11 +. /etc/init.d/rc.functions
    2.12 +. /etc/daemons.conf
    2.13 +
    2.14 +NAME=dovecot
    2.15 +DESC="Dovecot daemon"
    2.16 +DAEMON=/usr/sbin/dovecot
    2.17 +OPTIONS=$dovecot_OPTIONS
    2.18 +PIDFILE=/var/run/dovecot/dovecot.pid
    2.19 +
    2.20 +case "$1" in
    2.21 +  start)
    2.22 +    if active_pidfile $PIDFILE dovecot ; then
    2.23 +      echo "$NAME already running."
    2.24 +      exit 1
    2.25 +    fi
    2.26 +    echo -n "Starting $DESC: $NAME... "
    2.27 +    $DAEMON $OPTIONS
    2.28 +    status
    2.29 +    ;;
    2.30 +  stop)
    2.31 +    if ! active_pidfile $PIDFILE dovecot ; then
    2.32 +      echo "$NAME is not running."
    2.33 +      exit 1
    2.34 +    fi
    2.35 +    echo -n "Stopping $DESC: $NAME... "
    2.36 +    kill `cat $PIDFILE`
    2.37 +    status
    2.38 +    ;;
    2.39 +  restart)
    2.40 +    if ! active_pidfile $PIDFILE dovecot ; then
    2.41 +      echo "$NAME is not running."
    2.42 +      exit 1
    2.43 +    fi
    2.44 +    echo -n "Restarting $DESC: $NAME... "
    2.45 +    kill `cat $PIDFILE`
    2.46 +    sleep 2
    2.47 +    $DAEMON $OPTIONS
    2.48 +    status
    2.49 +    ;;
    2.50 +  *)
    2.51 +    echo ""
    2.52 +    echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
    2.53 +    echo ""
    2.54 +    exit 1
    2.55 +    ;;
    2.56 +esac
    2.57 +
    2.58 +exit 0