Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to download a file from an external location eg http://s3.amazonaws.com/my-bucket/config.xml and then save that file to /etc/config.xml when the server starts.

What is the best way to do this in fedora?

I assume I need some boot script as this need to be done every restart/start.

Just to clarify, the process will be:

  • Server boots up
  • Server downloads file from the location
  • Server runs command "serivce httpd start"
share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

you can use cron's @reboot directive to run a script every time your system starts up. edit /etc/crontab

@reboot root cd /to/where/xml/file/lives && /usr/bin/wget -q http://s3.amazonaws.com/my-bucket/config.xml && /sbin/service http start

As per IgnacioVazquez-Abrams comment you will need to disable httpd at startup using the chkconfig command e.g.

chkconfig httpd off

share|improve this answer
    
crond starts after httpd in Fedora. –  Ignacio Vazquez-Abrams Apr 5 '11 at 11:53
    
@IgnacioVazquez-Abrams: this does what the OP asked for. I kind of assumed that the OP had used chkconfig to disable httpd at startup. –  Iain Apr 5 '11 at 11:55
add comment

Write an initscript that runs in between network/NetworkManager and httpd. See /usr/share/doc/initscripts-*/sysvinitfiles for more details.

share|improve this answer
add comment

You can just put the commands into /etc/rc.local. This script is ran at the end of the boot process, so your network interfaces and settings will have been initiated. You may have to disable the existing httpd startup script (which is probably in /etc/init.d), by making it non executable:

sudo chmod -x httpd

Or simply by moving it to another location.

More information on the boot sequence can be found at: https://wiki.archlinux.org/index.php/Arch_Boot_Process

It may not be specific to your distro, but the process is usually pretty similar on any modern distro.

share|improve this answer
2  
Except that you need not jump through such hoops in Fedora; a single chkconfig command will disable it. –  Ignacio Vazquez-Abrams Apr 5 '11 at 11:42
    
Ah yes, good point. –  James Little Apr 5 '11 at 11:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.