If you have configuration files that you want to modify at boot time with environment variables or other RightScript Inputs, you can use the following methods:
Both methods allow you to dynamically change the configuration file with a RightScript Input variable.
The following examples use an ftpd configuration file. You can use any text configuration file because the principles are identical. If you have a configuration file /etc/xinetd.d/gssftp, the contents are:
service ftp
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/ftpd
server_args = -l -a
log_on_failure += USERID
disable = no
}
If you want to change the server_args to a script Input called FTP_SERVER_ARGS, you can modify them at boot time without having to edit the RightScript manually.
Use the following in your RightScript. It outputs the entire config file to /etc/xinetd.d/gssftp and substitues the FTP_SERVER_ARGS variable which is provided at runtime. You can see the configuration file is embedded in the script between the two EOF tags.
cat > /etc/xinetd.d/gssftp << EOF
service ftp
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/ftpd
server_args = $FTP_SERVER_ARGS
log_on_failure += USERID
disable = no
}
EOF
To attach a configuration file to a RightScript, you must edit the config file gssftp by putting in an easily recognized unique string, as in the following example:
service ftp
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/kerberos/sbin/ftpd
server_args = SERVER_ARGS_PROVIDED_BY_RIGHTSCRIPT
log_on_failure += USERID
disable = no
}
You would then add the config file gssftp to the script as an attachment using the attachments.
The one line installation script would look like this:
sed -e "s/SERVER_ARGS_PROVIDED_BY_RIGHTSCRIPT/$FTP_SERVER_ARGS/g" $ATTACH_DIR/gssftp > /etc/xinetd.d/gssftp
Enabling the script to find the string:
SERVER_ARGS_PROVIDED_BY_RIGHTSCRIPT and replace it with $FTP_SERVER_ARGS which are provided as RightScript Input variables in the attached file and installs it in /etc/xinetd.d where it belongs.
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.