This is a personal post which I never normally place on my tech blog, but I’m excited and hoping a few of you out there may support me through an online donation.

Follow this journey on our Facebook blog!

I’m partaking in the Mongol Rally 2016 where we will be driving our Black Beauty (pictured) over 10,000 miles (16,000 kms) through Countries, Cities and Sea. Lets trek over mountains, explore deserts and meet and greet all the people in between!

Our Black Beauty for the Mongol Rally 2016

Our Black Beauty for the Mongol Rally 2016

Wait… Where are you driving???

From England to Mongolia – so much scenery to see. Read more about the Mongol Rally here: http://www.theadventurists.com/mongol-rally/

Some of the countries we may be driving through:

  • United Kingdom
  • Belgium
  • Germany
  • Czech Republic
  • Austria
  • Slovakia
  • Hungary
  • Romania
  • Ukraine
  • Bulgaria
  • Turkey
  • Georgia
  • Azerbaijan
  • Iran
  • Turkmenistan
  • Uzbekistan
  • Kazakhstan
  • Russia
  • Mongolia
The start and finish points, with approx 6 weeks of driving and camping in between!

The start and finish points, with approx 6 weeks of driving and camping in between!

But that’s crazy! Why would you do such a thing???

The Leukaemia Foundationis the only national not-for-profit organisation dedicated to the care and cure of patients and families living with leukaemia, lymphoma, myeloma and related blood disorders.

The Leukaemia Foundationis the only national not-for-profit organisation dedicated to the care and cure of patients and families living with leukaemia, lymphoma, myeloma and related blood disorders.


It’s all for charity! So please support us in raising money for these two incredible charities:

The Leukaemia Foundation

The Leukaemia Foundation is an Australian nonprofit organisation caring for and curing patients afflicted with leukaemia, lymphoma, myeloma and related blood disorders.

Cool Earth

Cool Earth is the charity that works alongside indigenous villages to halt rainforest destruction.

Cool Earth is the charity that works alongside indigenous villages to halt rainforest destruction.

Cool Earth saves at-risk rainforest and shields millions of acres of neighbouring forest. We put local people back in control, giving them the resources they need to keep their forest intact.

Please make a donation! We need to raise £1000!

AU$ here: http://www.gofundme.com/mongolrally2016
GP£ here: http://www.gofundme.com/mongolrally16

Most important we would like to thank the Mongol Rally for this exciting and crazy adventure, without you this would not be possible.

Follow this journey on our Facebook blog!

I ran into a situation where I wanted to run a custom bash on first launch of a VM built from template.  I wanted this script to be able to ask for certain variables from the user in order to configure the systems DNS, NTP, Red Hat Satellite activation key, IP address and hostname.

In order for the script to run on boot, I added the script location into rc.local

When booting however, keyboard response was poor and there was no response/echo of the typed characters from the read (even though -s wasn’t specified).

Found this problem to be with plymouth running during boot startup for GIU fluidity.

Simply adding “plymouth quit” in my script solved this issue.  Below is a sample of the script for clarity:

#!/bin/bash
# are we a template?
if [[ -f "/etc/rhev_template" ]]
then
  echo "[*] I am a template, not performing customisation"
  exit 9
fi
#enable read through rc.local by disabling plymouth
plymouth quit

# network config
  NET_CORRECT="n"
  while [[ "$NET_CORRECT" != "y" ]]
  do
    read -p "[*] hostname: " HOST_NAME
    read -p "[*] ip address: " NET_IP
    read -p "[*] subnet mask: " NET_MASK
    read -p "[*] gateway: " NET_GW

    echo
    echo "    --------------------"
    echo "    hostname: $HOST_NAME"
    echo "    ip address: $NET_IP"
    echo "    subnet mask: $NET_MASK"
    echo "    gateway: $NET_GW"
    echo "    --------------------"
    echo -n "[*] Are these network settings correct (y to proceed) ? "
    read NET_CORRECT
  done
[script cut off]


Firefox has implemented a more secure method when encompassing unsigned SSL certificates.  This may be a pain at first glance, however adding more steps in order to bypass invalid SSL certificates surely is a good thing.

The message you may receive is:

This Connection is Untrusted

You have asked Firefox to connect securely to srv-qs-revm.lands.nsw, but we can't confirm that your connection is secure.

Normally, when you try to connect securely, sites will present trusted identification to prove that you are going to the right place. However, this site's identity can't be verified.
What Should I Do?

If you usually connect to this site without problems, this error could mean that someone is trying to impersonate the site, and you shouldn't continue.

srv-qs-revm.lands.nsw uses an invalid security certificate. The certificate is not trusted because the issuer certificate is not trusted. (Error code: sec_error_untrusted_issuer)

 

To resolve this issue, in the Tools menu select select Options

02_tools_menu_and_options_firefox

Select the Advanced tab then the Certificates tab and click on the View Certificates button:

 

03_advanced_certificates_view_certificates_firefox

Select the Servers tab and click the Add Exception button:

 

04_servers_add_exception_firefox

Finally, enter in the URL and click the Get Certificate button, followed by Confirm Security Exception button.  Then OK out and refresh the page.

05_enter_server_hostname_get_certificate_confirm_security_exception_firefox

As I have multiple websites which I like to utilise AWStats for (there are still benefits to server based logging over Google Analytics, however I like to use them together) I scp all of the Apache/httpd log files onto my awstats server. Below is a little PHP page which parses the AWStats config directory to generate an index page to make it easier to identify and navigate to each statistics page.

<!DOCTYPE html>
<html>
<head><title>AWStats listing</title>

<style type="text/css">
        body {
                font: 14px verdana, arial, helvetica, sans-serif;
                background-color: #eee;
                margin-top: 0;
                margin-bottom: 0;
        }
        a { font: 14px verdana, arial, helvetica, sans-serif; }
        a:link    { color: #0011BB; text-decoration: none; }
        a:visited { color: #0011BB; text-decoration: none; }
        a:hover   { color: #605040; text-decoration: underline; }
        #container {
                background-color: #fff;
                text-align: center;
                position:absolute;
                width:400px;
                z-index:15;
                top:40%;
                left:50%;
                margin:-100px 0 0 -200px;
                border: 2px solid #CCD;
        }
        ul {
                text-align: left;
        }
</style>
</head>
<body>
        <div id="container">
                <p><img src="/awstatsicons/other/awstats_logo6.png" border="0" width="90px" /></p>
                <p>Available AWStats for websites on this server:</p>
                <ul>
<?php

# Page by Sam Osborne
# 28-04-14
$directory = '/etc/awstats/';
$scanned_directory = array_diff(scandir($directory), array('..', '.', 'awstats.localhost.localdomain.conf', 'awstats.model.conf')); #array of files to exclude
foreach($scanned_directory as $file){
        if(substr($file, -4) != ".bak"){ #don't list .bak files
                $fileshort = substr(substr($file, 8), 0, -5);#Remove the awstats. (8 chars) from the front and .conf (5) from the end of the string
                echo '                  <li><a href="/awstats/awstats.pl?config='.$fileshort.'">'.$fileshort.'</a></li>'."\n";
        }
}
?>
                </ul>
        </div>
</body>
</html>

You may need to adjust the A HREF URL if you installation is different.

In a logrotate conf there are the options of prerotate and postrotate where you can place scripts to be run.  The only issue is in most logrotate confs it applies to multiple files and therefore the prerotate and postroate scripts are run multiple times (for each occurrence of each file to be rotated).

I had the situation where I wanted the prerotate to scp apache/httpd access logs to a central AWStats server prior to rotating, and I only wanted the scp to occur once.  The only method I identified to work was to create a kind of pid file, or temp file, and check for its existence.  Below is the code incase anybody else requires a similar solution:

vim /etc/logrotate.d/apache

#-------------------------------------------------
# Log rotation for /usr/local/apache
#-------------------------------------------------
/usr/local/apache/logs/*log {
      daily
      rotate 10
      missingok
      compress
      notifempty
      prerotate
            #Unfortunately prerotate script is run on each occurrence which meets the above *log
            #search therefore in order to not have the files scp'd multiple times I have to 
            #create a temp file for today and check for its existence
            today=$(date +"%y-%m-%d")
            filename="/usr/local/apache/logs/logrotate$today"
            if [ ! -f "$filename" ]; then
                  #This should only be run once as the file is created later
                  scp /usr/local/apache/logs/*access_log awstats1:/usr/local/awstats/importLogs/$HOSTNAME/.
                  #Remove yesterdays temp file
                  rm -f /usr/local/apache/logs/logrotate*
                  #Create todays temp file to fail this if clause on subsequent iterations
                  touch $filename
            fi
      endscript
      postrotate
            /usr/local/apache/bin/apachectl graceful
      endscript
}