#!/bin/sh # # Start wifibroadcast # . /etc/wfb.conf keydir="/etc" load_rtl() { modprobe cfg80211 modprobe 88XXau rtw_monitor_disable_1m=1 } load_ath() { modprobe cfg80211 modprobe mac80211 modprobe ath9k_htc sleep 3 # need to load firmware } load_interface() { if [ ${driver} = "rtl" ]; then ifconfig ${wlan} up iwconfig ${wlan} mode monitor elif [ ${driver} = "ath" ]; then iwconfig ${wlan} mode monitor ifconfig ${wlan} up fi iw reg set ${region} iwconfig ${wlan} channel ${channel} } start_wfb() { wfb_tx -p ${radio_port} -u ${udp_port} -K ${keydir}/drone.key -B ${bandwidth} -M ${mcs_index} -S ${stbc} -L ${ldpc} -G ${guard_interval} -k ${rs_k} -n ${rs_n} ${wlan} & } case "$1" in start) if [ ${daemon} -eq 1 ]; then echo "Loading modules for selected driver..." if [ ${driver} = "rtl" ]; then if ! lsmod | grep "88XXau"; then load_rtl fi elif ${driver} = "ath" ]; then if ! lsmod | grep "ath9k_htc"; then load_ath fi fi echo "Done." echo "Preparing interface wlan..." load_interface echo "Done." if ! cat ${keydir}/drone.key > /dev/null 2>&1; then echo "Generating drone & ground station keys..." cd ${keydir} ; wfb_keygen echo "Done." else echo "Drone key exist... Done." fi echo "Starting Wifibroadcast service..." start_wfb echo "Done." else echo "Wifibroadcast service disabled in wfb.conf..." fi ;; stop) echo "Stopping wifibroadcast service..." kill -9 $(pidof wfb_tx) ifconfig ${wlan} down ;; *) echo "Usage: $0 {start|stop}" exit 1 esac