From a992eea34527fa21797f5d3f1a13692bbb9489d2 Mon Sep 17 00:00:00 2001
From: Viktor <35473052+viktorxda@users.noreply.github.com>
Date: Mon, 22 Jan 2024 10:28:20 +0100
Subject: [PATCH] [no ci] Package: format datalink/wifibroadcast scripts

---
 general/package/datalink/files/S98datalink    | 74 +++++++++----------
 general/package/datalink/files/tweaksys       | 10 ++-
 general/package/wifibroadcast/files/setmcs    | 56 +++++++-------
 .../package/wifibroadcast/files/wifibroadcast |  5 --
 4 files changed, 72 insertions(+), 73 deletions(-)

diff --git a/general/package/datalink/files/S98datalink b/general/package/datalink/files/S98datalink
index 999f3163..6d1c5b64 100755
--- a/general/package/datalink/files/S98datalink
+++ b/general/package/datalink/files/S98datalink
@@ -2,54 +2,54 @@
 #
 # Start fpv datalink
 #
-
 . /etc/datalink.conf
-
 chip=$(ipcinfo -c)
 fw=$(grep "BUILD_OPTION" "/etc/os-release" | cut -d= -f2)
 
 case "$1" in
-  start)
-	if ! [ -f /etc/system.ok ]; then
-		tweaksys ${chip}
-	fi
+	start)
+		if ! [ -f /etc/system.ok ]; then
+			tweaksys ${chip}
+		fi
 
-	echo "Starting FPV datalink..."
-
-	if [ ${fw} = "lte" ]; then
-	  if [ ${usb_modem} = "true" ]; then
+		echo "Starting FPV datalink..."
+		if [ ${fw} = "lte" ]; then
+		if [ ${usb_modem} = "true" ]; then
 		echo "Starting lte modem configuration..."
 		echo "ToDo: Running usb_modeswitch or other shit here..."
-	  fi
-	  # for the future
-	  #cli -s .outgoing.url1 udp://${gs_ipaddr}:${gs_port}
-	  if [ ${use_zt} = "true" ]; then
+		fi
+		# for the future
+		#cli -s .outgoing.url1 udp://${gs_ipaddr}:${gs_port}
+		if [ ${use_zt} = "true" ]; then
 		echo "Starting ZeroTier-One daemon..."
 		/usr/sbin/zerotier-one -d &
 		if [ ! -f /var/lib/zerotier-one/networks.d/${zt_netid}.conf ]; then
-		  sleep 8
-		  zerotier-cli join ${zt_netid} &> /dev/null
-		  echo "Don't forget authorize in the my.zerotier.com!"
+		sleep 8
+		zerotier-cli join ${zt_netid} &> /dev/null
+		echo "Don't forget authorize in the my.zerotier.com!"
 		fi
-	  fi
-	  if [ ${telemetry} = "true" ]; then
+		fi
+		if [ ${telemetry} = "true" ]; then
 		telemetry start
-	  fi
-	else
-	  echo "Starting wifibroadcast service..."
-	  wifibroadcast start
-	fi
-	;;
-  stop)
-    echo "Stopping all services..."
-    kill -9 $(pidof wfb_tx)
-    kill -9 $(pidof wfb_rx)
-    kill -9 $(pidof telemetry_rx)
-    kill -9 $(pidof telemetry_tx)
-    kill -9 $(pidof mavlink-routerd)
-    kill -9 $(pidof mavfwd)
-	;;
-    *)
-    echo "Usage: $0 {start|stop}"
-    exit 1
+		fi
+		else
+		echo "Starting wifibroadcast service..."
+		wifibroadcast start
+		fi
+		;;
+
+	stop)
+		echo "Stopping all services..."
+		killall -q wfb_tx
+		killall -q wfb_rx
+		killall -q telemetry_rx
+		killall -q telemetry_tx
+		killall -q mavlink-routerd
+		killall -q mavfwd
+		;;
+
+	*)
+		echo "Usage: $0 {start|stop}"
+		exit 1
+		;;
 esac
diff --git a/general/package/datalink/files/tweaksys b/general/package/datalink/files/tweaksys
index 92f4feff..57ee9fe6 100755
--- a/general/package/datalink/files/tweaksys
+++ b/general/package/datalink/files/tweaksys
@@ -113,7 +113,6 @@ finish() {
 case "$1" in
 	gk7205v200 | gk7205v210 | hi3516ev200)
 		echo "Preparing system tweaks for ${chip}..."
-
 		# set custom config
 		if [ ${chip} = "gk7205v200" ] && [ ${sensor} = "imx307" ]; then
 			echo "switch to custom sensor config"
@@ -136,6 +135,7 @@ case "$1" in
 		streamer
 		finish
 		;;
+
 	gk7205v300 | hi3516ev300)
 		echo "Preparing system tweaks for ${chip}..."
 
@@ -152,27 +152,29 @@ case "$1" in
 		streamer
 		finish
 		;;
+
 	t31l | t31n | t31x | t31zx)
 		echo "Preparing system tweaks for ${chip}..."
-
 		basic
 		streamer
 		finish
 		;;
+
 	hi3536dv100)
 		echo "Preparing system tweaks for ${chip}..."
-
 		finish
 		;;
+
 	ssc33x)
 		echo "Preparing system tweaks for ${chip}..."
-
 		basic
 		sigmastar
 		streamer
 		finish
 		;;
+
 	*)
 		echo "Usage: $0 {gk7205v200|gk7205v210|gk7205v300|hi3516ev200|hi3516ev300|t31l|t31n|t31x|t31zx|hi3536dv100|ssc33x}"
 		exit 1
+		;;
 esac
diff --git a/general/package/wifibroadcast/files/setmcs b/general/package/wifibroadcast/files/setmcs
index 18ccaf1a..74a99258 100755
--- a/general/package/wifibroadcast/files/setmcs
+++ b/general/package/wifibroadcast/files/setmcs
@@ -1,36 +1,38 @@
 #!/bin/sh
 #
-# Change Atheros MCS 
+# Change Atheros MCS
 # Author: Tipo Man
 
 vendor=$(ipcinfo -v)
 
 case "$1" in
-	"1")	   
-	  echo '1-1' > /sys/bus/usb/drivers/usb/unbind
-	  if [ ${vendor} = "ingenic" ]; then
-		  rm /lib/firmware/htc_9271.fw
-		  ln -s /lib/firmware/ath9k_htc/htc_9271.fw.1 /lib/firmware/htc_9271.fw
-	  else
-		  rm /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
-		  ln -s /lib/firmware/ath9k_htc/htc_9271.fw.1 /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
-	  fi
-	  echo '1-1' > /sys/bus/usb/drivers/usb/bind
-	  echo "Loaded firmware with MCS"$1
-	;;
-	"3")		
-	  echo '1-1' > /sys/bus/usb/drivers/usb/unbind
-	  if [ ${vendor} = "ingenic" ]; then
-		  rm /lib/firmware/htc_9271.fw
-		  ln -s /lib/firmware/ath9k_htc/htc_9271.fw.3 /lib/firmware/htc_9271.fw
-	  else
-		  rm /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
-		  ln -s /lib/firmware/ath9k_htc/htc_9271.fw.3 /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
-	  fi
-	  echo '1-1' > /sys/bus/usb/drivers/usb/bind
-	  echo "Loaded firmware with MCS"$1
-	;;
+	"1")
+		echo '1-1' > /sys/bus/usb/drivers/usb/unbind
+		if [ ${vendor} = "ingenic" ]; then
+			rm /lib/firmware/htc_9271.fw
+			ln -s /lib/firmware/ath9k_htc/htc_9271.fw.1 /lib/firmware/htc_9271.fw
+		else
+			rm /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
+			ln -s /lib/firmware/ath9k_htc/htc_9271.fw.1 /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
+		fi
+		echo '1-1' > /sys/bus/usb/drivers/usb/bind
+		echo "Loaded firmware with MCS"$1
+		;;
+
+	"3")
+		echo '1-1' > /sys/bus/usb/drivers/usb/unbind
+		if [ ${vendor} = "ingenic" ]; then
+			rm /lib/firmware/htc_9271.fw
+			ln -s /lib/firmware/ath9k_htc/htc_9271.fw.3 /lib/firmware/htc_9271.fw
+		else
+			rm /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
+			ln -s /lib/firmware/ath9k_htc/htc_9271.fw.3 /lib/firmware/ath9k_htc/htc_9271-1.4.0.fw
+		fi
+		echo '1-1' > /sys/bus/usb/drivers/usb/bind
+		echo "Loaded firmware with MCS"$1
+		;;
+
 	*)
-	  echo "Only MCS 1 or 3 supported!"
-	;;
+		echo "Only MCS 1 or 3 supported!"
+		;;
 esac
diff --git a/general/package/wifibroadcast/files/wifibroadcast b/general/package/wifibroadcast/files/wifibroadcast
index 99bdd38b..896c7587 100755
--- a/general/package/wifibroadcast/files/wifibroadcast
+++ b/general/package/wifibroadcast/files/wifibroadcast
@@ -43,11 +43,6 @@ detect_wifi_card() {
 				modprobe 88XXau rtw_tx_pwr_idx_override=${driver_txpower_override}
 				;;
 
-			"0bda:f72b")
-				driver="realtek"
-				modprobe 8733bu
-				;;
-
 			"0cf3:9271" | "040d:3801")
 				driver="atheros"
 				if ! [ ${unit} = "gs" ]; then