Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > FAQs > How do I update a configuration file with a RightScript Input?

How do I update a configuration file with a RightScript Input?

Background Information

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: 

  1. Embed the configuration file in the script itself
  2. Attach the configuration file to the script
     

Both methods allow you to dynamically change the configuration file with a RightScript Input variable.


Answer

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.

Embedding a configuration file into a RightScript

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

 

Attaching a configuration file to a RightScript

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.

Viewing 1 of 1 comments: view all
Edited
Posted 15:22, 25 Oct 2013
Viewing 1 of 1 comments: view all
You must to post a comment.
Last modified
15:22, 25 Oct 2013

Tags

Classifications

This page has no classifications.

Announcements

None


© 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.