Compare commits

...

4 Commits

Author SHA1 Message Date
Tom Alexander
9a27184885
Update router vm scripts. 2024-10-10 19:03:11 -04:00
Tom Alexander
40b0d2c684
An attempt at a merged command. 2024-10-10 18:12:39 -04:00
Tom Alexander
6d0bc958a9
Update cast_file incantations. 2024-10-09 21:09:11 -04:00
Tom Alexander
e38bee4c0f
Use bbr for tcp congestion on FreeBSD, install ectool on framework laptop linux, and assign an ipv6 address in mrmanager. 2024-10-09 19:44:09 -04:00
9 changed files with 211 additions and 91 deletions

View File

@ -0,0 +1 @@
tcp_bbr_load="YES"

View File

@ -148,3 +148,25 @@
block: | block: |
daily_scrub_zfs_enable="YES" daily_scrub_zfs_enable="YES"
daily_scrub_zfs_default_threshold="7" daily_scrub_zfs_default_threshold="7"
# Switch to bbr tcp congestion control which should be better on lossy connections like bad wifi.
- name: Install loader.conf
copy:
src: "files/{{ item }}_loader.conf"
dest: "/boot/loader.conf.d/{{ item }}.conf"
mode: 0644
owner: root
group: wheel
loop:
- bbr
- name: Configure sysctls
sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
state: present
reload: false
sysctl_file: "/etc/sysctl.conf.local"
loop:
- name: net.inet.tcp.functions_default
value: "bbr"

View File

@ -26,6 +26,8 @@ firefox_config:
# Disable battery status, used to track users. # Disable battery status, used to track users.
dom.battery.enabled: false dom.battery.enabled: false
# Disable that websites can get notifications if you copy, paste, or cut something from a web page, and it lets them know which part of the page had been selected. # Disable that websites can get notifications if you copy, paste, or cut something from a web page, and it lets them know which part of the page had been selected.
#
# This breaks copying from BigQuery https://github.com/microsoft/monaco-editor/issues/1540
dom.event.clipboardevents.enabled: false dom.event.clipboardevents.enabled: false
# Isolates all browser identifier sources (e.g. cookies) to the first party domain, with the goal of preventing tracking across different domains. # Isolates all browser identifier sources (e.g. cookies) to the first party domain, with the goal of preventing tracking across different domains.
privacy.firstparty.isolate: true privacy.firstparty.isolate: true

View File

@ -74,3 +74,25 @@
# doas mkdir /tmp/emulated_tpm # doas mkdir /tmp/emulated_tpm
# doas swtpm socket --tpmstate dir=/tmp/emulated_tpm --ctrl type=unixio,path=/tmp/emulated_tpm/swtpm-sock --log level=20 --tpm2 # doas swtpm socket --tpmstate dir=/tmp/emulated_tpm --ctrl type=unixio,path=/tmp/emulated_tpm/swtpm-sock --log level=20 --tpm2
- name: Build aur packages
register: buildaur
become_user: "{{ build_user.name }}"
command: "aurutils-sync --no-view {{ item }}"
args:
creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*"
loop:
- fw-ectool-git
- name: Update cache
when: buildaur.changed
pacman:
name: []
state: present
update_cache: true
- name: Install packages
package:
name:
- fw-ectool-git
state: present

View File

@ -12,12 +12,16 @@ function main {
shift shift
if [ "$cmd" = "copy" ]; then if [ "$cmd" = "copy" ]; then
copy "${@}" copy "${@}"
elif [ "$cmd" = "h264" ]; then elif [ "$cmd" = "av1" ]; then
h264 "${@}" av1 "${@}"
elif [ "$cmd" = "stream_software_h264" ]; then
stream_software_h264 "${@}"
elif [ "$cmd" = "stream_hardware_h264" ]; then
stream_hardware_h264 "${@}"
elif [ "$cmd" = "preprocess_software_h264" ]; then
preprocess_software_h264 "${@}"
elif [ "$cmd" = "preprocess_hardware_h264" ]; then elif [ "$cmd" = "preprocess_hardware_h264" ]; then
preprocess_hardware_h264 "${@}" preprocess_hardware_h264 "${@}"
elif [ "$cmd" = "software_h264" ]; then
software_h264 "${@}"
elif [ "$cmd" = "vp9" ]; then elif [ "$cmd" = "vp9" ]; then
vp9 "${@}" vp9 "${@}"
elif [ "$cmd" = "preprocess_hardware_vp9" ]; then elif [ "$cmd" = "preprocess_hardware_vp9" ]; then
@ -60,7 +64,71 @@ function copy {
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch" "rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
} }
function h264 {
function av1 {
# local additional_flags=()
# additional_flags+=(--profile "$PROFILE")
# (cd "$DIR/../" && cargo build --no-default-features "${additional_flags[@]}")
local destination_type="$1" # "stream" or "preprocess"
local acceleration_type="$2" # "software" or "hardware"
# shift 2
local args=()
if [ "$destination_type" == "stream" ]; then
args+=(-re -stream_loop -1)
elif [ "$destination_type" == "preproces" ]; then
true
else
(>&2 echo "Unknown destination type: $destination_type")
exit 1
fi
if [ "$acceleration_type" == "software" ]; then
true
elif [ "$acceleration_type" == "hardware" ]; then
args+=(-vaapi_device /dev/dri/renderD128)
else
(>&2 echo "Unknown acceleration type: $acceleration_type")
exit 1
fi
args+=(-i "$file_to_cast")
if [ "$acceleration_type" == "software" ]; then
args+=(-c:v h264)
elif [ "$acceleration_type" == "hardware" ]; then
args+=(-vf 'format=nv12|vaapi,hwupload')
args+=(-c:v h264_vaapi)
else
(>&2 echo "Unknown acceleration type: $acceleration_type")
exit 1
fi
args+=(-b:v 2M)
args+=(-profile:v high)
args+=(-bf 0)
args+=(-strict -2)
args+=(-c:a opus)
args+=(-ac 2)
args+=(-b:a 320k)
args+=(-ar 48000)
if [ "$destination_type" == "stream" ]; then
args+=(-f rtsp)
args+=(-rtsp_transport tcp)
args+=("rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch")
elif [ "$destination_type" == "preproces" ]; then
args+=("$file_to_save")
else
(>&2 echo "Unknown destination type: $destination_type")
exit 1
fi
}
function stream_software_h264 {
local file_to_cast local file_to_cast
file_to_cast="$3" file_to_cast="$3"
@ -74,17 +142,14 @@ function h264 {
</dev/null exec ffmpeg \ </dev/null exec ffmpeg \
-re \ -re \
-stream_loop -1 \ -stream_loop -1 \
-init_hw_device vaapi=foo:/dev/dri/renderD128 \
-hwaccel vaapi \
-hwaccel_output_format vaapi \
-hwaccel_device foo \
-i "$file_to_cast" \ -i "$file_to_cast" \
-filter_hw_device foo \ -c:v h264 \
-vf 'format=nv12|vaapi,hwupload' \ -b:v 2M \
-c:v h264_vaapi \ -profile:v high \
-bf 0 \ -bf 0 \
-strict -2 \ -strict -2 \
-c:a opus \ -c:a opus \
-ac 2 \
-b:a 320k \ -b:a 320k \
-ar 48000 \ -ar 48000 \
-f rtsp \ -f rtsp \
@ -92,7 +157,38 @@ function h264 {
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch" "rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
} }
function preprocess_hardware_h264 { function stream_hardware_h264 {
local file_to_cast
file_to_cast="$3"
local USERNAME PASSWORD
USERNAME="$1"
PASSWORD="$2"
set -x
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \
-re \
-stream_loop -1 \
-vaapi_device /dev/dri/renderD128 \
-i "$file_to_cast" \
-vf 'format=nv12|vaapi,hwupload' \
-c:v h264_vaapi \
-b:v 2M \
-profile:v high \
-bf 0 \
-strict -2 \
-c:a opus \
-ac 2 \
-b:a 320k \
-ar 48000 \
-f rtsp \
-rtsp_transport tcp \
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
}
function preprocess_software_h264 {
local file_to_cast file_to_save local file_to_cast file_to_save
file_to_cast="$1" file_to_cast="$1"
file_to_save="$2" file_to_save="$2"
@ -101,14 +197,8 @@ function preprocess_hardware_h264 {
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames. # -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \ </dev/null exec ffmpeg \
-init_hw_device vaapi=foo:/dev/dri/renderD128 \
-hwaccel vaapi \
-hwaccel_output_format vaapi \
-hwaccel_device foo \
-i "$file_to_cast" \ -i "$file_to_cast" \
-filter_hw_device foo \ -c:v h264 \
-vf 'format=nv12|vaapi,hwupload' \
-c:v h264_vaapi \
-b:v 2M \ -b:v 2M \
-profile:v high \ -profile:v high \
-bf 0 \ -bf 0 \
@ -120,32 +210,7 @@ function preprocess_hardware_h264 {
"$file_to_save" "$file_to_save"
} }
function software_h264 { function preprocess_hardware_h264 {
local file_to_cast
file_to_cast="$3"
local USERNAME PASSWORD
USERNAME="$1"
PASSWORD="$2"
set -x
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \
-re \
-stream_loop -1 \
-i "$file_to_cast" \
-c:v h264 \
-bf 0 \
-c:a opus \
-b:a 320k \
-ar 48000 \
-f rtsp \
-rtsp_transport tcp \
"rtsp://$USERNAME:$PASSWORD@172.16.16.251:8554/fetch"
}
function preprocess_h264 {
local file_to_cast file_to_save local file_to_cast file_to_save
file_to_cast="$1" file_to_cast="$1"
file_to_save="$2" file_to_save="$2"
@ -154,10 +219,16 @@ function preprocess_h264 {
# -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames. # -bf 0 :: Disable b-frames because webrtc doesn't support h264 streams with b-frames.
</dev/null exec ffmpeg \ </dev/null exec ffmpeg \
-vaapi_device /dev/dri/renderD128 \
-i "$file_to_cast" \ -i "$file_to_cast" \
-c:v h264 \ -vf 'format=nv12,hwupload' \
-c:v h264_vaapi \
-b:v 2M \
-profile:v high \
-bf 0 \ -bf 0 \
-strict -2 \
-c:a opus \ -c:a opus \
-ac 2 \
-b:a 320k \ -b:a 320k \
-ar 48000 \ -ar 48000 \
"$file_to_save" "$file_to_save"

View File

@ -3,4 +3,5 @@ ifconfig_igb0="up"
ifconfig_igb1="up" ifconfig_igb1="up"
ifconfig_lagg0="up laggproto failover laggport igb0 laggport igb1" ifconfig_lagg0="up laggproto failover laggport igb0 laggport igb1"
ifconfig_lagg0_alias0="inet 74.80.180.138 netmask 255.255.255.248" ifconfig_lagg0_alias0="inet 74.80.180.138 netmask 255.255.255.248"
ifconfig_lagg0_alias1="inet6 2620:11f:7001:7::2/64" ifconfig_lagg0_ipv6="inet6 2620:11f:7001:7::2/64"
ifconfig_lagg0_alias1="inet6 2620:11f:7001:7::3 prefixlen 64"

View File

@ -19,7 +19,7 @@ function cleanup {
done done
} }
vms=() vms=()
for sig in EXIT INT QUIT HUP TERM; do for sig in EXIT; do
trap "set +e; sleep 10; cleanup" "$sig" trap "set +e; sleep 10; cleanup" "$sig"
done done
@ -67,17 +67,17 @@ function start_vm {
local bridge_link_name local bridge_link_name
bridge_link_name=$(detect_available_link "${bridge_name}") bridge_link_name=$(detect_available_link "${bridge_name}")
# additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}") additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}")
additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}" "-s" "3,ahci-cd,/home/talexander/disk.iso") # additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}" "-s" "3,ahci-cd,/home/talexander/disk.iso")
# -H \
vms+=("$name") vms+=("$name")
while true; do while true; do
set -x set -x
set +e set +e
bhyve \ bhyve \
-D \ -D \
-c 1 \ -c 2 \
-m 3G \ -m 3G \
-H \
-o 'rtc.use_localtime=false' \ -o 'rtc.use_localtime=false' \
-s 0,hostbridge \ -s 0,hostbridge \
-s "4,nvme,/dev/zvol/zroot/vm/mediamtx/disk0" \ -s "4,nvme,/dev/zvol/zroot/vm/mediamtx/disk0" \

View File

@ -19,7 +19,7 @@ function cleanup {
done done
} }
vms=() vms=()
for sig in EXIT INT QUIT HUP TERM; do for sig in EXIT; do
trap "set +e; sleep 10; cleanup" "$sig" trap "set +e; sleep 10; cleanup" "$sig"
done done

View File

@ -19,7 +19,7 @@ function cleanup {
done done
} }
vms=() vms=()
for sig in EXIT INT QUIT HUP TERM; do for sig in EXIT; do
trap "set +e; sleep 10; cleanup" "$sig" trap "set +e; sleep 10; cleanup" "$sig"
done done
@ -68,6 +68,7 @@ function start_vm {
bridge_link_name=$(detect_available_link "${bridge_name}") bridge_link_name=$(detect_available_link "${bridge_name}")
additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}") additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}")
# additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}" "-s" "3,ahci-cd,/home/talexander/disk.iso")
vms+=("$name") vms+=("$name")
while true; do while true; do
set -x set -x