[no ci] General: update scripts (#1386)

pull/1387/head
viktorxda 2024-04-08 14:17:32 +02:00 committed by GitHub
parent 6fc21eee30
commit a9214c48af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 66 additions and 106 deletions

View File

@ -1,7 +1,6 @@
#!/bin/sh #!/bin/sh
# Setting the TimeZone for all processes # Setting the TimeZone for all processes
/usr/sbin/timezone.sh
export TZ=$(cat /etc/TZ) export TZ=$(cat /etc/TZ)
# Set the firmware creation time as the base system time # Set the firmware creation time as the base system time

View File

@ -1,41 +0,0 @@
#!/bin/sh
# Get the timezone from the u-boot environment variable
timezone=$(fw_printenv -n timezone 2>/dev/null)
if [ -z "$timezone" ]; then
echo "Timezone env variable not found, using system default."
exit 1
fi
echo "User defined timezone: $timezone"
# Check if the values in /etc/timezone and /etc/TZ match the ones from fw_printenv
current_timezone=$(cat /etc/timezone 2>/dev/null)
current_tz_value=$(cat /etc/TZ 2>/dev/null)
if [ "$timezone" = "$current_timezone" ] && [ "$timezone" = "$current_tz_value" ]; then
echo "Timezone settings are already up to date."
exit 0
fi
# Search for the timezone in the file
matching_line=$(zcat /var/www/a/tz.js.gz | grep -i -F "$timezone")
if [ -z "$matching_line" ]; then
echo "Timezone not found in system file."
exit 1
fi
# Extract the value associated with the timezone
value=$(echo "$matching_line" | sed "s/^.*v:'\([^']*\)'.*$/\1/")
# Write the TZ file first
echo $value > /etc/TZ
# Then write the timezone file
echo $timezone > /etc/timezone
export TZ=$value
if tty -s; then
echo "timezone.sh: You are running from a shell, please restart or log out to update timezone environment variables."
fi

View File

@ -1,43 +1,45 @@
#!/bin/sh #!/bin/sh
#
# Start fpv datalink
#
. /etc/datalink.conf
chip=$(ipcinfo -c) chip=$(ipcinfo -c)
skip=$(fw_printenv -n fpv) skip=$(fw_printenv -n fpv)
fw=$(grep "BUILD_OPTION" "/etc/os-release" | cut -d= -f2) fw=$(grep "BUILD_OPTION" "/etc/os-release" | cut -d= -f2)
if [ -e /etc/datalink.conf ]; then
source /etc/datalink.conf
fi
case "$1" in case "$1" in
start) start)
if [ ${skip} = "true" ]; then if [ "$skip" = "true" ]; then
sed -i "s/console/#console/g" /etc/inittab sed -i "s/console/#console/g" /etc/inittab
elif [ ${skip} = "false" ]; then elif [ "$skip" = "false" ]; then
sed -i "s/#console/console/g" /etc/inittab sed -i "s/#console/console/g" /etc/inittab
exit 0 exit 0
fi fi
if ! [ -f /etc/system.ok ]; then if ! [ -f /etc/system.ok ]; then
tweaksys ${chip} tweaksys "$chip"
fi fi
echo "Starting FPV datalink..." echo "Starting FPV datalink..."
if [ ${fw} = "lte" ]; then if [ "$fw" = "lte" ]; then
if [ ${usb_modem} = "true" ]; then if [ "$usb_modem" = "true" ]; then
echo "Starting lte modem configuration..." echo "Starting lte modem configuration..."
echo "ToDo: Running usb_modeswitch or other shit here..." echo "ToDo: Running usb_modeswitch or other shit here..."
fi fi
# for the future # for the future
#cli -s .outgoing.url1 udp://${gs_ipaddr}:${gs_port} #cli -s .outgoing.url1 udp://$gs_ipaddr:$gs_port
if [ ${use_zt} = "true" ]; then if [ "$use_zt" = "true" ]; then
echo "Starting ZeroTier-One daemon..." echo "Starting ZeroTier-One daemon..."
/usr/sbin/zerotier-one -d & /usr/sbin/zerotier-one -d &
if [ ! -f /var/lib/zerotier-one/networks.d/${zt_netid}.conf ]; then if [ ! -f /var/lib/zerotier-one/networks.d/$zt_netid.conf ]; then
sleep 8 sleep 8
zerotier-cli join ${zt_netid} &> /dev/null zerotier-cli join $zt_netid &> /dev/null
echo "Don't forget authorize in the my.zerotier.com!" echo "Don't forget authorize in the my.zerotier.com!"
fi fi
fi fi
if [ ${telemetry} = "true" ]; then
if [ "$telemetry" = "true" ]; then
telemetry start telemetry start
fi fi
else else

View File

@ -1,30 +1,30 @@
#!/bin/sh #!/bin/sh
#
# Start wifibroadcast
#
. /etc/datalink.conf
. /etc/wfb.conf
keydir="/etc"
chip=$(ipcinfo -c) chip=$(ipcinfo -c)
vendor=$(ipcinfo -v) vendor=$(ipcinfo -v)
driver="" keydir=/etc
if [ -e /etc/datalink.conf ]; then
source /etc/datalink.conf
fi
if [ -e /etc/wfb.conf ]; then
source /etc/wfb.conf
fi
set_mcs() { set_mcs() {
if [ ${vendor} = "ingenic" ]; then if [ "$vendor" = "ingenic" ]; then
mcs=$(ls -l /lib/firmware | grep "htc_9271" | awk {'print $11'} | cut -d "." -f3) mcs=$(ls -l /lib/firmware | grep "htc_9271" | awk {'print $11'} | cut -d "." -f3)
else else
mcs=$(ls -l /lib/firmware/ath9k_htc | grep "htc_9271-1.4.0.fw" | cut -d "." -f6) mcs=$(ls -l /lib/firmware/ath9k_htc | grep "htc_9271-1.4.0.fw" | cut -d "." -f6)
fi fi
if [ -z "${mcs}" ]; then if [ -z "$mcs" ]; then
setmcs ${mcs_index} setmcs $mcs_index
fi fi
if [ ${mcs_index} -eq 1 ] || [ ${mcs_index} -eq 3 ]; then if [ "$mcs_index" -eq 1 ] || [ "$mcs_index" -eq 3 ]; then
if [ ! ${mcs_index} -eq ${mcs} ]; then if [ ! "$mcs_index" -eq "$mcs" ]; then
setmcs ${mcs_index} setmcs $mcs_index
sleep 3 sleep 3
fi fi
fi fi
@ -36,42 +36,42 @@ set_mcs() {
detect_wifi_card() { detect_wifi_card() {
echo "Detecting wifi card vendor..." echo "Detecting wifi card vendor..."
devices=$(lsusb | cut -d ' ' -f6 | sort | uniq) devices=$(lsusb | cut -d ' ' -f6 | sort | uniq)
for card in ${devices}; do for card in $devices; do
case "${card}" in case "$card" in
"0bda:8812" | "0bda:881a" | "0b05:17d2" | "2357:0101" | "2604:0012") "0bda:8812" | "0bda:881a" | "0b05:17d2" | "2357:0101" | "2604:0012")
driver="realtek" driver="realtek"
modprobe 88XXau rtw_tx_pwr_idx_override=${driver_txpower_override} modprobe 88XXau rtw_tx_pwr_idx_override=$driver_txpower_override
;; ;;
"0cf3:9271" | "040d:3801") "0cf3:9271" | "040d:3801")
driver="atheros" driver="atheros"
if ! [ ${unit} = "gs" ]; then if ! [ "$unit" = "gs" ]; then
set_mcs set_mcs
fi fi
modprobe mac80211 modprobe mac80211
modprobe ath9k_hw txpower=${txpower} modprobe ath9k_hw txpower=$txpower
modprobe ath9k_htc modprobe ath9k_htc
;; ;;
esac esac
done done
if [ -z "${driver}" ]; then if [ -z "$driver" ]; then
echo "No usb wifi card detected. Check wifi stick connection, usb power or possible bad soldering." echo "No usb wifi card detected. Check wifi stick connection, usb power or possible bad soldering."
exit exit 1
else else
echo "Detected:" ${driver} echo "Detected:" $driver
fi fi
echo "Awaiting interface ${wlan} in system..." echo "Awaiting interface $wlan in system..."
local n=0 local n=0
while ! $(ifconfig -a | grep -q ${wlan}); do while ! $(ifconfig -a | grep -q $wlan); do
if [ ${n} -ge 5 ]; then if [ "$n" -ge 5 ]; then
echo "No interface ${wlan}. Check wifi stick connection, usb power or possible bad soldering." echo "No interface $wlan. Check wifi stick connection, usb power or possible bad soldering."
exit exit 1
fi fi
sleep 0.5 sleep 0.5
n=$(expr ${n} + 1) n=$(expr $n + 1)
done done
} }
@ -81,58 +81,58 @@ load_modules() {
} }
load_interface() { load_interface() {
if [ ${driver} = "realtek" ]; then if [ "$driver" = "realtek" ]; then
ifconfig ${wlan} up ifconfig $wlan up
iwconfig ${wlan} mode monitor iwconfig $wlan mode monitor
elif [ ${driver} = "atheros" ]; then elif [ "$driver" = "atheros" ]; then
iwconfig ${wlan} mode monitor iwconfig $wlan mode monitor
ifconfig ${wlan} up ifconfig $wlan up
fi fi
iw reg set ${region} iw reg set $region
if [ ! -z "${frequency}" ]; then if [ ! -z "$frequency" ]; then
iwconfig ${wlan} freq ${frequency} iwconfig $wlan freq $frequency
else else
iwconfig ${wlan} channel ${channel} iwconfig $wlan channel $channel
fi fi
# dirty fix crash if txpower set. setting txpower disabled because patched driver always set txpower level 58 # dirty fix crash if txpower set. setting txpower disabled because patched driver always set txpower level 58
# iw dev ${wlan} set txpower fixed $((${txpower} * 100)) # iw dev $wlan set txpower fixed $(($txpower * 100))
} }
start_drone_wfb() { start_drone_wfb() {
wfb_tx -p ${stream} -u ${udp_port} -R ${rcv_buf} -K ${keydir}/${unit}.key -B ${bandwidth} \ wfb_tx -p $stream -u $udp_port -R $rcv_buf -K $keydir/$unit.key -B $bandwidth \
-M ${mcs_index} -S ${stbc} -L ${ldpc} -G ${guard_interval} -k ${fec_k} -n ${fec_n} \ -M $mcs_index -S $stbc -L $ldpc -G $guard_interval -k $fec_k -n $fec_n \
-T ${pool_timeout} -i ${link_id} -f ${frame_type} ${wlan} > /dev/null & -T $pool_timeout -i $link_id -f $frame_type $wlan > /dev/null &
} }
start_gs_wfb() { start_gs_wfb() {
wfb_rx -c ${udp_addr} -u ${udp_port} -p ${stream} -K ${keydir}/${unit}.key -i ${link_id} ${wlan} > /dev/null & wfb_rx -c $udp_addr -u $udp_port -p $stream -K $keydir/$unit.key -i $link_id $wlan > /dev/null &
} }
case "$1" in case "$1" in
start) start)
if [ ${daemon} -eq 1 ]; then if [ "$daemon" -eq 1 ]; then
echo "Loading modules and wifi card driver..." echo "Loading modules and wifi card driver..."
load_modules load_modules
echo "Preparing interface wlan..." echo "Preparing interface wlan..."
load_interface load_interface
if ! cat ${keydir}/${unit}.key > /dev/null 2>&1; then if ! cat "$keydir/$unit.key" > /dev/null 2>&1; then
echo "Generating drone & ground station keys..." echo "Generating drone & ground station keys..."
cd ${keydir}; wfb_keygen cd $keydir; wfb_keygen
else else
echo ${unit} "key exist..." echo $unit "key exist..."
fi fi
echo "Starting Wifibroadcast service..." echo "Starting Wifibroadcast service..."
start_${unit}_wfb start_${unit}_wfb
echo "Done." echo "Done."
if [ ${telemetry} = "true" ]; then if [ "$telemetry" = "true" ]; then
if [ ${chip} = "gk7205v200" ]; then if [ "$chip" = "gk7205v200" ]; then
# UART2_RX mux # UART2_RX mux
devmem 0x120c0010 32 0x1e04 devmem 0x120c0010 32 0x1e04
fi fi