Fix permissions

pull/22/head
schizza 2024-05-03 10:19:14 +02:00
parent 0409955801
commit acebf1b268
2 changed files with 11 additions and 9 deletions

View File

@ -196,10 +196,7 @@ echo -n "Creating 'exec.sh' script ... "
cat >$COMPLETE_PATH/exec.sh <<-EOF cat >$COMPLETE_PATH/exec.sh <<-EOF
#!/bin/bash #!/bin/bash
RUN=\$(find /homeassistant -name "iptables_redirect.sh" | sed -n 1p) 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
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
EOF EOF
exit_status $? "cat" \ exit_status $? "cat" \
@ -212,12 +209,18 @@ exit_status $? "chmod" \
"Filed to set +x on exec.sh" \ "Filed to set +x on exec.sh" \
"OK." "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' ... " echo -n "Creating 'runscript' ... "
cat >$COMPLETE_PATH/runscript <<-"EOF" cat >$COMPLETE_PATH/runscript <<-"EOF"
#!/bin/zsh #!/bin/bash
SCRIPT=$(find /homeassistant -name "iptables_redirect.sh" | sed -n 1p) SCRIPT=$(find /homeassistant -name "iptables_redirect.sh" | sed -n 1p)
sudo /bin/bash "$SCRIPT" sudo $SCRIPT
EOF EOF
exit_status $? "cat" \ exit_status $? "cat" \

View File

@ -59,9 +59,8 @@ if [ $APK_MISSING -eq 1 ] && [ $INSTALL_IPTABLES -eq 1 ]; then
fi fi
if [ $INSTALL_IPTABLES -eq 1 ] && [ $APK_MISSING -eq 0 ]; then if [ $INSTALL_IPTABLES -eq 1 ] && [ $APK_MISSING -eq 0 ]; then
declare -a RUNINSTALL=(apk add iptables)
echo -n "Installing 'iptables' ... ${RUNINSTALL[@]} ... " echo -n "Installing 'iptables' ... ${RUNINSTALL[@]} ... "
${RUNINSTALL[@]} sudo apk add iptables
EXIT_STATUS=$? EXIT_STATUS=$?
if [ $EXIT_STATUS -ne 0 ]; then if [ $EXIT_STATUS -ne 0 ]; then
warn "apk error code: $EXIT_STATUS" warn "apk error code: $EXIT_STATUS"
@ -72,7 +71,7 @@ if [ $INSTALL_IPTABLES -eq 1 ] && [ $APK_MISSING -eq 0 ]; then
fi 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) 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 ... " 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 if [ $? -eq 0 ]; then
warn "Rule is already present in PREROUTING chain." warn "Rule is already present in PREROUTING chain."
else else