mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 15:38:40 +01:00
Fwknop: add flexibility to uci support
Styling cleanups signed-off-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
committed by
Steven Barth
parent
8c1e0d4bfd
commit
7d72d8b170
@@ -0,0 +1,9 @@
|
||||
config global
|
||||
# option uci_enabled '1'
|
||||
|
||||
config access
|
||||
option SOURCE 'ANY'
|
||||
option HMAC_KEY 'CHANGEME'
|
||||
option KEY 'CHANGEME'
|
||||
|
||||
config config
|
||||
@@ -30,60 +30,59 @@ restart()
|
||||
|
||||
reload()
|
||||
{
|
||||
gen_confs
|
||||
$FWKNOPD_BIN -R
|
||||
}
|
||||
|
||||
gen_confs()
|
||||
{
|
||||
|
||||
|
||||
config_cb() {
|
||||
|
||||
local type="$1"
|
||||
local name="$2"
|
||||
if [ "$type" = "global" ]
|
||||
then
|
||||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
if [ "$option" = "uci_enabled" ] && [ "$value" -eq 1 ] ; then
|
||||
> /etc/fwknop/fwknopd.conf
|
||||
> /etc/fwknop/access.conf
|
||||
UCI_ENABLED=1
|
||||
[ -f /tmp/access.conf.tmp ] && rm /tmp/access.conf.tmp
|
||||
config_cb() {
|
||||
local type="$1"
|
||||
local name="$2"
|
||||
if [ "$type" = "global" ]; then
|
||||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
if [ "$option" = "uci_enabled" ] && [ "$value" -eq 1 ] ; then
|
||||
> /etc/fwknop/fwknopd.conf
|
||||
> /etc/fwknop/access.conf
|
||||
UCI_ENABLED=1
|
||||
fi
|
||||
}
|
||||
elif [ "$type" = "config" ]; then
|
||||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
if [ $UCI_ENABLED ]; then
|
||||
echo "$option $value" >> /etc/fwknop/fwknopd.conf #writing each option to fwknopd.conf
|
||||
fi
|
||||
}
|
||||
elif [ "$type" = "access" ]
|
||||
then
|
||||
if [ -f /tmp/access.conf.tmp ] ; then
|
||||
cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
|
||||
rm /tmp/access.conf.tmp
|
||||
fi
|
||||
}
|
||||
elif [ "$type" = "config" ]
|
||||
then
|
||||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
if [ $UCI_ENABLED ]; then
|
||||
echo "${option//_/-} $value" >> /etc/fwknop/fwknopd.conf #writing each option to fwknopd.conf
|
||||
fi
|
||||
}
|
||||
elif [ "$type" = "SOURCE" ]
|
||||
then
|
||||
echo "${type//_/-} $name" >> /etc/fwknop/access.conf #writing each option to access.conf
|
||||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
if [ $UCI_ENABLED ]; then
|
||||
echo "${option//_/-} $value" >> /etc/fwknop/access.conf #writing each option to access.conf
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
if [ $UCI_ENABLED ] && [ $option = "SOURCE" ]; then
|
||||
echo "$option $value" >> /etc/fwknop/access.conf #writing each option to access.conf
|
||||
fi
|
||||
if [ $UCI_ENABLED ] && [ $option != "SOURCE" ]; then
|
||||
echo "$option $value" >> /tmp/access.conf.tmp #writing each option to access.conf
|
||||
fi
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if [ -f /etc/config/fwknopd ]; then
|
||||
|
||||
config_load fwknopd
|
||||
|
||||
|
||||
fi
|
||||
if [ -f /etc/config/fwknopd ]; then
|
||||
config_load fwknopd
|
||||
if [ -f /tmp/access.conf.tmp ] ; then
|
||||
cat /tmp/access.conf.tmp >> /etc/fwknop/access.conf
|
||||
rm /tmp/access.conf.tmp
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user