After I wrote the script to put up a maintenance page for my websites, I came up with two more things to display on the page:
- Timestamp for start of maintenance
- Reason for maintenance
In this post:
- FreeBSD 15.0
The new script
The new script is invoked like this:
[14:11 r720-02-proxy01 dvl ~] % ~/bin/offline dev.freshports.org "$(date -R -v +2H)" "Offline for database update"
<html>
<head>
<title>Error 503 Service Unavailable</title>
<style>
<style>
body { text-align: center; padding: 20px; font: 25px Helvetica, sans-serif; color: #efe8e8; background-color:#2e2929}
@media (min-width: 768px){
body{ padding-top: 150px; }
}
h1 { font-size: 50px; }
h2 { font-size: 35px; }
h3 { font-size: 28px; }
article { display: block; text-align: left; max-width: 650px; margin: 0 auto; }
td { font-size: 25px; line-height: 1.5; margin: 20px 0; }
</style>
</style>
</head>
<body>
<h1>Server is offline for maintenance</h1>
<h2>503 Service Unavailable</h2>
<h3>Offline for database update</h3>
<table>
<tr>
<td>Started at:</td><td>Wed, 18 Mar 2026 14:12:28 +0000</td>
</tr>
<tr>
<td>Please retry after:</td><td> Wed, 18 Mar 2026 16:12:28 +0000</td>
</tr>
</table>
</body>
</html>
overwrite /usr/local/www/offline/dev.freshports.org-maintenance.html? (y/n [n])
The original script is in my previous post. The new script is here:
[14:11 r720-02-proxy01 dvl ~] % cat ~/bin/offline
#!/bin/sh
# Usage: ~/bin/offline foo.bar "$(date -R -v +2H)"
# see -v option on man date: [y|m|w|d|H|M|S]
website=$1
retryafter=$2
reason=$3
OFFLINE_DIR="/usr/local/www/offline"
# slight santization
hostname=$(basename $website)
start=$(date -R)
tmpfile=$(mktemp /tmp/offline.XXXXXX)
cat << EOF >> $tmpfile
<html>
<head>
<title>Error 503 Service Unavailable</title>
<style>
<style>
body { text-align: center; padding: 20px; font: 25px Helvetica, sans-serif; color: #efe8e8; background-color:#2e2929}
@media (min-width: 768px){
body{ padding-top: 150px; }
}
h1 { font-size: 50px; }
h2 { font-size: 35px; }
h3 { font-size: 28px; }
article { display: block; text-align: left; max-width: 650px; margin: 0 auto; }
td { font-size: 25px; line-height: 1.5; margin: 20px 0; }
</style>
</style>
</head>
<body>
<h1>Server is offline for maintenance</h1>
<h2>503 Service Unavailable</h2>
<h3>${reason}</h3>
<table>
<tr>
<td>Started at:</td><td>${start}</td>
</tr>
<tr>
<td>Please retry after:</td><td> ${retryafter}</td>
</tr>
</table>
</body>
</html>
EOF
cat $tmpfile
sudo chown root:wheel $tmpfile
sudo chmod 0644 $tmpfile
sudo mv -i $tmpfile "${OFFLINE_DIR}/${hostname}-maintenance.html"
# We remove the tmpfile file if we answer NO to the overwrite of the mv
sudo rm -f $tmpfile
The results
The resulting webpage looks something like this (what you see in between the horizontal lines):
Server is offline for maintenance
503 Service Unavailable
Offline for database update
| Started at: | Wed, 18 Mar 2026 14:12:28 +0000 |
| Please retry after: | Wed, 18 Mar 2026 16:12:28 +0000 |
Hope that helps.











