#!/bin/bash add_entry () { curl 'http://localhost:8090/Blacklist_p.html' --compressed -H 'Content-Type: multipart/form-data; boundary=---------------------------70675837311993919383702838946' --data-binary $'-----------------------------70675837311993919383702838946\r\nContent-Disposition: form-data; name="currentBlacklist"\r\n\r\nurl.default.black\r\n-----------------------------70675837311993919383702838946\r\nContent-Disposition: form-data; name="newEntry"\r\n\r\n'$1$'\r\n-----------------------------70675837311993919383702838946\r\nContent-Disposition: form-data; name="addBlacklistEntry"\r\n\r\nAdd URL pattern\r\n-----------------------------70675837311993919383702838946--\r\n' >/dev/null 2>&1 if [ "$?" == 0 ]; then echo 'I| added to blacklist: '$1 else echo 'E| CURL failed on adding entry to blacklist' exit 3 fi } add_entry_domainonly () { add_entry $1'/.*' } add_entry_domainandsub () { add_entry $1'/.*' add_entry '*.'$1'/.*' } if [[ $1 == '' ]]; then echo 'E| you must specify the domain to add' exit 1 fi if [[ $2 == 0 ]]; then add_entry_domainonly $1 elif [[ $2 == 1 ]]; then add_entry_domainandsub $1 else echo 'E| second parameter must be one of [ 0 | 1 ]' exit 2 fi