Mini Shell

Direktori : /proc/self/root/opt/tier1adv/bin/
Upload File :
Current File : //proc/self/root/opt/tier1adv/bin/dcv

#!/bin/bash
# dcv v1.0
# A script used to add domain control validation text file to user account
# Written by Shawn C.

REQARGS=3

# Usage
function print_usage {

        echo
        echo "  Usage: dcv <domain> <md5> <sha1>"
        echo
        exit

}

function check_sanity {

        echo

# Is "www" included in the domain?
        if echo $DOMAIN | grep "^www." &> /dev/null; then
                echo -n "Found leading 'www.' in domain, stripping... "
                DOM=$(echo $DOMAIN | sed "s/www\.//g")
                DOMAIN=$DOM && echo "success."
        fi

# Does the domain exist on the server?

        echo -n "Searching for domain on server... "

        if ! sudo grep "^$DOMAIN:" /etc/userdatadomains &> /dev/null; then
                echo "failure."
                echo
                exit
        else
                echo "success."
                echo -n "Searching for document root... "
                OWNER=$(sudo cat /etc/userdatadomains | grep ^$DOMAIN: | awk '{print $2}' | awk -F"==" '{print $1}')
                DOCROOT=$(sudo cat /etc/userdatadomains | grep ^$DOMAIN: | awk -F"==" '{print $5}')
                TXT=$(echo "$DOCROOT/$MD5.txt")
                URL=$(echo "http://$DOMAIN/$MD5.txt")

                if [[ $DOCROOT != "" ]]; then
                        echo "success."
                else
                        echo "failure."
                        exit
                fi

                echo
                echo "Owner: $OWNER"
                echo "Docroot: $DOCROOT"
                echo "Domain: $DOMAIN"
                echo "MD5: $MD5"
                echo "SHA-1: $SHA1"
                echo "File: $TXT"
                echo "URL: $URL"
                echo
        fi

}

function add_dcv {

        /opt/tier1adv/bin/switch $OWNER <<-DCV
                echo
                echo -n "Adding $TXT... "
                echo -e "$SHA1\ncomodoca.com" > $TXT && echo "success." || echo "failure."
DCV

        echo -n "Checking if DCV is web accessible... "
        curl -sA '"Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0"' $URL | grep "$SHA1\|comodoca.com" &> /dev/null && echo "success." || echo "failure."
        echo
        echo "Operation completed."
        echo
        exit
}

if [[ $# -eq $REQARGS ]]; then
        DOMAIN=$1
        MD5=$2
        SHA1=$3
        check_sanity
        add_dcv
else
        print_usage
fi

Zerion Mini Shell 1.0