Minor tweaks.
parent
5dc35ec7ad
commit
be93b490e0
|
|
@ -73,7 +73,10 @@ function cont() {
|
|||
read -n 1 YN
|
||||
YN=${YN:-N}
|
||||
case $YN in
|
||||
[Yy]) return 0 ;;
|
||||
[Yy])
|
||||
echo -e "\n"
|
||||
return 0
|
||||
;;
|
||||
[Nn]) error "\nExiting." ;;
|
||||
*) error "\nInvalid response.\n" false ;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#
|
||||
# Script pro přesměrování portu pro stanici SWS12500
|
||||
|
||||
|
||||
STATION_IP=[_STATION_IP_]
|
||||
HA=[_HA_]
|
||||
SRC_PORT=[_SRC_PORT_]
|
||||
|
|
@ -22,10 +21,12 @@ GREEN_COLOR='\033[0;32m'
|
|||
GREEN_YELLOW='\033[1;33m'
|
||||
NO_COLOR='\033[0m'
|
||||
|
||||
|
||||
function info () { echo -e "${GREEN_COLOR}INFO: $1${NO_COLOR}";}
|
||||
function warn () { echo -e "${GREEN_YELLOW}WARN: $1${NO_COLOR}";}
|
||||
function error () { echo -e "${RED_COLOR}ERROR: $1${NO_COLOR}"; if [ "$2" != "false" ]; then exit 1;fi; }
|
||||
function info() { echo -e "${GREEN_COLOR}$1${NO_COLOR}"; }
|
||||
function warn() { echo -e "${GREEN_YELLOW}$1${NO_COLOR}"; }
|
||||
function error() {
|
||||
echo -e "${RED_COLOR}$1${NO_COLOR}"
|
||||
if [ "$2" != "false" ]; then exit 1; fi
|
||||
}
|
||||
|
||||
function check() {
|
||||
echo -n "Checking dependencies: '$1' ... "
|
||||
|
|
@ -37,7 +38,6 @@ function check () {
|
|||
return 0
|
||||
}
|
||||
|
||||
|
||||
echo
|
||||
echo "**************************************************************"
|
||||
echo "* *"
|
||||
|
|
@ -54,7 +54,6 @@ INSTALL_IPTABLES=$?
|
|||
check "apk" false
|
||||
APK_MISSING=$?
|
||||
|
||||
|
||||
if [ $APK_MISSING -eq 1 ] && [ $INSTALL_IPTABLES -eq 1 ]; then
|
||||
error "Could not install and run iptables.\n'apk' installer is missing and 'iptables' are not installed.\n"
|
||||
fi
|
||||
|
|
@ -77,6 +76,7 @@ $(iptables -C ${RULE[@]} 2>/dev/null)
|
|||
if [ $? -eq 0 ]; then
|
||||
warn "Rule is already present in PREROUTING chain."
|
||||
else
|
||||
info "not found."
|
||||
echo -n "Inserting iptables rule to PREROUTING chain ... "
|
||||
$(iptables -I ${RULE[@]})
|
||||
fi
|
||||
|
|
@ -86,4 +86,5 @@ if [ $EXIT_STATUS -ne 0 ]; then
|
|||
error "Rule could not be added!"
|
||||
fi
|
||||
|
||||
info "iptables are set to forward port $SRC_PORT -> $DST_PORT for station's IP: $STATION_IP"
|
||||
info "OK."
|
||||
info "iptables are now set to redirect incomming connections from $STATION_IP:Any -> $HA:$SRC_PORT to $HA:$DST_PORT"
|
||||
|
|
|
|||
Loading…
Reference in New Issue