#!/bin/bash

# Common functions for registration scripts
LOCK_LOCATION=/var/lib/eucalyptus/registration.lock

# Logging
function reglog {
    if [ -d /var/log/eucalyptus ]; then
        echo "$(date --rfc-3339=seconds) | $$ -> $1" >> /var/log/eucalyptus/registration.log
    fi
}

# Parameter sanitizing functions
function testip {
    if [ -n "${1//[0-9.]/}" ]; then
       reglog "Input parameter is not an IP address."
       exit 2
    fi
}

# Startup
reglog "Calling $(basename $0) $1 $2"

# Test lock
if [ -f "${LOCK_LOCATION}" ]; then
    reglog "Registration locked by ${LOCK_LOCATION}"
    exit 0
fi
