0

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"
2

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

2
  • crond starts after httpd in Fedora. 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.
    – user9517
    Apr 5 '11 at 11:55
2

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.

2
  • 2
    Except that you need not jump through such hoops in Fedora; a single chkconfig command will disable it. Apr 5 '11 at 11:42
  • Ah yes, good point. Apr 5 '11 at 11:54
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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