opustecnica / public Goto Github PK
View Code? Open in Web Editor NEWPublic Code Share
License: GNU General Public License v3.0
Public Code Share
License: GNU General Public License v3.0
What do you think about this version of scripts/ipt-enable-logs.sh for https://github.com/opustecnica/public/wiki/UDM-&-UDM-PRO-NOTES?
#!/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
#!/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.
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
iptables
and I see my firewall rule set, butbash
, 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
bash
available, butiptables
... :-(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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.