[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
# Setting the TimeZone for all processes
/usr/sbin/timezone.sh
export TZ=$(cat /etc/TZ)
# 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
#
# Start fpv datalink
#
. /etc/datalink.conf
chip=$(ipcinfo -c)
skip=$(fw_printenv -n fpv)
fw=$(grep "BUILD_OPTION" "/etc/os-release" | cut -d= -f2)
if [ -e /etc/datalink.conf ]; then
source /etc/datalink.conf
fi
case "$1" in
start)
if [ ${skip} = "true" ]; then
if [ "$skip" = "true" ]; then
sed -i "s/console/#console/g" /etc/inittab
elif [ ${skip} = "false" ]; then
elif [ "$skip" = "false" ]; then
sed -i "s/#console/console/g" /etc/inittab
exit 0
fi
if ! [ -f /etc/system.ok ]; then
tweaksys ${chip}
tweaksys "$chip"
fi
echo "Starting FPV datalink..."
if [ ${fw} = "lte" ]; then
if [ ${usb_modem} = "true" ]; then
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
#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
if [ ! -f /var/lib/zerotier-one/networks.d/$zt_netid.conf ]; then
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!"
fi
fi
if [ ${telemetry} = "true" ]; then
if [ "$telemetry" = "true" ]; then
telemetry start
fi
else

View File

@ -1,30 +1,30 @@
#!/bin/sh
#
# Start wifibroadcast
#
. /etc/datalink.conf
. /etc/wfb.conf
keydir="/etc"
chip=$(ipcinfo -c)
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() {
if [ ${vendor} = "ingenic" ]; then
if [ "$vendor" = "ingenic" ]; then
mcs=$(ls -l /lib/firmware | grep "htc_9271" | awk {'print $11'} | cut -d "." -f3)
else
mcs=$(ls -l /lib/firmware/ath9k_htc | grep "htc_9271-1.4.0.fw" | cut -d "." -f6)
fi
if [ -z "${mcs}" ]; then
setmcs ${mcs_index}
if [ -z "$mcs" ]; then
setmcs $mcs_index
fi
if [ ${mcs_index} -eq 1 ] || [ ${mcs_index} -eq 3 ]; then
if [ ! ${mcs_index} -eq ${mcs} ]; then
setmcs ${mcs_index}
if [ "$mcs_index" -eq 1 ] || [ "$mcs_index" -eq 3 ]; then
if [ ! "$mcs_index" -eq "$mcs" ]; then
setmcs $mcs_index
sleep 3
fi
fi
@ -36,42 +36,42 @@ set_mcs() {
detect_wifi_card() {
echo "Detecting wifi card vendor..."
devices=$(lsusb | cut -d ' ' -f6 | sort | uniq)
for card in ${devices}; do
case "${card}" in
for card in $devices; do
case "$card" in
"0bda:8812" | "0bda:881a" | "0b05:17d2" | "2357:0101" | "2604:0012")
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")
driver="atheros"
if ! [ ${unit} = "gs" ]; then
if ! [ "$unit" = "gs" ]; then
set_mcs
fi
modprobe mac80211
modprobe ath9k_hw txpower=${txpower}
modprobe ath9k_hw txpower=$txpower
modprobe ath9k_htc
;;
esac
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."
exit
exit 1
else
echo "Detected:" ${driver}
echo "Detected:" $driver
fi
echo "Awaiting interface ${wlan} in system..."
echo "Awaiting interface $wlan in system..."
local n=0
while ! $(ifconfig -a | grep -q ${wlan}); do
if [ ${n} -ge 5 ]; then
echo "No interface ${wlan}. Check wifi stick connection, usb power or possible bad soldering."
exit
while ! $(ifconfig -a | grep -q $wlan); do
if [ "$n" -ge 5 ]; then
echo "No interface $wlan. Check wifi stick connection, usb power or possible bad soldering."
exit 1
fi
sleep 0.5
n=$(expr ${n} + 1)
n=$(expr $n + 1)
done
}
@ -81,58 +81,58 @@ load_modules() {
}
load_interface() {
if [ ${driver} = "realtek" ]; then
ifconfig ${wlan} up
iwconfig ${wlan} mode monitor
elif [ ${driver} = "atheros" ]; then
iwconfig ${wlan} mode monitor
ifconfig ${wlan} up
if [ "$driver" = "realtek" ]; then
ifconfig $wlan up
iwconfig $wlan mode monitor
elif [ "$driver" = "atheros" ]; then
iwconfig $wlan mode monitor
ifconfig $wlan up
fi
iw reg set ${region}
iw reg set $region
if [ ! -z "${frequency}" ]; then
iwconfig ${wlan} freq ${frequency}
if [ ! -z "$frequency" ]; then
iwconfig $wlan freq $frequency
else
iwconfig ${wlan} channel ${channel}
iwconfig $wlan channel $channel
fi
# 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() {
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} \
-T ${pool_timeout} -i ${link_id} -f ${frame_type} ${wlan} > /dev/null &
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 \
-T $pool_timeout -i $link_id -f $frame_type $wlan > /dev/null &
}
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
start)
if [ ${daemon} -eq 1 ]; then
if [ "$daemon" -eq 1 ]; then
echo "Loading modules and wifi card driver..."
load_modules
echo "Preparing interface wlan..."
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..."
cd ${keydir}; wfb_keygen
cd $keydir; wfb_keygen
else
echo ${unit} "key exist..."
echo $unit "key exist..."
fi
echo "Starting Wifibroadcast service..."
start_${unit}_wfb
echo "Done."
if [ ${telemetry} = "true" ]; then
if [ ${chip} = "gk7205v200" ]; then
if [ "$telemetry" = "true" ]; then
if [ "$chip" = "gk7205v200" ]; then
# UART2_RX mux
devmem 0x120c0010 32 0x1e04
fi