[systemd-devel] Using Multiple EnvironmentFile lines

Steve Dickson SteveD at redhat.com
Tue Aug 2 05:36:49 PDT 2011


Hello,

I noticed that the ypbind.service used multiple
EnvironmentFile lines so thought this would be a 
good way to build command lines to daemons on the fly... 

So the nfs-server.service looks like:

[Unit]
Description=NFS Protocol Daemon
After=network.target rpcbind.service
ConditionPathIsDirectory=/sys/module/sunrpc

[Service]
EnvironmentFile=-/etc/sysconfig/nfs
EnvironmentFile=/usr/lib/nfs-utils/scripts/nfs-server.preconfig
ExecStartPre=-/usr/sbin/rpc.rquotad $RPCRQUOTADOPTS
ExecStartPre=/usr/sbin/exportfs -r
ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS ${RPCNFSDCOUNT}
ExecStartPost=/usr/sbin/rpc.mountd $RPCMOUNTDOPTS
ExecStartPost=-/usr/lib/nfs-utils/scripts/nfs-server.postconfig
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target


The /etc/sysconf/nfs like what is installed today.

The nfs-server.preconfig looks like:

#
# Set up arguments to rpc.mountd
#
# Define the port rpc.mountd listens on if requested
[ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"

case "$MOUNTD_NFS_V2" in
no|NO)
    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 2" ;;
esac 

case "$MOUNTD_NFS_V3" in
no|NO)
    RPCMOUNTDOPTS="$RPCMOUNTDOPTS --no-nfs-version 3" ;;
esac 

#
# Set up arguments to rpc.nfsd
#
# Define the number of nfsd processes to be started by default
[ -z "$RPCNFSDCOUNT" ] && RPCNFSDCOUNT=8

# Set v4 grace period if requested
[ -n "$NFSD_V4_GRACE" ] && {
    echo "$NFSD_V4_GRACE" > /proc/fs/nfsd/nfsv4gracetime
}

Now it appears the variables being set in nfs-server.preconfig
(the second EnvironmentFile line) are not be carried over 
into the .service file. 

For example if RPCNFSDCOUNT is not set in /etc/sysconfg/nfs 
(the first EnvironmentFile line) and is set in the second 
EnvironmentFile, ${RPCNFSDCOUNT} does not have a value when 
rpc.nfsd is started in the service file. Note setting the variable 
in the first EnvironmentFile always works. 

Can one have multiple Environment Files to set multiple
env variables?  

Is this the correct way to build command lines for daemon on the fly?

tia,

steved. 
 


More information about the systemd-devel mailing list