ProFTPD manifest xml for opensolaris
In order to start/stop/refresh proftpd using SMF method, you need two files, the manifest xml file and the start/stop/refresh proftpd script.
First, the xml file:
Copy this file in /var/svc/manifest/network/proftpd.xml
To import this file type as root:
svccfg import /var/svc/manifest/network/proftpd.xml
Second file, the proftpd start up script:
#!/sbin/sh
#
#proftpd start up script
# ident "%Z%%M% %I% %E% SMI"
. /lib/svc/share/smf_include.sh
PROFTPDIR=/usr/proftpd-1.3.2/
PROFTPCONF=/usr/proftpd-1.3.2/etc/proftpd.conf
PIDFILE=/usr/proftpd-1.3.2/var/proftpd.pid
if [ ! -d $PROFTPDIR ]; then
echo "Error: proftpd dir not found"
exit $SMF_EXIT_ERR_CONFIG
fi
if [ ! -f $PROFTPCONF ]; then
echo "Error: proftpd conf file not found"
exit $SMF_EXIT_ERR_CONFIG
fi
# This script is being used for two purposes: as part of an SMF
# start/stop/refresh method, and as a sysidconfig(1M)/sys-unconfig(1M)
# application.
#
# Both, the SMF methods and sysidconfig/sys-unconfig use different
# arguments..
case $1 in
'start')
$PROFTPDIR/sbin/proftpd -c $PROFTPCONF 2> /dev/null
;;
'stop')
if [ -f "$PIDFILE" ]; then
kill -9 `/usr/bin/cat $PIDFILE`
rm -f $PIDFILE 2>/dev/null
else
pkill proftpd 2>/dev/null
rm -f $PIDFILE 2>/dev/null
fi
;;
'restart')
if [ -f "$PIDFILE" ]; then
/usr/bin/kill -HUP `/usr/bin/cat $PIDFILE`
fi
;;
*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac
exit $?
Copy this file in /lib/svc/method/
In order to start up the proftpd server (read more about how to compile proftpd on opensolari here) type:
svcadm enable proftpd-server
To check if the proftpd server is running type:
svcs -p proftpd-server
The output will something like that
root@opensolaris:/var/lib# svcs -p proftpd-server
STATE STIME FMRI
online 12:07:06 svc:/network/proftpd-server:default
11:56:03 276 proftpd
To stop the proftpd server type:
svcadm disable proftpd-server
Same for refresh/restart method
svcadm refresh proftpd-server
The script and the xml file are self explained, and if you installed the proftpd in a different path, do not forget to change the PROFTPDIR, PROFTPCONF and PIDFILE variables from proftpd script acording to your proftpd prefix.
Troubleshooting Tips
If you have problems with the proftpd manifest check the /var/svc/log/network-proftpd-server\:default.log file.
To see if the proftpd is running:
svcs -xv proftpd-server
The output is something like this:
svc:/network/proftpd-server:default (PROFTPD server)
State: online since Wed Mar 18 12:35:33 2009
See: man -M /usr/proftpd-1.3.2/share/man -s 1M in.proftpd
See: /var/svc/log/network-proftpd-server:default.log
Impact: None.
First, the xml file:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="proftpd-server">
<service
name="network/proftpd-server"
type="service"
version="1">
<create_default_instance enabled="false">
<single_instance>
<dependency name='net-loopback'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value="'svc:/network/loopback'">
</dependency>
<dependency name='net-physical'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value="'svc:/network/physical'">
</dependency>
<exec_method
type="method"
name="start"
exec="/lib/svc/method/proftpd start"
timeout_seconds="60">
</exec_method>
<exec_method
type="method" name="stop"
exec="/lib/svc/method/proftpd stop"
timeout_seconds="60">
</exec_method>
<exec_method
type="method"
name="refresh"
exec="/lib/svc/method/proftpd restart"
timeout_seconds="60">
</exec_method>
<stability value="Unstable">
<template>
<common_name>
<loctext lang="C">
PROFTPD server
</loctext>
</common_name>
<documentation>
<manpage title='in.proftpd'
section='1M'
manpath='/usr/proftpd-1.3.2/share/man' />
</documentation>
</template>
</service>
</service_bundle>
Copy this file in /var/svc/manifest/network/proftpd.xml
To import this file type as root:
svccfg import /var/svc/manifest/network/proftpd.xml
Second file, the proftpd start up script:
#!/sbin/sh
#
#proftpd start up script
# ident "%Z%%M% %I% %E% SMI"
. /lib/svc/share/smf_include.sh
PROFTPDIR=/usr/proftpd-1.3.2/
PROFTPCONF=/usr/proftpd-1.3.2/etc/proftpd.conf
PIDFILE=/usr/proftpd-1.3.2/var/proftpd.pid
if [ ! -d $PROFTPDIR ]; then
echo "Error: proftpd dir not found"
exit $SMF_EXIT_ERR_CONFIG
fi
if [ ! -f $PROFTPCONF ]; then
echo "Error: proftpd conf file not found"
exit $SMF_EXIT_ERR_CONFIG
fi
# This script is being used for two purposes: as part of an SMF
# start/stop/refresh method, and as a sysidconfig(1M)/sys-unconfig(1M)
# application.
#
# Both, the SMF methods and sysidconfig/sys-unconfig use different
# arguments..
case $1 in
'start')
$PROFTPDIR/sbin/proftpd -c $PROFTPCONF 2> /dev/null
;;
'stop')
if [ -f "$PIDFILE" ]; then
kill -9 `/usr/bin/cat $PIDFILE`
rm -f $PIDFILE 2>/dev/null
else
pkill proftpd 2>/dev/null
rm -f $PIDFILE 2>/dev/null
fi
;;
'restart')
if [ -f "$PIDFILE" ]; then
/usr/bin/kill -HUP `/usr/bin/cat $PIDFILE`
fi
;;
*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac
exit $?
Copy this file in /lib/svc/method/
In order to start up the proftpd server (read more about how to compile proftpd on opensolari here) type:
svcadm enable proftpd-server
To check if the proftpd server is running type:
svcs -p proftpd-server
The output will something like that
root@opensolaris:/var/lib# svcs -p proftpd-server
STATE STIME FMRI
online 12:07:06 svc:/network/proftpd-server:default
11:56:03 276 proftpd
To stop the proftpd server type:
svcadm disable proftpd-server
Same for refresh/restart method
svcadm refresh proftpd-server
The script and the xml file are self explained, and if you installed the proftpd in a different path, do not forget to change the PROFTPDIR, PROFTPCONF and PIDFILE variables from proftpd script acording to your proftpd prefix.
Troubleshooting Tips
If you have problems with the proftpd manifest check the /var/svc/log/network-proftpd-server\:default.log file.
To see if the proftpd is running:
svcs -xv proftpd-server
The output is something like this:
svc:/network/proftpd-server:default (PROFTPD server)
State: online since Wed Mar 18 12:35:33 2009
See: man -M /usr/proftpd-1.3.2/share/man -s 1M in.proftpd
See: /var/svc/log/network-proftpd-server:default.log
Impact: None.
Comments