Thanks redhead. I run multiple websites on my server and I was thinking of a universal maintenance page for all the virtual hosts.
This is what I have done so far:
1) I created a /etc/httpd/conf.d/websites.conf file with the following config:
2) I then created the following directories:
The "open" directory contains all my virtualhost files. The "closed" directory contains only one file (closed.conf) looking like this:
3) Next I created a symbolic link /etc/httpd/conf.d/websites.d/active which can point to either the "closed" or "open" directory. here's how the directory listing of websites.d looks:
ErrorDocument 404 /
4) For the next step I created a web-store-front.sh script that flips between the "open" and "closed" directories depending on whether I use "open" or "closed" as my first argument. It also restarts apache to activate the change.
[root@web-001 bin]# ll /etc/httpd/conf.d/websites.d/
lrwxrwxrwx 1 root root 33 Nov 11 08:56 active -> /etc/httpd/conf.d/websites.d/open
drwxr-xr-x 2 root root 4096 Nov 10 09:25 closed
drwxr-xr-x 2 root root 4096 Nov 11 15:02 open
The index.html file in the /home/www/default/closed directory has the maintenance message.
# Remove symbolic link
if [ -d /etc/httpd/conf.d/websites.d/active ]; then
rm -f /etc/httpd/conf.d/websites.d/active
# Restore symbolic link
if [ $1 = "closed" ]; then
ln -s /etc/httpd/conf.d/websites.d/closed /etc/httpd/conf.d/websites.d/active
ln -s /etc/httpd/conf.d/websites.d/open /etc/httpd/conf.d/websites.d/active
# Restart Apache only if Apache is already running
if [ -f "$LOCK_FILE" ]; then
/sbin/service httpd restart
5) A brief version of my backup script then looks like this:
I'm now working on expanding the backup script to read the username, password and any directories I may want backed up from a configuration file and then tar the DB backups and files all together in one big tar ball.
mysql-daily-backup.sh mysql-username mysql-password
When I get that far, I'll post the code. It's turning into a nice little project.