Fix permissions
parent
0409955801
commit
acebf1b268
|
|
@ -196,10 +196,7 @@ echo -n "Creating 'exec.sh' script ... "
|
|||
cat >$COMPLETE_PATH/exec.sh <<-EOF
|
||||
#!/bin/bash
|
||||
|
||||
RUN=\$(find /homeassistant -name "iptables_redirect.sh" | sed -n 1p)
|
||||
KEY=\$(find /homeassistatnt -name "ipt_dsa" | sed -n 1p)
|
||||
|
||||
cat \$RUN | ssh -i \$KEY -o StrictHostKeyChecking=no -p $SSH_PORT -l $SSH_USER $HA_IP /bin/zsh
|
||||
cat iptables_redirect/iptables_redirect.sh | ssh -i iptables_redirect/ssh/ipt.dsa -o StrictHostKeyChecking=no -p $SSH_PORT -l $SSH_USER $HA_IP /bin/zsh
|
||||
EOF
|
||||
|
||||
exit_status $? "cat" \
|
||||
|
|
@ -212,12 +209,18 @@ exit_status $? "chmod" \
|
|||
"Filed to set +x on exec.sh" \
|
||||
"OK."
|
||||
|
||||
echo -n "Setting 'iptables_redirect.sh' script right privileges ... "
|
||||
chmod -f a+rx "$COMPLETE_PATH/iptables_redirect.sh"
|
||||
exit_status $? "chmod" \
|
||||
"Filed to set +x on exec.sh" \
|
||||
"OK."
|
||||
|
||||
echo -n "Creating 'runscript' ... "
|
||||
cat >$COMPLETE_PATH/runscript <<-"EOF"
|
||||
#!/bin/zsh
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT=$(find /homeassistant -name "iptables_redirect.sh" | sed -n 1p)
|
||||
sudo /bin/bash "$SCRIPT"
|
||||
sudo $SCRIPT
|
||||
EOF
|
||||
|
||||
exit_status $? "cat" \
|
||||
|
|
|
|||
|
|
@ -59,9 +59,8 @@ if [ $APK_MISSING -eq 1 ] && [ $INSTALL_IPTABLES -eq 1 ]; then
|
|||
fi
|
||||
|
||||
if [ $INSTALL_IPTABLES -eq 1 ] && [ $APK_MISSING -eq 0 ]; then
|
||||
declare -a RUNINSTALL=(apk add iptables)
|
||||
echo -n "Installing 'iptables' ... ${RUNINSTALL[@]} ... "
|
||||
${RUNINSTALL[@]}
|
||||
sudo apk add iptables
|
||||
EXIT_STATUS=$?
|
||||
if [ $EXIT_STATUS -ne 0 ]; then
|
||||
warn "apk error code: $EXIT_STATUS"
|
||||
|
|
@ -72,7 +71,7 @@ if [ $INSTALL_IPTABLES -eq 1 ] && [ $APK_MISSING -eq 0 ]; then
|
|||
fi
|
||||
declare -a RULE=(PREROUTING -t nat -s $STATION_IP -d $HA -p tcp -m tcp --dport $SRC_PORT -j REDIRECT --to-ports $DST_PORT)
|
||||
echo -n "Chceking for existing rule in iptables ... "
|
||||
$(iptables -C ${RULE[@]} 2>/dev/null)
|
||||
sudo iptables -C ${RULE[@]} 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
warn "Rule is already present in PREROUTING chain."
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue