Coder Social home page Coder Social logo

public's People

Contributors

opustecnica avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

public's Issues

sh version of scripts/ipt-enable-logs.sh

What do you think about this version of scripts/ipt-enable-logs.sh for https://github.com/opustecnica/public/wiki/UDM-&-UDM-PRO-NOTES?

scripts/ipt-enable-logs.sh

#!/bin/sh

# [NOTE] Need to find a hook to run this script not only at startup but every time time the firewall is modified.

# Clear existing ipt-save if it exists.
FILE=/data/ipt-save
if test -f "${FILE}"; then
  rm -f "${FILE}"
fi

# Collect existing iptables configuration into an array.
prev_line=''
iptables-save |
while IFS= read -r line; do
  if [ -n "${prev_line}" ]; then
    ACTION="$(echo "${line}" | sed -E "s/.*-j\s(.*)$/\1/")"
    if echo "${ACTION}" | grep ^RETURN$ >/dev/null; then ACTION='ACCEPT'; fi
    echo -e "${prev_line}" | sed -E "s/^-A\sUBIOS_(\S+)\s.*-j LOG$/& --log-prefix \"[${ACTION}_\1] \"/" >> "${FILE}"
    prev_line=''
  fi

  if echo "${line}" | grep LOG$ >/dev/null
    then
      prev_line="${line}"
    else
      echo -e "${line}" >> "${FILE}"
      prev_line=''
  fi
done

on_boot.d/30-ipt-enable-logs-launch.sh

#!/bin/sh

set -e

/mnt/data/scripts/ipt-enable-logs.sh
iptables-restore -c < /data/ipt-save

I've compared the output of both the previous and new versions and they are identical.

iptables script

Hi @opustecnica! First of all, let me thank you for this script here:
https://github.com/opustecnica/public/wiki/UDM-&-UDM-PRO-NOTES

I have a question about it, if you don't mind... in the "to-do" you say that you need to adapt it to run with sh instead of bash... actually I am getting this problem. When I SSH into my UDM, I get an environment where

  1. I have iptables and I see my firewall rule set, but
  2. I don't have bash, just sh, which is making it difficult to use scripts from the Internet because they are usually bash

On the other hand, if I go into unifi-os shell, I get

  1. A nice environment with bash available, but
  2. It doesn't seem to know anything about iptables... :-(

I've searched a bit around the web but I couldn't get much information on this unifi-os shell, what is it anyway? A container, a chroot, what?

Anyway, I digress - my question to you is: what about your script doesn't work in sh? Did you ever make a sh version of it? I am afraid I am not fluent in shell scripting (any kind), so I'd appreciate your help. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.