Hey folks,
There's a lot of different scripts appearing lately, allowing users to implement advanced firewall-level filtering. This is great
A lot of those require being added to the firewall-start script, and I understand that things can start getting messy, as everyone probably does it his way, and that file could potentially become cluttered.
I would recommend agreeing on some kind of "standard" way of dealing with firewall-start. Here are my recommendations:
First, limit the changes to firewall-start to either a single line, two at most. One (optional) line could be a comment to simply identify the next line.
The second line would be a call to a separate script, which would contain ALL of the changes you want to make at firewall-start launch.
This way, it will make it easier to detect the presence of a given script, and also to handle it. Here's an example.
Let's say your script comes with its own install/uninstall routine. The install routine would insert the following line:
Then, later on, the user wants to uninstall your script. Your uninstaller can then simply remove that one single line, using sed (you can even use the helper.sh script that I include in the firmware, and which can easily remove/add/replace a line in a given file):
Similarly, you can easily detect if another script is present, and deal accordingly if you can find that specific line inside firewall-start: warn the user of compatibility issue, insert yourself specifically before that line, etc.... Use something like sed or grep to detect the presence of the other script within firewall-start.
In the end, this will make it easier for the developers, but also for the users (making it easier/simpler to implement an uninstaller).
There's a lot of different scripts appearing lately, allowing users to implement advanced firewall-level filtering. This is great
A lot of those require being added to the firewall-start script, and I understand that things can start getting messy, as everyone probably does it his way, and that file could potentially become cluttered.
I would recommend agreeing on some kind of "standard" way of dealing with firewall-start. Here are my recommendations:
First, limit the changes to firewall-start to either a single line, two at most. One (optional) line could be a comment to simply identify the next line.
The second line would be a call to a separate script, which would contain ALL of the changes you want to make at firewall-start launch.
This way, it will make it easier to detect the presence of a given script, and also to handle it. Here's an example.
Let's say your script comes with its own install/uninstall routine. The install routine would insert the following line:
Code:
sh /jffs/yourscript/start-superfilter
Then, later on, the user wants to uninstall your script. Your uninstaller can then simply remove that one single line, using sed (you can even use the helper.sh script that I include in the firmware, and which can easily remove/add/replace a line in a given file):
Code:
#Uninstaller
pc_delete "sh /jffs/yourscript/start-superfilter" "/jffs/scripts/firewall-start"
rm -rf /jffs/yourscript
service restart_firewall
Similarly, you can easily detect if another script is present, and deal accordingly if you can find that specific line inside firewall-start: warn the user of compatibility issue, insert yourself specifically before that line, etc.... Use something like sed or grep to detect the presence of the other script within firewall-start.
In the end, this will make it easier for the developers, but also for the users (making it easier/simpler to implement an uninstaller).