first commit
This commit is contained in:
55
scripts/autoload-wfb-nics.sh
Executable file
55
scripts/autoload-wfb-nics.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Initialize log file and type variables
|
||||
LOG_FILE=""
|
||||
TYPE=""
|
||||
|
||||
# Parse arguments
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--log)
|
||||
LOG_FILE="$2"
|
||||
shift
|
||||
;;
|
||||
--type)
|
||||
TYPE="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown parameter passed: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Initialize an empty string to store matching interface names
|
||||
matching_interfaces=""
|
||||
|
||||
# List all network interfaces and filter only wireless ones
|
||||
for iface in /sys/class/net/*; do
|
||||
iface_name=$(basename $iface)
|
||||
# Check if the interface is wireless and usb
|
||||
if [ -d "/sys/class/net/$iface_name/wireless" ] && [[ "$(readlink -f /sys/class/net/$iface_name/device/subsystem)" == *"usb"* ]]; then
|
||||
# Append the interface name to the list
|
||||
matching_interfaces+="$iface_name "
|
||||
fi
|
||||
done
|
||||
|
||||
# Output the list of matching interfaces as a space-separated string
|
||||
new_wfb_nics="WFB_NICS=\"${matching_interfaces% }\""
|
||||
|
||||
# Read the current contents of /etc/default/wifibroadcast
|
||||
current_wfb_nics=$(cat /etc/default/wifibroadcast 2>/dev/null)
|
||||
|
||||
# Compare and update if different
|
||||
if [[ "$current_wfb_nics" != "$new_wfb_nics" ]]; then
|
||||
echo "$new_wfb_nics" >/etc/default/wifibroadcast
|
||||
systemctl restart wifibroadcast &
|
||||
# Log to file if --log argument was provided
|
||||
if [[ -n "$LOG_FILE" ]]; then
|
||||
echo "$(date) [$TYPE]: Network interface $ACTION $INTERFACE" >>"$LOG_FILE"
|
||||
echo "$(date) [$TYPE]: $new_wfb_nics" >>"$LOG_FILE"
|
||||
echo "$(date) [$TYPE]: Restarting Wifibroadcast service" >>"$LOG_FILE"
|
||||
fi
|
||||
fi
|
||||
1
scripts/rec-fps
Normal file
1
scripts/rec-fps
Normal file
@@ -0,0 +1 @@
|
||||
60
|
||||
1
scripts/screen-mode
Normal file
1
scripts/screen-mode
Normal file
@@ -0,0 +1 @@
|
||||
1280x720@60
|
||||
24
scripts/stream.sh
Executable file
24
scripts/stream.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
DVR_PATH=/media
|
||||
SCREEN_MODE=$(</config/scripts/screen-mode)
|
||||
REC_FPS=$(</config/scripts/rec-fps)
|
||||
|
||||
PID=0
|
||||
BUTTON=21
|
||||
|
||||
#pixelpilot --osd --osd-config /config/config_osd.json --screen-mode $SCREEN_MODE --dvr-framerate $REC_FPS --dvr-fmp4 --dvr-template $DVR_PATH/record_%Y-%m-%d_%H-%M-%S.mp4 &
|
||||
pixelpilot --osd --osd-config /config/config_osd.json --screen-mode $(</config/scripts/screen-mode) --dvr-framerate $(</config/scripts/rec-fps) --dvr-fmp4 --dvr-template $DVR_PATH/record_%Y-%m-%d_%H-%M-%S.mp4
|
||||
|
||||
PID=$!
|
||||
|
||||
while true; do
|
||||
# Wait for button click
|
||||
if [ $(gpio read $BUTTON) -eq 1 ]; then
|
||||
echo "toggle DVR for $PID"
|
||||
kill -SIGUSR1 $PID
|
||||
# wait 2s to let user release the button
|
||||
sleep 2
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
Reference in New Issue
Block a user