source code of /thinkpad/index.cgi.src-old

Last modified
Lines 66

Parent directory Download CGIread sitemap Main page

Quick links: content itsup

  1. #!/bin/sh
  2. echo 'Content-Type: text/html; charset=UTF-8'
  3. echo
  4. # stat -c %Y IP
  5. # date +%s
  6. cat <<_END1_
  7. __HTML5__
  8.         <meta name="robots" content="follow, noindex"/>
  9.         __TITLE__
  10.         <style>
  11.             #itsup
  12.             {
  13.                 color: #000000;
  14.                 background-color: #22ee22;
  15.                 font-size: 125%;
  16.                 padding: 3em;
  17.             }
  18.         </style>
  19.     </head>
  20.     <body>
  21. __NAVIGATION__
  22.         <main><div id="content">
  23.             __H1__
  24.             <p>
  25.                 It's not always up or the IP address might be different,
  26.                 so I'll (automatically) link to the right place below.
  27.                 It's supposed to be on <a target="_blank" rel="noopener"
  28.                 href="http://thinkpad.oskog97.com/">thinkpad.oskog97.com</a>
  29.                 but... :-/
  30.             </p>
  31. _END1_
  32. stale_time=$(($(date +%s) - $(stat -c %Y IP)))
  33. if [ $stale_time -lt 600 ]; then
  34.     IP=$(cat IP)
  35.     A=$(host thinkpad.oskog97.com | cut -d' ' -f4)
  36.     if [ "$A" = "$IP" ]; then
  37.         DNS_status="The thinkpad subdomain's A-record matches the IP address"
  38.         link="http://thinkpad.oskog97.com/"
  39.     else
  40.         DNS_status="<strong>The thinkpad subdomain needs to be updated!</strong>"
  41.         link="http://$IP/"
  42.     fi
  43.     cat <<_END2_
  44.             <div id="itsup">
  45.                 <h2>It's up!</h2>
  46.                 <p>IP: ${IP}</p>
  47.                 <p>${DNS_status}</p>
  48.                 <p><a href="$link" target="_blank" rel="noopener">Visit its website</a></p>
  49.             </div>
  50. _END2_
  51. else
  52.     link="https://web.archive.org/web/http://thinkpad.oskog97.com/"
  53.     echo "            <p><a href='$link' rel='noopener' target='_blank'>Visit its website on archive.org</a></p>"
  54. fi
  55. cat <<_END3_
  56.         </div></main>
  57. __FOOTER__
  58.     </body>
  59. </html>
  60. _END3_