Browse Source

dcwapd: Update init script to use procd

consolidate shell scripts into init script
remove "litter" from uci file
update default UCI values

Signed-off-by: Carey Sonsino <careys@edgewaterwireless.com>
Signed-off-by: Carey Sonsino <csonsino@gmail.com>
lilik-openwrt-22.03
Carey Sonsino 5 years ago
parent
commit
0d5b50c4bf
6 changed files with 114 additions and 250 deletions
  1. +2
    -9
      net/dcwapd/Makefile
  2. +110
    -40
      net/dcwapd/files/dcwapd.init
  3. +0
    -31
      net/dcwapd/files/dcwapd.init.d
  4. +2
    -86
      net/dcwapd/files/dcwapd.uci
  5. +0
    -39
      net/dcwapd/files/start_dcwapd.sh
  6. +0
    -45
      net/dcwapd/files/stop_dcwapd.sh

+ 2
- 9
net/dcwapd/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dcwapd
PKG_VERSION:=1.1.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/ewsi/$(PKG_NAME)/tar.gz/v$(PKG_VERSION)?
@ -58,19 +58,12 @@ define Package/dcwapd/install
# Note: $(INSTALL_BIN) does not keep symlinks, so use $(CP)
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
# Utility files
$(INSTALL_DIR) $(1)/etc/$(PKG_NAME)
$(INSTALL_DATA) ./files/*.inc $(1)/etc/$(PKG_NAME)/
$(INSTALL_BIN) ./files/*.sh $(1)/etc/$(PKG_NAME)/
# UCI config file copy - this is here for convenience and reference only
$(INSTALL_DATA) ./files/dcwapd.uci $(1)/etc/$(PKG_NAME)/
# UCI config file
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/dcwapd.uci $(1)/etc/config/dcwapd
# Init script
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/dcwapd.init.d $(1)/etc/init.d/dcwapd
$(INSTALL_BIN) ./files/dcwapd.init $(1)/etc/init.d/dcwapd
endef
$(eval $(call BuildPackage,dcwapd))

net/dcwapd/files/dcwapd.inc → net/dcwapd/files/dcwapd.init View File


+ 0
- 31
net/dcwapd/files/dcwapd.init.d View File

@ -1,31 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
# Setting the stop value makes the restart script unreliable when invoked by LuCI
#STOP=0
scriptdir=/etc/dcwapd
#validate_section_dcwapd() {
# uci_validate_section dcwapd general "${1}" \
# 'enabled:bool:1'
#}
start() {
# validate_section_dcwapd dcwapd
# only run the start script if the enabled uci option is set properly
enabled=$(uci get dcwapd.general.enabled)
if [ "${enabled}" = "1" ]; then
${scriptdir}/start_dcwapd.sh
else
echo "dcwapd is disabled in UCI"
return 1
fi
}
stop() {
${scriptdir}/stop_dcwapd.sh
# Add a sleep after stopping because an immediate restat will fail otherwise
sleep 1
}

+ 2
- 86
net/dcwapd/files/dcwapd.uci View File

@ -1,99 +1,22 @@
######################################################
# Copyright 2018 EWSI
#
# Licensed to the public under the Apache License 2.0.
######################################################
# Dual Channel Wi-Fi AP Daemon configuration
###################
# General Options #
###################
# The "enabled" option controls the run state of the Dual Channel Wi-Fi AP Daemon
# 0 - disabled, 1 - enabled
# The "tmpdir" option MUST be specified
# option tmpdir '<path_of_temp_dir>'
config general 'general'
option enabled 0
option tmpdir '/tmp/dcwapd'
################
# Channel Sets #
################
# Sections of type "channel-set" define a Dual Channel Wi-Fi primary channel,
# along with it's associated data channels
#
# The "data_channels" option is a space-delimited list of "datachannel"-typed instance names
config channel-set 'channelset0'
option enabled 0
# option enabled 1
option ssid 'OpenWrt'
option bridge 'br-lan'
option data_channels 'datachannel0'
#config channel-set 'channelset1'
# option enabled 0
# option ssid 'OpenWrt2'
# option bridge 'br-lan'
# option data_channels 'datachannel1'
#################
# Data Channels #
#################
# Sections of type "datachannel" define a Dual Channel Wi-Fi data channel,
# along with it's associated bridge and wireless interfaces
#
# The "interfaces" option is a space-delimited list of wireless interface names
config datachannel 'datachannel0'
option ssid 'DCW0'
option ssid 'OpenWrt-DCW'
option bridge 'br-dc0'
option interfaces 'wlan2 wlan5'
#config datachannel 'datachannel1'
# option ssid 'DCW1'
# option bridge 'br-dc1'
# option interfaces 'wlan4'
####################
# Init Net Options #
####################
# The "init_net" section MUST be specified
# This section will be used to save and restore the state of the data interfaces
config init_net 'init_net'
###############
# Filter Sets #
###############
# Sections of type "filter-set" define a Dual Channel Wi-Fi group of filters,
# along with it's associated MAC address and filter rules
#
# The "TFP_Default" filter set MUST be defined, although it is not required
# to have any associated filter rules
# The "TFP_Default" filter mac option can have the value of '*', meaning match
# all MAC addresses
#
# The "filters" option is a space-delimited list of "filter"-typed instance names
option interfaces ''
config filter-set 'TFP_Default'
option mac '*'
option filters 'filter0 filter1'
#config filter-set 'filterset0'
# option mac '00:00:BE:EF:F0:0D'
# option filters 'filter2'
################
# Filter Rules #
################
# Sections of type "filter" define a Dual Channel Wi-Fi filter,
# along with it's associated filter parameters
#
# Any or all of the filter options may be set to '*' to match
# all values
config filter 'filter0'
option packet_size '*'
option source_ip '*'
@ -107,10 +30,3 @@ config filter 'filter1'
option source_port '443'
option protocol 'tcp'
option dest_port '*'
#config filter 'filter2'
# option packet_size '*'
# option source_ip '*'
# option source_port '22'
# option protocol 'tcp'
# option dest_port '*'

+ 0
- 39
net/dcwapd/files/start_dcwapd.sh View File

@ -1,39 +0,0 @@
#!/bin/sh
#
# Dual Channel Wi-Fi Startup Script
#
# This script creates the proper network bridge configuration
# necessary for Dual Channel Wi-Fi, and starts the dcwapd daemon
#
# Note - shellcheck cannot deal with the dynamic sourcing
# shellcheck disable=SC1090
# which also messes with variables defined in the sourced file
# shellcheck disable=SC2154
scriptdir=$(dirname -- "$(readlink -f -- "$0")")
. "$scriptdir"/dcwapd.inc
get_channelsets
# get the list of channel sets
channelsets=$result
for channelset in $channelsets; do
if [ -n "$channelset" ]; then
get_channelset_enabled "$channelset"
enabled=$result
if [ "$enabled" = "1" ]; then
# the channel set is enabled
# get the list of data channels used by the channel set
get_datachannels "$channelset"
datachannels=$result
for datachannel in $datachannels; do
datachannel_up "$datachannel"
done
fi
fi
done
# start dcwapd, sending stdout and stderr to the system log
dcwapd 2>&1 | logger &

+ 0
- 45
net/dcwapd/files/stop_dcwapd.sh View File

@ -1,45 +0,0 @@
#!/bin/sh
#
# Dual Channel Wi-Fi Startup Script
#
# This script creates the proper network bridge configuration
# necessary for Dual Channel Wi-Fi, and starts the dcwapd daemon
#
# Note - shellcheck cannot deal with the dynamic sourcing
# shellcheck disable=SC1090
# which also messes with variables defined in the sourced file
# shellcheck disable=SC2154
scriptdir=$(dirname -- "$(readlink -f -- "$0")")
. "$scriptdir"/dcwapd.inc
pid=$(pidof dcwapd)
if [ -n "$pid" ]; then
if [ "$verbose" -eq "1" ]; then
echo "Stopping dcwapd..." 2>&1 | logger
fi
kill "$pid"
fi
get_channelsets
# get the list of channel sets
channelsets=$result
for channelset in $channelsets; do
if [ -n "$channelset" ]; then
# we don't care if it is enabled, tear it down
# get_channelset_enabled $channelset
# enabled=$result
# if [ $enabled = "1" ]; then
# # the channel set is enabled
# get the list of data channels used by the channel set
get_datachannels "$channelset"
datachannels=$result
for datachannel in $datachannels; do
datachannel_down "$datachannel"
done
# fi
fi
done

Loading…
Cancel
Save