84 Commits

Author SHA1 Message Date
Tom Alexander
9bc3aed323 Add ndproxy to support neighbor discovery of VMs from the public internet. 2025-12-07 14:31:15 -05:00
Tom Alexander
613204d9fa Enable ipv6 cluster in the firewall. 2025-12-07 14:19:24 -05:00
Tom Alexander
c23a99bd41 Add support for multiple 9p directories. 2025-12-07 10:32:56 -05:00
Tom Alexander
32d276c467 Add IP allocations for new nix-based kubernetes cluster. 2025-11-30 19:50:45 -05:00
Tom Alexander
6e14356a13 Enable type-checking by default in vscode for python. 2025-11-30 19:17:49 -05:00
Tom Alexander
c5e7b983ec Disable 6ghz.
Currently, I get a lot of dropped packets on 6ghz. I suspect it is a bug in the drivers/firmware.
2025-09-28 20:57:32 -04:00
Tom Alexander
25957105c9 Add support for preventing OOM kill on certain VMs. 2025-09-27 19:02:06 -04:00
Tom Alexander
daaf427286 Update to the new GPG key. 2025-09-23 19:51:38 -04:00
Tom Alexander
c96c4d3ddb Unbind shift+enter to stop unintentionally running python code. 2025-09-19 10:04:09 -04:00
Tom Alexander
b72fa0edff Disable AI firefox stuff. 2025-09-19 10:03:24 -04:00
Tom Alexander
052c051c75 Switch to abm level 2.
Recent kernels have made the screen dimmer. Switching to ABM level 2 has compensated for that.
2025-09-16 17:57:53 -04:00
Tom Alexander
79a2ec6f53 Add rg jail. 2025-09-07 15:37:29 -04:00
Tom Alexander
7c506f9e7f Add d2. 2025-09-07 15:11:11 -04:00
Tom Alexander
40dc19eaea Disable nfsd. 2025-08-31 19:58:39 -04:00
Tom Alexander
2aec6d2411 Add support for mounting a host directory into the VM via virtio-9p. 2025-08-30 16:53:03 -04:00
Tom Alexander
97149b9196 Fix firewall blocking to host machine.
The firewall was not working so all traffic was making it through to the host system.
2025-08-30 15:07:57 -04:00
Tom Alexander
4633a97262 Wire memory in router VMs. 2025-08-27 20:16:06 -04:00
Tom Alexander
9ff8835e0a Scope back navigation to the editor. 2025-08-27 16:51:51 -04:00
Tom Alexander
2f07067bda Merge branch 'bhyve_rc' 2025-08-26 22:30:21 -04:00
Tom Alexander
2d94825d17 Add timeouts. 2025-08-26 22:29:59 -04:00
Tom Alexander
d1c6e358d4 Update vscode config. 2025-08-26 22:29:58 -04:00
Tom Alexander
54060aada6 Add delay between starts. 2025-08-26 22:29:58 -04:00
Tom Alexander
313c159a3e Integrate code to launch the VMs. 2025-08-26 22:29:58 -04:00
Tom Alexander
187a7aebe9 Add a bhyverc script using pidfiles. 2025-08-26 22:29:58 -04:00
Tom Alexander
ab246f61dd Add speech-dispatcher for text to speech in firefox. 2025-08-23 16:23:22 -04:00
Tom Alexander
04c991e775 Enable hardware accelerated encoding in chromium. 2025-08-09 13:30:31 -04:00
Tom Alexander
ca1a569013 Static ip address for certificate renewals on home server. 2025-05-24 18:28:12 -04:00
Tom Alexander
6578d64b50 Format typescript on save in vscode. 2025-05-19 16:27:00 -04:00
Tom Alexander
22cf52d490 Fix screen scaling during screen sharing. 2025-04-01 13:41:07 -04:00
Tom Alexander
5b276081d1 Forward port to hydra ssh. 2025-03-23 20:41:52 -04:00
Tom Alexander
ff1217c65d Add hydra IP address binding. 2025-03-23 16:54:56 -04:00
Tom Alexander
9319fc4bc5 Add DMARC record to domain. 2025-03-08 13:34:27 -05:00
Tom Alexander
b1bea7224f Integrate some git config suggestions from https://blog.gitbutler.com/how-git-core-devs-configure-git/ . 2025-02-26 13:29:44 -05:00
Tom Alexander
28b61ff95a Show the project on the mode line in emacs. 2025-02-24 14:04:41 -05:00
Tom Alexander
abf5f81d21 Do not show window borders when it is the only window on the workspace. 2025-02-24 12:19:22 -05:00
Tom Alexander
d9150880d3 Fix org-mode shift-arrow keys and add cmake support. 2025-02-24 12:17:32 -05:00
Tom Alexander
515e910487 Switch back to LTS kernel. 2025-02-24 12:15:37 -05:00
Tom Alexander
e2f8696ed6 Move the window title to the center. 2024-12-16 23:00:50 -05:00
Tom Alexander
3bd4f15fe1 Add window title to waybar. 2024-12-16 22:43:10 -05:00
Tom Alexander
157471952a Get rid of window title bars. 2024-12-16 18:18:18 -05:00
Tom Alexander
a555876a7e Sort icons. 2024-12-13 23:06:54 -05:00
Tom Alexander
3116d34994 Add nix support to emacs. 2024-11-29 21:27:08 -05:00
Tom Alexander
5c823f3353 Try a convert vs stream function instead for video conversion. 2024-11-17 21:29:42 -05:00
Tom Alexander
c2f1a0db1c Merge branch 'template_linfi' 2024-10-21 18:10:49 -04:00
Tom Alexander
c0c12b9eea Hard-code my wifi regulatory domain to US. 2024-10-21 18:10:39 -04:00
Tom Alexander
d2ff39b5e6 Move my home server over to linfi. 2024-10-21 18:10:39 -04:00
Tom Alexander
e9e6e141d2 Switch to av1 for screen recording. 2024-10-14 18:18:20 -04:00
Tom Alexander
d2c1f5c94f Disable pf so fileserver doesn't go dark accidentally. 2024-10-14 18:18:20 -04:00
Tom Alexander
cd0208f3fc Add a script to get the next hop in a route.
I never remember the incantation, and its slightly different between FreeBSD and Linux so I am adding this script essentially as a note.
2024-10-13 22:02:59 -04:00
Tom Alexander
9d6ddfd1bd Merge branch 'linfi' 2024-10-13 20:48:29 -04:00
Tom Alexander
117769d1ab Set up a linux VM for running wifi. 2024-10-13 20:45:33 -04:00
Tom Alexander
91a138ab9d Add my custom ports. 2024-10-12 13:17:02 -04:00
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
Tom Alexander
5a08b3e0bd Update command to route private kubernetes services. 2024-10-06 21:34:12 -04:00
Tom Alexander
acf4951047 Update custom ports location. 2024-10-06 17:32:07 -04:00
Tom Alexander
9413f5dce8 Optimize Go programs and add IPv6 to mrmanager. 2024-10-06 17:32:06 -04:00
Tom Alexander
913d2e9f15 Fix certificates for bastion. 2024-10-04 21:22:55 -04:00
Tom Alexander
bb66c9a907 Update rust. 2024-09-30 19:17:30 -04:00
Tom Alexander
5331552759 Enable cranelift on linux for compiling rust faster.
This is based on https://bjorn3.github.io/2023/10/31/progress-report-oct-2023.html.
2024-09-29 22:16:12 -04:00
Tom Alexander
8e5034a393 Add a test for the freezing display issue. 2024-09-29 03:59:55 -04:00
Tom Alexander
14fa62c64a Add a role to configure chromium to run on Vulkan. 2024-09-24 22:22:13 -04:00
Tom Alexander
15d65c3f21 Adjust network ttl. 2024-09-12 14:47:17 -04:00
Tom Alexander
00bbded91c libclc does not have a znver4 because its based on llvm 15. 2024-09-06 11:52:56 -04:00
Tom Alexander
c58257538a Zoom in when screen sharing. 2024-09-03 19:32:42 -04:00
Tom Alexander
e2a434bde0 Update keyboard layout. 2024-08-28 18:20:34 -04:00
Tom Alexander
077155f835 Add windows vm to FreeBSD on laptop. 2024-08-28 18:20:33 -04:00
Tom Alexander
aec97a5df6 Add jail for momlaptop. 2024-08-17 19:30:14 -04:00
Tom Alexander
20768edcf6 Fix night mode signal handling.
Now the script works on both FreeBSD and Linux, and it exits properly so switching between docked and undocked doesn't cause problems for waybar.
2024-08-13 20:14:09 -04:00
Tom Alexander
8175cf443a Set up zsh on poudriere.
This is to save a better command history.
2024-08-11 12:56:35 -04:00
Tom Alexander
075a768424 Remove igt-gpu-tools.
This depends on oping which has been failing to build for a while.
2024-08-10 11:19:41 -04:00
Tom Alexander
621625d831 Tint the screen at night. 2024-07-28 15:03:57 -04:00
Tom Alexander
3a63d4d307 Fix firefox fingerprint protection. 2024-07-21 11:25:51 -04:00
Tom Alexander
1e47ff3f64 Add more streaming commands. 2024-07-18 23:29:07 -04:00
Tom Alexander
31bf399b51 Switch to tcp streaming. 2024-07-17 19:46:43 -04:00
Tom Alexander
9029508c58 Fix dark mode in firefox. 2024-07-16 20:13:20 -04:00
Tom Alexander
22d90ae79b Simplify iwd conf. 2024-07-15 19:26:14 -04:00
Tom Alexander
6420db5385 Pipe not working. 2024-07-14 12:18:59 -04:00
Tom Alexander
0a4ee7b7f6 Support different vnc resolutions in bhyve. 2024-07-14 12:18:58 -04:00
Tom Alexander
5d1c1e2e19 Switch to manual dummynet rc.d implementation.
The existing one does not seem to work.
2024-07-13 14:05:14 -04:00
Tom Alexander
043061fb16 Switch to opus for streaming. 2024-07-13 13:51:49 -04:00
Tom Alexander
076b8d296f Add software vp8 live cast. 2024-07-13 13:15:04 -04:00
178 changed files with 3535 additions and 484 deletions

View File

@@ -14,6 +14,8 @@ pf_config: "mrmanager_pf.conf"
pflog_conf: pflog_conf:
- name: 0 - name: 0
dev: pflog0 dev: pflog0
- name: 1
dev: pflog1
cputype: "amd" cputype: "amd"
hwpstate: true hwpstate: true
etc_hosts: {} etc_hosts: {}
@@ -36,6 +38,10 @@ jail_list:
enabled: true enabled: true
conf: conf:
src: public_dns src: public_dns
- name: rg
enabled: true
conf:
src: rg
bhyve_dataset: zdata/vm bhyve_dataset: zdata/vm
bhyve_canmount: "on" bhyve_canmount: "on"
# efi_dev: /dev/gpt/EFI # efi_dev: /dev/gpt/EFI

View File

@@ -67,6 +67,9 @@ jail_list:
- name: certificate - name: certificate
conf: conf:
src: certificate src: certificate
- name: momlaptop
conf:
src: momlaptop
# - name: mumble # - name: mumble
# conf: # conf:
# src: mumble # src: mumble
@@ -74,9 +77,17 @@ jail_list:
# - name: mumbledb # - name: mumbledb
# mount: /var/db/murmur # mount: /var/db/murmur
bhyve_dataset: zmass/encrypted/vm bhyve_dataset: zmass/encrypted/vm
bhyve_list: [] # Disable mounting bhyve dataset so it doesn't hide the unencrypted linfi vm
bhyve_canmount: "on" bhyve_canmount: "off"
bhyve_mountpoint: "none"
bhyve_bemount: "on" bhyve_bemount: "on"
wireguard_directory: homeserver wireguard_directory: homeserver
enabled_wireguard: enabled_wireguard:
- wgh - wgh
linfi:
enabled: true
zfs_dataset: zmass/unencrypted/vm/linfi
zfs_mountpoint: /vm/linfi
driver_blocklist: "ath if_ath if_ath_pci ath_hal if_iwm if_iwlwifi"
pci_blocklist: "6/0/0"
amd: false

View File

@@ -1,2 +1,2 @@
[headless] [headless]
homeserver ansible_user=talexander ansible_host=10.216.1.1 homeserver ansible_user=talexander ansible_host=homeserver

View File

@@ -0,0 +1 @@
os_flavor: freebsd

View File

@@ -8,3 +8,4 @@ public_dns ansible_ssh_host=public_dns@10.217.2.1 ansible_connection=sshjail
sftp ansible_ssh_host=sftp@homeserver ansible_connection=sshjail sftp ansible_ssh_host=sftp@homeserver ansible_connection=sshjail
bastion ansible_ssh_host=bastion@homeserver ansible_connection=sshjail bastion ansible_ssh_host=bastion@homeserver ansible_connection=sshjail
certificate ansible_ssh_host=certificate@homeserver ansible_connection=sshjail certificate ansible_ssh_host=certificate@homeserver ansible_connection=sshjail
momlaptop ansible_ssh_host=momlaptop@homeserver ansible_connection=sshjail

View File

@@ -49,7 +49,7 @@ jail_list:
conf: conf:
src: nat_dhcp src: nat_dhcp
bhyve_dataset: zroot/freebsd/current/vm bhyve_dataset: zroot/freebsd/current/vm
bhyve_list: [] bhyve_bemount: off
# efi_dev: /dev/gpt/EFI # efi_dev: /dev/gpt/EFI
efi_dev: /dev/diskid/DISK-SJB7N717610407Q0Hp1 efi_dev: /dev/diskid/DISK-SJB7N717610407Q0Hp1
sway_conf_files: sway_conf_files:
@@ -59,3 +59,10 @@ enabled_wireguard:
- wgh - wgh
- drmario - drmario
- colo - colo
linfi:
enabled: true
zfs_dataset: zroot/freebsd/current/vm/linfi
zfs_mountpoint: /vm/linfi
driver_blocklist: "if_iwm if_iwlwifi"
pci_blocklist: "1/0/0"
amd: true

View File

@@ -1,4 +1,5 @@
os_flavor: "freebsd" os_flavor: "freebsd"
sshd_enabled: true
custom_repo: "file:///usr/local/poudriere/data/packages/currentznver4-default-framework" custom_repo: "file:///usr/local/poudriere/data/packages/currentznver4-default-framework"
pkgbase_url: "file:///usr/local/poudriere/data/images/currentznver4-repo/FreeBSD:15:amd64/latest" pkgbase_url: "file:///usr/local/poudriere/data/images/currentznver4-repo/FreeBSD:15:amd64/latest"
poudriere_builds: poudriere_builds:

View File

@@ -27,6 +27,7 @@
- sway - sway
- emacs - emacs
- firefox - firefox
- chromium
- devfs - devfs
- ssh_client - ssh_client
- sshfs - sshfs
@@ -52,7 +53,7 @@
- javascript - javascript
- launch_keyboard - launch_keyboard
- lvfs - lvfs
- restaurant_health_rating # - restaurant_health_rating
- wasm - wasm
- noise_suppression - noise_suppression
@@ -67,9 +68,12 @@
ansible_become: True ansible_become: True
roles: roles:
- sudo # for poudboot script - sudo # for poudboot script
- doas
- fstab - fstab
- package_manager - package_manager
- zsh
- termcap - termcap
- sshd
- portshaker - portshaker
- poudriere - poudriere
- poudrierenginx - poudrierenginx
@@ -100,6 +104,7 @@
- wireguard - wireguard
- emacs - emacs
- mrmanager - mrmanager
- ndproxy
- hosts: admin_git:public_dns - hosts: admin_git:public_dns
vars: vars:
@@ -122,12 +127,14 @@
vars: vars:
ansible_become: True ansible_become: True
roles: roles:
- linfi
- framework_laptop - framework_laptop
- hosts: homeserver - hosts: homeserver
vars: vars:
ansible_become: True ansible_become: True
roles: roles:
- linfi
- homeserver - homeserver
- hosts: odowork - hosts: odowork
@@ -154,3 +161,9 @@
ansible_become: True ansible_become: True
roles: roles:
- jail_certificate - jail_certificate
- hosts: momlaptop
vars:
ansible_become: True
roles:
- jail_momlaptop

View File

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

View File

@@ -1,35 +1,54 @@
[user] [user]
email = tom@fizz.buzz email = tom@fizz.buzz
name = Tom Alexander name = Tom Alexander
signingkey = D3A179C9A53C0EDE signingkey = 36C99E8B3C39D85F
[push] [push]
default = simple default = simple # (default since 2.0)
[alias] [alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
bh = log --oneline --branches=* --remotes=* --graph --decorate bh = log --oneline --branches=* --remotes=* --graph --decorate
amend = commit --amend --no-edit amend = commit --amend --no-edit
authorcount = shortlog --summary --numbered --all --no-merges
[core] [core]
excludesfile = ~/.gitignore_global excludesfile = ~/.gitignore_global
[commit] [commit]
gpgsign = true gpgsign = true
verbose = true
[pull] [pull]
rebase = true rebase = true
[log] [log]
date = local date = local
[init] [init]
defaultBranch = main defaultBranch = main
# Use meld for `git difftool` and `git mergetool`
[diff] [diff]
tool = meld tool = meld # Use meld for `git difftool` and `git mergetool`
algorithm = histogram
colorMoved = plain
mnemonicPrefix = true
renames = true
[difftool] [difftool]
prompt = false prompt = false
[difftool "meld"] [difftool "meld"]
cmd = meld "$LOCAL" "$REMOTE" cmd = meld "$LOCAL" "$REMOTE"
[merge] [merge]
tool = meld tool = meld
conflictStyle = zdiff3
[mergetool "meld"] [mergetool "meld"]
# Make the middle pane start with partially-merged contents: # Make the middle pane start with partially-merged contents:
cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED" cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
# Make the middle pane start without any merge progress: # Make the middle pane start without any merge progress:
# cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED" # cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"
[column]
ui = auto
[branch]
sort = -committerdate
[tag]
sort = version:refname
[fetch]
prune = true
pruneTags = true
all = true
[rebase]
autoSquash = true
autoStash = true
updateRefs = false

View File

@@ -1,33 +1,38 @@
[user] [user]
email = ThomasA.Alexander@hmhn.org email = ThomasA.Alexander@hmhn.org
name = Tom Alexander name = Tom Alexander
signingkey = D3A179C9A53C0EDE signingkey = 36C99E8B3C39D85F
[push] [push]
default = simple default = simple # (default since 2.0)
[alias] [alias]
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
bh = log --oneline --branches=* --remotes=* --graph --decorate bh = log --oneline --branches=* --remotes=* --graph --decorate
amend = commit --amend --no-edit amend = commit --amend --no-edit
authorcount = shortlog --summary --numbered --all --no-merges
[core] [core]
excludesfile = ~/.gitignore_global excludesfile = ~/.gitignore_global
[commit] [commit]
gpgsign = true gpgsign = true
verbose = true
[pull] [pull]
rebase = true rebase = true
[log] [log]
date = local date = local
[init] [init]
defaultBranch = main defaultBranch = main
# Use meld for `git difftool` and `git mergetool`
[diff] [diff]
tool = meld tool = meld # Use meld for `git difftool` and `git mergetool`
algorithm = histogram
colorMoved = plain
mnemonicPrefix = true
renames = true
[difftool] [difftool]
prompt = false prompt = false
[difftool "meld"] [difftool "meld"]
cmd = meld "$LOCAL" "$REMOTE" cmd = meld "$LOCAL" "$REMOTE"
[merge] [merge]
tool = meld tool = meld
conflictStyle = zdiff3
[mergetool "meld"] [mergetool "meld"]
# Make the middle pane start with partially-merged contents: # Make the middle pane start with partially-merged contents:
cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED" cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
@@ -35,3 +40,19 @@
# cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED" # cmd = meld "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"
[includeIf "gitdir:/bridge/"] [includeIf "gitdir:/bridge/"]
path = /bridge/git/machine_setup/ansible/roles/base/files/gitconfig_home path = /bridge/git/machine_setup/ansible/roles/base/files/gitconfig_home
[includeIf "gitdir:/persist/"]
path = /bridge/git/machine_setup/ansible/roles/base/files/gitconfig_home
[column]
ui = auto
[branch]
sort = -committerdate
[tag]
sort = version:refname
[fetch]
prune = true
pruneTags = true
all = true
[rebase]
autoSquash = true
autoStash = true
updateRefs = false

View File

@@ -44,6 +44,7 @@ default:\
:pseudoterminals=unlimited:\ :pseudoterminals=unlimited:\
:kqueues=unlimited:\ :kqueues=unlimited:\
:umtxp=unlimited:\ :umtxp=unlimited:\
:pipebuf=unlimited:\
:priority=0:\ :priority=0:\
:ignoretime@:\ :ignoretime@:\
:umask=022:\ :umask=022:\

View File

@@ -10,7 +10,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function cleanup { function cleanup {
switch_to_main_screen switch_to_main_screen
} }
for sig in EXIT INT QUIT HUP TERM; do for sig in EXIT; do
trap "set +e; cleanup; exit" "$sig" trap "set +e; cleanup; exit" "$sig"
done done

View File

@@ -19,6 +19,7 @@
- tcpdump - tcpdump
- moreutils # for ts [%Y-%m-%d %H:%M:%.S] - moreutils # for ts [%Y-%m-%d %H:%M:%.S]
- ddrescue - ddrescue
- dmidecode
state: present state: present
- name: Install packages - name: Install packages

View File

@@ -13,6 +13,7 @@
- gsed - gsed
- gmake - gmake
- rust-coreutils - rust-coreutils
- shuf
state: present state: present
- name: Install service configuration - name: Install service configuration
@@ -38,18 +39,6 @@
command: cap_mkdb /etc/login.conf command: cap_mkdb /etc/login.conf
when: login_config.changed when: login_config.changed
- name: Enable periodic scrub
community.general.sysrc:
name: daily_scrub_zfs_enable
value: "YES"
path: /etc/periodic.conf.local
- name: Set scrub interval
community.general.sysrc:
name: daily_scrub_zfs_default_threshold
value: "7"
path: /etc/periodic.conf.local
- name: Install loader.conf - name: Install loader.conf
copy: copy:
src: "{{loader_conf}}" src: "{{loader_conf}}"
@@ -119,3 +108,65 @@
group: wheel group: wheel
loop: loop:
- disk_labels - disk_labels
- name: Configure sysctls
sysctl:
name: "{{ item.name }}"
value: "{{ item.value }}"
state: present
reload: false
sysctl_file: "/etc/sysctl.conf.local"
loop:
# Adjust ttl
- name: net.inet.ip.ttl
value: 65
- name: net.inet6.ip6.hlim
value: 65
- name: Log periodic output instead of getting it as mail
blockinfile:
path: "/etc/periodic.conf.local"
marker: "# {mark} ANSIBLE MANAGED BLOCK log"
# create: true
mode: 0644
owner: root
group: wheel
block: |
daily_output=/var/log/daily.log
weekly_output=/var/log/weekly.log
monthly_output=/var/log/monthly.log
- name: Enable periodic zfs scrub
when: install_zfs
blockinfile:
path: "/etc/periodic.conf.local"
marker: "# {mark} ANSIBLE MANAGED BLOCK zfs"
# create: true
mode: 0644
owner: root
group: wheel
block: |
daily_scrub_zfs_enable="YES"
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

@@ -67,3 +67,13 @@
- name: vm.dirty_writeback_centisecs - name: vm.dirty_writeback_centisecs
value: 1500 value: 1500
file: power.conf file: power.conf
# Adjust ttl
- name: net.ipv4.ip_default_ttl
value: 65
file: ttl.conf
- name: net.ipv6.conf.all.hop_limit
value: 65
file: ttl.conf
- name: net.ipv6.conf.default.hop_limit
value: 65
file: ttl.conf

View File

@@ -1,2 +1 @@
bhyve_mountpoint: "/vm" bhyve_mountpoint: "/vm"
bhyve_list: []

View File

@@ -30,6 +30,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
: ${BRIDGE_NAME:="bridge_$INTERFACE_NAME"} # or bridge_raw for RAW networks : ${BRIDGE_NAME:="bridge_$INTERFACE_NAME"} # or bridge_raw for RAW networks
: ${VNC_ENABLE:="NO"} : ${VNC_ENABLE:="NO"}
: ${VNC_LISTEN:="127.0.0.1:5900"} : ${VNC_LISTEN:="127.0.0.1:5900"}
: ${VNC_WIDTH:="1920"}
: ${VNC_HEIGHT:="1080"}
if [ "$VERBOSE" = "YES" ]; then if [ "$VERBOSE" = "YES" ]; then
set -x set -x
@@ -45,7 +47,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
@@ -141,7 +143,7 @@ function start_vm {
additional_args+=("-s" "5,ahci-cd,$mount_cd") additional_args+=("-s" "5,ahci-cd,$mount_cd")
fi fi
if [ "$VNC_ENABLE" = "YES" ]; then if [ "$VNC_ENABLE" = "YES" ]; then
additional_args+=("-s" "29,fbuf,tcp=$VNC_LISTEN,w=1920,h=1080") additional_args+=("-s" "29,fbuf,tcp=$VNC_LISTEN,w=$VNC_WIDTH,h=$VNC_HEIGHT")
fi fi
vms+=("$name") vms+=("$name")
while true; do while true; do
@@ -151,7 +153,10 @@ function start_vm {
-D \ -D \
-c $CPU_CORES \ -c $CPU_CORES \
-m $MEMORY \ -m $MEMORY \
-S \
-H \ -H \
-P \
-o 'rtc.use_localtime=false' \
-s 0,hostbridge \ -s 0,hostbridge \
-s "4,nvme,/dev/zvol/${zfs_path}/disk0" \ -s "4,nvme,/dev/zvol/${zfs_path}/disk0" \
-s 30,xhci,tablet \ -s 30,xhci,tablet \
@@ -212,7 +217,7 @@ EOF
mkpeer ${host_interface_name}: bridge ether link0 mkpeer ${host_interface_name}: bridge ether link0
name ${host_interface_name}:ether $bridge_name name ${host_interface_name}:ether $bridge_name
EOF EOF
ifconfig $(ngctl msg "${host_interface_name}:" getifname | grep Args | cut -d '"' -f 2) name "${host_interface_name}" "$ip_range" up ifconfig "$(ngctl msg "${host_interface_name}:" getifname | grep Args | cut -d '"' -f 2)" name "${host_interface_name}" "$ip_range" up
fi fi
} }

View File

@@ -0,0 +1,478 @@
#!/usr/bin/env bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Share a host directory to the guest via 9pfs.
#
# Inside the VM run:
# mount -t virtfs -o trans=virtio sharename /some/vm/path
# mount -t 9p -o cache=mmap -o msize=512000 sharename /mnt/9p
# mount -t 9p -o trans=virtio,cache=mmap,msize=512000 bind9p /path/to/mountpoint
# bhyve_options="-s 28,virtio-9p,sharename=/"
# Enable Sound
# bhyve_options="-s 16,hda,play=/dev/dsp,rec=/dev/dsp"
# Example usage:
#
# doas bhyverc create-disk zdata/vm/poudriere /vm/poudriere 10
# doas bhyverc start poudriere zdata/vm/poudriere /vm/poudriere /vm/iso/FreeBSD-13.2-RELEASE-amd64-bootonly.iso
# doas bhyverc start poudriere zdata/vm/poudriere /vm/poudriere
: ${VERBOSE:="NO"} # or YES
if [ "$VERBOSE" = "YES" ]; then
set -x
fi
: ${CPU_CORES:="1"}
: ${MEMORY:="1G"}
: ${NETWORK:="NAT"} # or RAW or BOTH
: ${IP_RANGE:="10.215.1.1/24"} # Ignored for RAW networks
: ${INTERFACE_NAME:="jail_nat"} # or the external interface like lagg0 for RAW networks
: ${BRIDGE_NAME:="bridge_$INTERFACE_NAME"} # or bridge_raw for RAW networks
: ${VNC_ENABLE:="NO"}
: ${VNC_LISTEN:="127.0.0.1:5900"}
: ${VNC_WIDTH:="1920"}
: ${VNC_HEIGHT:="1080"}
: ${BIND9P:=""}
: ${PREVENT_OOM:="NO"}
: "${CD:=}"
: ${SHUTDOWN_TIMEOUT:="600"} # 10 minutes
############## Setup #########################
function die {
local status_code="$1"
shift
(>&2 echo "${@}")
exit "$status_code"
}
function log {
(>&2 echo "${@}")
}
############## Program #########################
function main {
local cmd
cmd=$1
shift
if [ "$cmd" = "start" ]; then
init
start "${@}"
elif [ "$cmd" = "stop" ]; then
init
stop "${@}"
elif [ "$cmd" = "status" ]; then
init
status "${@}"
elif [ "$cmd" = "console" ]; then
init
console "${@}"
elif [ "$cmd" = "_start_body" ]; then
init
start_body "${@}"
elif [ "$cmd" = "create-disk" ]; then
create_disk "${@}"
else
(>&2 echo "Unknown command: $cmd")
exit 1
fi
}
function start {
local num_vms="$#"
if [ "$num_vms" -eq 0 ]; then
log "No VMs specified."
return 0
fi
while [ "$#" -gt 0 ]; do
local name="$1"
shift 1
log "Starting VM $name."
start_one "$name"
[ "$#" -eq 0 ] || sleep 5
done
}
function start_one {
local name="$1"
local tmux_name="$name"
/usr/local/bin/tmux new-session -d -s "$tmux_name" "$0" "_start_body" "$name"
# /usr/local/bin/tmux new-session -d -s "$tmux_name" "/usr/bin/env VNC_ENABLE=NO VNC_LISTEN=0.0.0.0:5900 /usr/local/bin/bash /home/talexander/launch_opnsense.bash"
}
function launch_pidfile {
local pidfile="$1"
shift 1
mkdir -p "$(dirname "$pidfile")"
cat > "${pidfile}" <<< "$$"
set -x
exec "${@}"
}
export -f launch_pidfile
function stop {
local num_vms="$#"
if [ "$num_vms" -eq 0 ]; then
log "No VMs specified."
return 0
fi
while [ "$#" -gt 0 ]; do
local name="$1"
shift 1
log "Stopping VM $name."
stop_one "$name"
[ "$#" -eq 0 ] || sleep 5
done
}
function stop_one {
local name="$1"
local pidfile="/run/bhyverc/${name}/pid"
if [ ! -e "$pidfile" ]; then
log "Pid file $pidfile does not exist."
return 0
fi
local bhyve_pid
bhyve_pid=$(cat "$pidfile")
if ps -p "$bhyve_pid" >/dev/null; then
# Send ACPI shutdown command
log "Sending ACPI shutdown to ${name}:${bhyve_pid}."
kill -SIGTERM "$bhyve_pid"
fi
local timeout_start timeout_end
timeout_start=$(date +%s)
while ps -p "$bhyve_pid" >/dev/null; do
timeout_end=$(date +%s)
if [ $((timeout_end-timeout_start)) -ge "$SHUTDOWN_TIMEOUT" ]; then
log "${name}:${bhyve_pid} took more than $SHUTDOWN_TIMEOUT seconds to shut down. Hard powering down."
break
fi
log "Waiting for ${name}:${bhyve_pid} to exit."
sleep 2
done
bhyvectl "--vm=$name" --destroy || true
local timeout_start timeout_end
timeout_start=$(date +%s)
while ps -p "$bhyve_pid" >/dev/null; do
timeout_end=$(date +%s)
if [ $((timeout_end-timeout_start)) -ge "$SHUTDOWN_TIMEOUT" ]; then
log "${name}:${bhyve_pid} took more than $SHUTDOWN_TIMEOUT seconds to hard power down. Giving up."
break
fi
log "Waiting for ${name}:${bhyve_pid} to hard power down."
sleep 2
done
rm -f "$pidfile"
log "Finished stopping $name."
}
function status {
local num_vms="$#"
if [ "$num_vms" -gt 0 ]; then
for name in "$@"; do
status_one "$name"
done
else
log "No VMs specified."
fi
}
function status_one {
local name="$1"
local pidfile="/run/bhyverc/${name}/pid"
if [ ! -e "$pidfile" ]; then
log "$name is not running."
return 0
fi
local bhyve_pid
bhyve_pid=$(cat "$pidfile")
if ! ps -p "$bhyve_pid" >/dev/null; then
log "$name is not running."
return 0
fi
log "$name is running as pid $bhyve_pid."
}
function console {
local num_vms="$#"
if [ "$num_vms" -gt 0 ]; then
for name in "$@"; do
log "Attaching to console of VM $name."
console_one "$name"
done
else
log "No VMs specified."
fi
}
function console_one {
local name="$1"
local tmux_name="$name"
exec tmux a -t "$tmux_name"
}
function init {
mkdir -p /run/bhyverc
}
############## Bhyve ###########################
function create_disk {
local zfs_path="$1"
local mount_path="$2"
local gigabytes="$3"
zfs create -o "mountpoint=$mount_path" "$zfs_path"
cp /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd "${mount_path}/"
tee "${mount_path}/settings" <<EOF
CPU_CORES="$CPU_CORES"
MEMORY="$MEMORY"
NETWORK="$NETWORK"
IP_RANGE="$IP_RANGE"
BRIDGE_NAME="$BRIDGE_NAME"
INTERFACE_NAME="$INTERFACE_NAME"
EOF
zfs create -s "-V${gigabytes}G" -o volmode=dev -o primarycache=metadata -o secondarycache=none "$zfs_path/disk0"
}
function start_body {
local name="$1"
local zfs_path="zdata/vm/$name"
local mount_path="/vm/$name"
if [ -e "${mount_path}/settings" ]; then
source "${mount_path}/settings"
fi
local mount_cd="$CD"
local host_interface_name="$INTERFACE_NAME" # for raw, external interface
local bridge_name="$BRIDGE_NAME"
local ip_range="$IP_RANGE" # for raw this value does not matter
local mac_address
mac_address=$(calculate_mac_address "$name")
if [ "$PREVENT_OOM" = "YES" ]; then
protect -d -i -p "$$"
fi
local entry parsed_item
local additional_args=()
local next_pcie_slot=10
if [ "$NETWORK" = "NAT" ]; then
assert_bridge "$host_interface_name" "$bridge_name" "$ip_range"
local 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}")
elif [ "$NETWORK" = "RAW" ]; then
assert_raw "$host_interface_name" "$bridge_name"
local 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}")
elif [ "$NETWORK" = "BOTH" ]; then
assert_bridge "jail_nat" "$bridge_name" "$ip_range"
assert_raw "$host_interface_name" "bridge_raw"
local bridge_link_name=$(detect_available_link "${bridge_name}")
local raw_bridge_link_name=$(detect_available_link "bridge_raw")
local raw_mac_address=$(calculate_mac_address "${name}_raw")
additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}")
additional_args+=("-s" "3:0,virtio-net,netgraph,path=bridge_raw:,peerhook=${raw_bridge_link_name},mac=${raw_mac_address}")
else
die 1 "Unrecognized NETWORK type $NETWORK"
fi
if [ -n "$BIND9P" ]; then
if [[ "$BIND9P" = *":"* ]]; then
IFS=':' read -ra entry <<<"$BIND9P"
for item in "${entry[@]}"; do
IFS='=' read -ra parsed_item <<<"$item"
additional_args+=("-s" "${next_pcie_slot},virtio-9p,${parsed_item[0]}=${parsed_item[1]}")
next_pcie_slot=$((next_pcie_slot+1))
done
else
additional_args+=("-s" "${next_pcie_slot},virtio-9p,bind9p=${BIND9P}")
next_pcie_slot=$((next_pcie_slot+1))
fi
fi
# -H release the CPU when guest issues HLT instruction. Otherwise 100% of core will be consumed.
# -s 3,ahci-cd,/vm/.iso/archlinux-2023.04.01-x86_64.iso \
# -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080,wait \
# -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080 \
# TODO: Look into using nmdm instead of stdio for serial console
if [ -n "$mount_cd" ]; then
additional_args+=("-s" "5,ahci-cd,$mount_cd")
fi
if [ "$VNC_ENABLE" = "YES" ]; then
additional_args+=("-s" "${next_pcie_slot},fbuf,tcp=$VNC_LISTEN,w=$VNC_WIDTH,h=$VNC_HEIGHT")
next_pcie_slot=$((next_pcie_slot+1))
fi
vms+=("$name")
while true; do
local pidfile="/run/bhyverc/${name}/pid"
trap "set +e; stop_one '${name}'" EXIT
local launch_cmd=()
launch_cmd+=(
launch_pidfile "$pidfile"
bhyve
-D
-c "$CPU_CORES"
-m "$MEMORY"
-S
-H
-o 'rtc.use_localtime=false'
-s "0,hostbridge"
-s "4,nvme,/dev/zvol/${zfs_path}/disk0"
-s "${next_pcie_slot},xhci,tablet"
-s "$((next_pcie_slot+1)),lpc" -l "com1,stdio"
-l "bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,${mount_path}/BHYVE_UEFI_VARS.fd"
"${additional_args[@]}"
"$name"
)
set +e
rm -f "$pidfile"
(
IFS=$' \n\t'
set -ex
bash -c "${launch_cmd[*]}"
)
local exit_code=$?
log "Exit code ${exit_code}"
set -e
if [ $exit_code -eq 0 ]; then
echo "Rebooting."
sleep 5
elif [ $exit_code -eq 1 ]; then
echo "Powered off."
break
elif [ $exit_code -eq 2 ]; then
echo "Halted."
break
elif [ $exit_code -eq 3 ]; then
echo "Triple fault."
break
elif [ $exit_code -eq 4 ]; then
echo "Exited due to an error."
break
fi
done
}
function detect_available_link {
local bridge_name="$1"
local linknum=1
while true; do
local link_name="link${linknum}"
if ! ng_exists "${bridge_name}:${link_name}"; then
echo "$link_name"
return
fi
linknum=$((linknum + 1))
if [ "$linknum" -gt 90 ]; then
(>&2 echo "No available links on bridge $bridge_name")
exit 1
fi
done
}
function assert_bridge {
local host_interface_name="$1"
local bridge_name="$2"
local ip_range="$3"
if ! ng_exists "${bridge_name}:"; then
ngctl -d -f - <<EOF
mkpeer . eiface hook ether
name .:hook $host_interface_name
EOF
ngctl -d -f - <<EOF
mkpeer ${host_interface_name}: bridge ether link0
name ${host_interface_name}:ether $bridge_name
EOF
ifconfig "$(ngctl msg "${host_interface_name}:" getifname | grep Args | cut -d '"' -f 2)" name "${host_interface_name}" "$ip_range" up
fi
}
function assert_raw {
local extif="$1"
local bridge_name="$2"
kldload -n ng_bridge ng_eiface ng_ether
if ! ng_exists "${bridge_name}:"; then
ngctlcat <<EOF
# Create a bridge.
mkpeer $extif: bridge lower link0
# Assign a name to the bridge.
name $extif:lower ${bridge_name}
# Since the host is also using $extif, we need to connect the upper hook also. Otherwise we will lose connectivity.
connect $extif: ${bridge_name}: upper link1
# Enable promiscuous mode so the host ethernet adapter accepts packets for all addresses
msg $extif: setpromisc 1
# Do not overwrite source address on packets
msg $extif: setautosrc 0
EOF
fi
}
function ng_exists {
ngctl status "${1}" >/dev/null 2>&1
}
function calculate_mac_address {
local name="$1"
local source
source=$(md5 -r -s "$name" | awk '{print $1}')
echo "06:${source:0:2}:${source:2:2}:${source:4:2}:${source:6:2}:${source:8:2}"
}
function find_available_port {
local start_port="$1"
local port="$start_port"
while true; do
sockstat -P tcp -p 443
port=$((port + 1))
done
}
function ngctlcat {
if [ "$VERBOSE" = "YES" ]; then
tee /dev/tty | ngctl -d -f -
else
ngctl -d -f -
fi
}
main "${@}"

View File

@@ -0,0 +1,37 @@
#!/bin/sh
#
# REQUIRE: LOGIN FILESYSTEMS
# PROVIDE: bhyverc
# KEYWORD: shutdown
. /etc/rc.subr
name=bhyverc
rcvar=${name}_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
console_cmd="${name}_console"
extra_commands="console"
load_rc_config $name
bhyverc_start() {
export PATH="$PATH:/usr/local/bin"
exec /usr/local/bin/bhyverc start "${@}"
}
bhyverc_status() {
export PATH="$PATH:/usr/local/bin"
exec /usr/local/bin/bhyverc status "${@}"
}
bhyverc_stop() {
export PATH="$PATH:/usr/local/bin"
exec /usr/local/bin/bhyverc stop "${@}"
}
bhyverc_console() {
export PATH="$PATH:/usr/local/bin"
exec /usr/local/bin/bhyverc console "${@}"
}
run_rc_command "$@"

View File

@@ -22,6 +22,25 @@
loop: loop:
- src: bhyve_netgraph_bridge.bash - src: bhyve_netgraph_bridge.bash
dest: /usr/local/bin/bhyve_netgraph_bridge dest: /usr/local/bin/bhyve_netgraph_bridge
- src: bhyverc.bash
dest: /usr/local/bin/bhyverc
- name: Install rc script
copy:
src: "files/{{ item.src }}"
dest: "/usr/local/etc/rc.d/{{ item.dest|default(item.src) }}"
owner: root
group: wheel
mode: 0755
loop:
- src: bhyverc.sh
dest: bhyverc
- name: Enable bhyverc
community.general.sysrc:
name: bhyverc_enable
value: "YES"
path: /etc/rc.conf.d/bhyverc
- name: Create zfs dataset - name: Create zfs dataset
zfs: zfs:

View File

@@ -5,4 +5,4 @@ set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
GPGKEY=27DE40D9B8455C1B exec aur sync --makepkg-conf /etc/aurutils/makepkg.conf -c --sign "$@" GPGKEY=4278299FB84F6875 exec aur sync --makepkg-conf /etc/aurutils/makepkg.conf -c --sign "$@"

View File

@@ -1,27 +1,27 @@
-----BEGIN PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEXZwWGhYJKwYBBAHaRw8BAQdAfv7qozKkmf4D+5PDzADsMm4aAKDGLha7+Cu0 mDMEaNLjzBYJKwYBBAHaRw8BAQdAoegj6iXzJgxBkW8LyRS8ANRzp0LqyFbW1kRr
0H+RsWG0HlRvbSBBbGV4YW5kZXIgPHdvcmtAZml6ei5idXp6PoiQBBMWCAA4FiEE Z4VtVRK0HlRvbSBBbGV4YW5kZXIgPHdvcmtAZml6ei5idXp6PoiQBBMWCAA4FiEE
uEgVk2PCh3k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vsVyhWWI Rw8BAQdAPT7jOLbozd5hacityJHniQ6UbHN+AJcb6jh5rXOnOuSIfgQYFggAJhYh
EgMBCAeIfgQYFggAJgIbDBYhBLhIFZNjwod5F5VL4SfeQNm4RVwbBQJlC4ZwBQkL BNJyyNYWfyaFlGdmb0J4KZ+4T2h1BQJo0uclAhsgBQkDwmcAAAoJEEJ4KZ+4T2h1
MdY5AAoJECfeQNm4RVwbXscA/A8zRRTCwQKxJ8iz5jmTcVFAhl2vD781Dtv8NvcW rREA/3QE6suVUDl4OS2tCi4z2fh/7kjt29I3IFo+/B0AOumgAP0ao8FGqJyFC8YA
d5t8APwIwcuFVZZA3yayhIxi3aqYpMRxpn2t6Nswax1MIM8DBQ== 7V6T4qrXHbhlqTeofGhQ+iu7HqZVCw==
=0HtE =OfDR
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----

View File

@@ -40,11 +40,11 @@
command: pacman-key -a - command: pacman-key -a -
args: args:
stdin: "{{ lookup('file', pgp_key|default('gpg.asc')) }}" stdin: "{{ lookup('file', pgp_key|default('gpg.asc')) }}"
when: '"B848159363C2877917954BE127DE40D9B8455C1B" not in pacmankeys.stdout' when: '"D272C8D6167F26859467666F4278299FB84F6875" not in pacmankeys.stdout'
register: my_key_imported register: my_key_imported
- name: Sign my signing key - name: Sign my signing key
command: pacman-key --lsign-key "B848159363C2877917954BE127DE40D9B8455C1B" command: pacman-key --lsign-key "D272C8D6167F26859467666F4278299FB84F6875"
when: my_key_imported.changed when: my_key_imported.changed
- name: Build the aurutils package - name: Build the aurutils package
@@ -103,7 +103,8 @@
- /var/cache/pacman/custom/ - /var/cache/pacman/custom/
- name: Create custom repo db - name: Create custom repo db
command: repo-add --new --sign /var/cache/pacman/custom/custom.db.tar "/home/{{ build_user.name }}/.config/ansible_deploy/aurutils/aurutils-*-any.pkg.tar.*" # shell: repo-add --new --sign /var/cache/pacman/custom/custom.db.tar "/home/{{ build_user.name }}/.config/ansible_deploy/aurutils/aurutils-*-any.pkg.tar.*"
command: repo-add --new --sign /var/cache/pacman/custom/custom.db.tar
become: true become: true
become_user: "{{ build_user.name }}" become_user: "{{ build_user.name }}"
args: args:

View File

@@ -0,0 +1,2 @@
--ozone-platform-hint=auto
--enable-features=VaapiVideoDecoder,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE,AcceleratedVideoEncoder

View File

@@ -0,0 +1,2 @@
dependencies:
- users

View File

@@ -0,0 +1,55 @@
# - name: Create directories
# file:
# name: "{{ item }}"
# state: directory
# mode: 0755
# owner: root
# group: wheel
# loop:
# - /foo/bar
# - name: Install scripts
# copy:
# src: "files/{{ item.src }}"
# dest: "{{ item.dest }}"
# mode: 0755
# owner: root
# group: wheel
# loop:
# - src: foo.bash
# dest: /usr/local/bin/foo
# - name: Install Configuration
# copy:
# src: "files/{{ item.src }}"
# dest: "{{ item.dest }}"
# mode: 0600
# owner: root
# group: wheel
# loop:
# - src: foo.conf
# dest: /usr/local/etc/foo.conf
# - name: Clone Source
# git:
# repo: "https://foo.bar/baz.git"
# dest: /foo/bar
# version: "v1.0.2"
# force: true
# diff: false
- import_tasks: tasks/freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/linux.yaml
when: 'os_flavor == "linux"'
- include_tasks:
file: tasks/peruser.yaml
apply:
become: yes
become_user: "{{ initialize_user }}"
when: users is defined
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
loop_control:
loop_var: initialize_user

View File

@@ -0,0 +1,5 @@
# - name: Install packages
# package:
# name:
# - foo
# state: present

View File

@@ -0,0 +1,7 @@
# Check chrome://gpu/ to confirm hardware video decoding and vulkan rendering is working.
- name: Install packages
package:
name:
- chromium
state: present

View File

@@ -0,0 +1,2 @@
- import_tasks: tasks/common.yaml
when: install_graphics

View File

@@ -0,0 +1,29 @@
- include_role:
name: per_user
# - name: Create directories
# file:
# name: "{{ account_homedir.stdout }}/{{ item }}"
# state: directory
# mode: 0700
# owner: "{{ account_name.stdout }}"
# group: "{{ group_name.stdout }}"
# loop:
# - ".config/foo"
# - name: Copy files
# copy:
# src: "files/{{ item.src }}"
# dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
# mode: 0600
# owner: "{{ account_name.stdout }}"
# group: "{{ group_name.stdout }}"
# loop:
# - src: foo.conf
# dest: .config/foo/foo.conf
- import_tasks: tasks/peruser_freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/peruser_linux.yaml
when: 'os_flavor == "linux"'

View File

@@ -0,0 +1,10 @@
- name: Copy files
copy:
src: "files/{{ item.src }}"
dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
mode: 0600
owner: "{{ account_name.stdout }}"
group: "{{ group_name.stdout }}"
loop:
- src: chromium-flags.conf
dest: .config/chromium-flags.conf

View File

@@ -17,3 +17,9 @@ add include $devfsrules_hide_all
add include $devfsrules_unhide_basic add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login add include $devfsrules_unhide_login
add path 'bpf*' unhide add path 'bpf*' unhide
[tajailrand=15]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add path urandom unhide

View File

@@ -2,6 +2,8 @@
package: package:
name: name:
- docker - docker
- docker-compose
- docker-buildx
state: present state: present
- name: Create docker zfs dataset - name: Create docker zfs dataset

View File

@@ -1,2 +1,2 @@
dnctl pipe 1 config bw 100KByte/s pipe 1 config bw 100KByte/s
dnctl pipe 2 config pipe 2 config

View File

@@ -1,2 +0,0 @@
dnctl_enable="YES"
dnctl_rules="/etc/dnctl.conf"

View File

@@ -0,0 +1,28 @@
#!/bin/sh
#
#
# PROVIDE: dummynet
# BEFORE: pf ipfw
# KEYWORD: nojailvnet
. /etc/rc.subr
name="dummynet"
desc="Dummynet packet queuing and scheduling"
rcvar="${name}_enable"
load_rc_config $name
start_cmd="${name}_start"
required_files="$dummynet_rules"
required_modules="dummynet"
dummynet_start()
{
startmsg -n "Enabling ${name}"
cat "$dnctl_rules" | while read l; do
dnctl $l
done
startmsg '.'
}
run_rc_command $*

View File

@@ -0,0 +1,2 @@
dummynet_enable="YES"
dummynet_rules="/etc/dnctl.conf"

View File

@@ -9,6 +9,16 @@
- src: "{{ dummynet_config }}" - src: "{{ dummynet_config }}"
dest: /etc/dnctl.conf dest: /etc/dnctl.conf
- name: Install rc script
copy:
src: "files/{{ item.src }}"
dest: "/usr/local/etc/rc.d/{{ item.dest|default(item.src) }}"
owner: root
group: wheel
mode: 0755
loop:
- src: dummynet
- name: Install service configuration - name: Install service configuration
copy: copy:
src: "files/{{ item }}_rc.conf" src: "files/{{ item }}_rc.conf"
@@ -17,4 +27,4 @@
owner: root owner: root
group: wheel group: wheel
loop: loop:
- dnctl - dummynet

View File

@@ -51,17 +51,27 @@
;; Persist history over Emacs restarts. Vertico sorts by history position. ;; Persist history over Emacs restarts. Vertico sorts by history position.
(use-package savehist (use-package savehist
;; This is an emacs built-in but we're pulling the latest version ;; This is an emacs built-in but we're pulling the latest version
:pin gnu
:config :config
(savehist-mode)) (savehist-mode))
(use-package which-key (use-package which-key
:pin gnu
:diminish :diminish
:config :config
(which-key-mode)) (which-key-mode))
(use-package windmove (use-package windmove
:config ;; This is an emacs built-in but we're pulling the latest version
(windmove-default-keybindings)) :pin gnu
:bind
(
("S-<up>" . windmove-up)
("S-<right>" . windmove-right)
("S-<down>" . windmove-down)
("S-<left>" . windmove-left)
)
)
(setq tramp-default-method "ssh") (setq tramp-default-method "ssh")

View File

@@ -63,6 +63,9 @@
show-trailing-whitespace t show-trailing-whitespace t
;; Remove the line when killing it with ctrl-k ;; Remove the line when killing it with ctrl-k
kill-whole-line t kill-whole-line t
;; Show the current project in the mode line
project-mode-line t
) )
;; (setq-default fringes-outside-margins t) ;; (setq-default fringes-outside-margins t)

View File

@@ -0,0 +1,18 @@
(require 'common-lsp)
(use-package cmake-mode
:commands cmake-mode
:hook (
(cmake-mode . (lambda ()
(eglot-ensure)
(defclass my/eglot-cmake (eglot-lsp-server) ()
:documentation
"Own eglot server class.")
(add-to-list 'eglot-server-programs
'(cmake-mode . (my/eglot-cmake "cmake-language-server")))
))
)
)
(provide 'lang-cmake)

View File

@@ -0,0 +1,16 @@
(defun d2-format-buffer ()
"Run prettier."
(interactive)
(run-command-on-buffer "d2" "fmt" "-")
)
(use-package d2-mode
:commands (d2-mode)
:hook (
(d2-mode . (lambda ()
;; (add-hook 'before-save-hook 'd2-format-buffer nil 'local)
))
)
)
(provide 'lang-d2)

View File

@@ -0,0 +1,22 @@
(require 'common-lsp)
(require 'util-tree-sitter)
(use-package nix-mode
:mode (("\\.nix\\'" . nix-mode)
)
:commands nix-mode
:hook (
(nix-mode . (lambda ()
(eglot-ensure)
(defclass my/eglot-nix (eglot-lsp-server) ()
:documentation
"Own eglot server class.")
(add-to-list 'eglot-server-programs
'(nix-mode . (my/eglot-nix "nixd")))
(add-hook 'before-save-hook 'eglot-format-buffer nil 'local)
))
)
)
(provide 'lang-nix)

View File

@@ -1,14 +1,23 @@
(use-package org (use-package org
:ensure nil :ensure nil
:commands org-mode :commands org-mode
:bind ( :bind (:map org-mode-map
("C-c l" . org-store-link) ("C-c l" . org-store-link)
("C-c a" . org-agenda) ("C-c a" . org-agenda)
("S-<up>" . org-shiftup)
("S-<right>" . org-shiftright)
("S-<down>" . org-shiftdown)
("S-<left>" . org-shiftleft)
) )
:hook ( :hook (
(org-mode . (lambda () (org-mode . (lambda ()
(org-indent-mode +1) (org-indent-mode +1)
)) ))
;; Make windmove work in Org mode:
(org-shiftup-final . windmove-up)
(org-shiftleft-final . windmove-left)
(org-shiftdown-final . windmove-down)
(org-shiftright-final . windmove-right)
) )
:config :config
(require 'org-tempo) (require 'org-tempo)
@@ -36,6 +45,8 @@
;; TODO: There is an option to set the compiler, could be better than manually doing this here https://orgmode.org/manual/LaTeX_002fPDF-export-commands.html ;; TODO: There is an option to set the compiler, could be better than manually doing this here https://orgmode.org/manual/LaTeX_002fPDF-export-commands.html
;; (setq org-latex-compiler "lualatex") ;; (setq org-latex-compiler "lualatex")
;; TODO: nixos latex page recommends this line, figure out what it does / why its needed:
;; (setq org-preview-latex-default-process 'dvisvgm)
(setq org-latex-pdf-process (setq org-latex-pdf-process
'("lualatex -shell-escape -interaction nonstopmode -output-directory %o %f" '("lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"lualatex -shell-escape -interaction nonstopmode -output-directory %o %f" "lualatex -shell-escape -interaction nonstopmode -output-directory %o %f"
@@ -76,4 +87,8 @@
(use-package gnuplot) (use-package gnuplot)
(use-package graphviz-dot-mode) (use-package graphviz-dot-mode)
(use-package htmlize
;; For syntax highlighting when exporting to HTML.
)
(provide 'lang-org) (provide 'lang-org)

View File

@@ -4,6 +4,8 @@
:commands (treesit-install-language-grammar treesit-ready-p) :commands (treesit-install-language-grammar treesit-ready-p)
:init :init
(setq treesit-language-source-alist '()) (setq treesit-language-source-alist '())
:custom
(treesit-max-buffer-size 209715200) ;; 200MiB
:config :config
;; Default to the max level of detail in treesitter highlighting. This ;; Default to the max level of detail in treesitter highlighting. This
;; can be overridden in each language's use-package call with: ;; can be overridden in each language's use-package call with:

View File

@@ -36,4 +36,10 @@
(require 'lang-xml) (require 'lang-xml)
(require 'lang-nix)
(require 'lang-cmake)
(require 'lang-d2)
(load-directory autoload-directory) (load-directory autoload-directory)

View File

@@ -7,3 +7,5 @@ dependencies:
when: 'emacs_flavor == "full"' when: 'emacs_flavor == "full"'
- role: terraform - role: terraform
when: 'emacs_flavor == "full"' when: 'emacs_flavor == "full"'
- role: nix
when: 'emacs_flavor == "full"'

View File

@@ -15,6 +15,7 @@
- typescript-language-server - typescript-language-server
- shellcheck - shellcheck
- vscode-css-languageserver - vscode-css-languageserver
- d2 # Generating diagrams
state: present state: present
- name: Create directories - name: Create directories

View File

@@ -7,7 +7,6 @@ firefox_config:
dom.security.https_only_mode_ever_enabled: true dom.security.https_only_mode_ever_enabled: true
extensions.activeThemeID: "firefox-compact-dark@mozilla.org" extensions.activeThemeID: "firefox-compact-dark@mozilla.org"
# Disable ads # Disable ads
extensions.pocket.enabled: false
browser.newtabpage.activity-stream.showSponsored: false browser.newtabpage.activity-stream.showSponsored: false
browser.newtabpage.activity-stream.showSponsoredTopSites: false browser.newtabpage.activity-stream.showSponsoredTopSites: false
browser.newtabpage.activity-stream.feeds.section.topstories: false browser.newtabpage.activity-stream.feeds.section.topstories: false
@@ -21,3 +20,25 @@ firefox_config:
privacy.globalprivacycontrol.enabled: true privacy.globalprivacycontrol.enabled: true
# Disable "studies" (slice testing) # Disable "studies" (slice testing)
app.shield.optoutstudies.enabled: false app.shield.optoutstudies.enabled: false
# Disable battery status, used to track users.
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.
#
# This breaks copying from BigQuery https://github.com/microsoft/monaco-editor/issues/1540
# 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.
privacy.firstparty.isolate: true
# Do not preload URLs that auto-complete in the address bar.
browser.urlbar.speculativeConnect.enabled: false
# Do not resist fingerprinting because that tells websites to use light mode.
# https://bugzilla.mozilla.org/show_bug.cgi?id=1732114
privacy.resistFingerprinting: null # (default false)
# Instead, enable fingerprinting protection, which allows configuring an override.
privacy.fingerprintingProtection: true
# Allow sending dark mode preference to websites.
# Allow sending timezone to websites.
privacy.fingerprintingProtection.overrides: "+AllTargets,-CSSPrefersColorScheme,-JSDateTimeUTC,-CanvasExtractionBeforeUserInputIsBlocked,-CanvasImageExtractionPrompt,-CanvasExtractionFromThirdPartiesIsBlocked"
# Disable weather on new tab page
browser.newtabpage.activity-stream.showWeather: false
browser.ml.chat.enabled: false
browser.ml.enabled: false

View File

@@ -3,4 +3,5 @@
name: name:
- libfido2 - libfido2
- firefox-developer-edition - firefox-developer-edition
- speech-dispatcher # For TTS
state: present state: present

View File

@@ -10,12 +10,21 @@
register: firefox_about_config register: firefox_about_config
- name: Configure Firefox about:config - name: Configure Firefox about:config
when: item[1].value != None
lineinfile: lineinfile:
path: "{{ item[0].path }}" path: "{{ item[0].path }}"
regexp: '"{{ item[1].key }}", [^")\n]*\)' regexp: '"{{ item[1].key }}", [^")\n]*\)'
line: 'user_pref("{{ item[1].key }}", {{ item[1].value | to_json }});' line: 'user_pref("{{ item[1].key }}", {{ item[1].value | to_json }});'
loop: "{{ firefox_about_config.files | product(firefox_config | dict2items) | list }}" loop: "{{ firefox_about_config.files | product(firefox_config | dict2items) | list }}"
- name: Configure Firefox about:config
when: item[1].value == None
lineinfile:
path: "{{ item[0].path }}"
regexp: '"{{ item[1].key }}", [^")\n]*\)'
state: absent
loop: "{{ firefox_about_config.files | product(firefox_config | dict2items) | list }}"
- import_tasks: tasks/peruser_freebsd.yaml - import_tasks: tasks/peruser_freebsd.yaml
when: 'os_flavor == "freebsd"' when: 'os_flavor == "freebsd"'

View File

@@ -1,5 +1,5 @@
ext_if = "{ igb0 igb1 ix0 ix1 wlan0 }" ext_if = "{ igb0 igb1 ix0 ix1 linfi_host }"
not_ext_if = "{ !igb0 !igb1 !ix0 !ix1 !wlan0 }" not_ext_if = "{ !igb0 !igb1 !ix0 !ix1 !linfi_host }"
jail_nat_v4 = "{ 10.215.1.0/24 }" jail_nat_v4 = "{ 10.215.1.0/24 }"
not_jail_nat_v4 = "{ any, !10.215.1.0/24 }" not_jail_nat_v4 = "{ any, !10.215.1.0/24 }"
restricted_nat_v4 = "{ 10.215.2.0/24 }" restricted_nat_v4 = "{ 10.215.2.0/24 }"
@@ -19,17 +19,17 @@ unifi_ports = "{ 8443 3478 10001 8080 1900 8843 8880 6789 5514 }"
set skip on lo set skip on lo
# queueing # queueing
# altq on wlan0 cbq queue { def, stuff } # altq on linfi_host cbq queue { def, stuff }
# queue def cbq(default borrow) # queue def cbq(default borrow)
# queue stuff bandwidth 8Mb cbq { dagger } # queue stuff bandwidth 8Mb cbq { dagger }
# queue dagger cbq(borrow) # queue dagger cbq(borrow)
# redirections # redirections
nat pass on $ext_if inet from $jail_nat_v4 to $not_jail_nat_v4 -> (wlan0) nat pass on $ext_if inet from $jail_nat_v4 to $not_jail_nat_v4 -> (linfi_host)
rdr pass on $not_ext_if proto {tcp, udp} from any to 10.215.1.1 port 53 -> 172.16.0.1 port 53 rdr pass on $not_ext_if proto {tcp, udp} from any to 10.215.1.1 port 53 -> 172.16.0.1 port 53
# cloak # cloak
nat pass on $ext_if inet from 10.215.2.0/24 to !10.215.2.0/24 -> (wlan0) nat pass on $ext_if inet from 10.215.2.0/24 to !10.215.2.0/24 -> (linfi_host)
rdr pass on $not_ext_if proto {tcp, udp} from any to 10.215.2.1 port 53 -> 172.16.0.1 port 53 rdr pass on $not_ext_if proto {tcp, udp} from any to 10.215.2.1 port 53 -> 172.16.0.1 port 53
# bastion # bastion
@@ -42,6 +42,10 @@ nat pass on restricted_nat proto {tcp, udp} from 10.215.1.217/32 to 10.215.2.2 p
rdr pass on $ext_if inet proto {tcp, udp} from $not_restricted_nat_v4 to any port 8082 -> 10.215.2.2 port 8082 rdr pass on $ext_if inet proto {tcp, udp} from $not_restricted_nat_v4 to any port 8082 -> 10.215.2.2 port 8082
nat pass on restricted_nat proto {tcp, udp} from any to 10.215.2.2 port 8082 -> 10.215.2.1 nat pass on restricted_nat proto {tcp, udp} from any to 10.215.2.2 port 8082 -> 10.215.2.1
# cloak -> dagger old
rdr pass on $ext_if inet proto {tcp, udp} from $not_restricted_nat_v4 to any port 8083 -> 10.215.2.2 port 8083
nat pass on restricted_nat proto {tcp, udp} from any to 10.215.2.2 port 8083 -> 10.215.2.1
# -> sftp # -> sftp
# TODO: Limit bandwidth for sftp # TODO: Limit bandwidth for sftp
rdr pass on $ext_if inet proto {tcp, udp} from $not_jail_nat_v4 to any port 8022 -> 10.215.1.216 port 22 rdr pass on $ext_if inet proto {tcp, udp} from $not_jail_nat_v4 to any port 8022 -> 10.215.1.216 port 22
@@ -51,14 +55,17 @@ nat pass on jail_nat proto {tcp, udp} from any to 10.215.1.216 port 22 -> 10.215
# rdr pass on $ext_if inet proto {tcp, udp} from any to any port 65022 -> 10.213.177.8 port 22 # rdr pass on $ext_if inet proto {tcp, udp} from any to any port 65022 -> 10.213.177.8 port 22
rdr pass on $ext_if inet proto {udp, tcp} from any to any port $unifi_ports -> 10.215.1.202 rdr pass on $ext_if inet proto {udp, tcp} from any to any port $unifi_ports -> 10.215.1.202
# -> momlaptop
rdr pass on $ext_if inet proto {tcp, udp} from $not_jail_nat_v4 to any port 8033 -> 10.215.1.218 port 443
nat pass on jail_nat proto {tcp, udp} from any to 10.215.1.218 port 443 -> 10.215.1.1
# filtering # filtering
# match in on jail_nat from any to any dnpipe(1, 2)
# match in on restricted_nat from any to any dnpipe(1, 2)
block log all block log all
pass out on $ext_if pass out on $ext_if
# match in on jail_nat from any to any dnpipe 1
# match in on jail_nat from any to $rfc1918 dnpipe 2
# match in on restricted_nat from any to any dnpipe 1
pass in on jail_nat pass in on jail_nat
# Allow traffic from my machine to the jails/virtual machines # Allow traffic from my machine to the jails/virtual machines
pass out on jail_nat from $jail_nat_v4 pass out on jail_nat from $jail_nat_v4

View File

@@ -2,7 +2,8 @@ ext_if = "lagg0"
not_ext_if = "{ !lagg0 }" not_ext_if = "{ !lagg0 }"
jail_nat_v4 = "{ 10.215.1.0/24 }" jail_nat_v4 = "{ 10.215.1.0/24 }"
not_jail_nat_v4 = "{ any, !10.215.1.0/24 }" not_jail_nat_v4 = "{ any, !10.215.1.0/24 }"
pub_k8s = "{ 74.80.180.136/29, !74.80.180.138 }" # pub_k8s = "{ 74.80.180.136/29, !74.80.180.138 }"
pub_k8s = "{ 74.80.180.137, 74.80.180.139, 74.80.180.140, 74.80.180.141, 74.80.180.142 }"
dhcp = "{ bootpc, bootps }" dhcp = "{ bootpc, bootps }"
allow = "{ colo }" allow = "{ colo }"
@@ -33,20 +34,24 @@ scrub in on $ext_if all fragment reassemble
# redirections # redirections
nat on $ext_if inet from ! ($ext_if) to ! ($ext_if) -> ($ext_if) nat on $ext_if inet from ! ($ext_if) to ! ($ext_if) -> ($ext_if)
rdr pass proto {tcp, udp} from any to 10.215.1.1 port 53 tag REDIREXTERNAL -> 1.1.1.1 port 53 rdr pass on jail_nat proto {tcp, udp} from any to 10.215.1.1 port 53 tag REDIREXTERNAL -> 1.1.1.1 port 53
rdr pass on $ext_if proto {tcp, udp} to ($ext_if) port 6443 -> 10.215.1.204 port 6443 rdr pass on $ext_if proto {tcp, udp} to ($ext_if) port 6443 tag REDIRINTERNAL -> 10.215.1.204 port 6443
rdr pass on jail_nat proto {tcp, udp} to ($ext_if) port 6443 tag REDIRINTERNAL -> 10.215.1.204 port 6443 rdr pass on jail_nat proto {tcp, udp} to ($ext_if) port 6443 tag REDIRINTERNAL -> 10.215.1.204 port 6443
rdr pass on $ext_if proto {tcp, udp} to ($ext_if) port 19993 -> 10.215.1.204 port 19993 rdr pass on $ext_if proto {tcp, udp} to ($ext_if) port 19993 tag REDIRINTERNAL -> 10.215.1.204 port 19993
rdr pass on jail_nat proto {tcp, udp} to ($ext_if) port 19993 tag REDIRINTERNAL -> 10.215.1.204 port 19993 rdr pass on jail_nat proto {tcp, udp} to ($ext_if) port 19993 tag REDIRINTERNAL -> 10.215.1.204 port 19993
rdr pass proto {tcp, udp} from $not_jail_nat_v4 to ($ext_if) port 65099 -> 10.215.1.210 port 22 rdr pass proto {tcp, udp} from $not_jail_nat_v4 to ($ext_if) port 65099 tag REDIRINTERNAL -> 10.215.1.210 port 22
rdr pass proto {tcp, udp} from $jail_nat_v4 to ($ext_if) port 65099 tag REDIRINTERNAL -> 10.215.1.210 port 22 rdr pass proto {tcp, udp} from $jail_nat_v4 to ($ext_if) port 65099 tag REDIRINTERNAL -> 10.215.1.210 port 22
rdr pass proto {tcp, udp} from $not_jail_nat_v4 to ($ext_if) port 53 -> 10.215.1.211 port 53 # log (to pflog1)
rdr pass proto {tcp, udp} from $not_jail_nat_v4 to ($ext_if) port 53 tag REDIRINTERNAL -> 10.215.1.211 port 53
rdr pass proto {tcp, udp} from $jail_nat_v4 to ($ext_if) port 53 tag REDIRINTERNAL -> 10.215.1.211 port 53 rdr pass proto {tcp, udp} from $jail_nat_v4 to ($ext_if) port 53 tag REDIRINTERNAL -> 10.215.1.211 port 53
rdr pass proto {tcp, udp} from $not_jail_nat_v4 to ($ext_if) port 65122 tag REDIRINTERNAL -> 10.215.1.219 port 22
rdr pass proto {tcp, udp} from $jail_nat_v4 to ($ext_if) port 65122 tag REDIRINTERNAL -> 10.215.1.219 port 22
nat pass tagged REDIRINTERNAL -> (jail_nat) nat pass tagged REDIRINTERNAL -> (jail_nat)
nat pass tagged REDIREXTERNAL -> ($ext_if) nat pass tagged REDIREXTERNAL -> ($ext_if)
@@ -63,6 +68,9 @@ pass quick on $allow
# Single interface kubernetes cluster is working with the following run on mrmanager: # Single interface kubernetes cluster is working with the following run on mrmanager:
# doas route add -host 74.80.180.139 -interface jail_nat # doas route add -host 74.80.180.139 -interface jail_nat
# doas route add -net 10.129.0.0/16 -interface jail_nat
# ? doas route -6 add -net '2620:11f:7001:7:ffff:ffff:0ad7:0100/120' -interface jail_nat
# ? doas ifconfig jail_nat inet6 2620:11f:7001:7:ffff:ffff:0ad7:0101/120
# doas sysctl net.link.ether.inet.proxyall=1 # doas sysctl net.link.ether.inet.proxyall=1
# Plus this in pf.conf: # Plus this in pf.conf:
# pass quick from any to 74.80.180.139 # pass quick from any to 74.80.180.139
@@ -72,6 +80,10 @@ pass in on jail_nat
# Allow traffic from my machine to the jails/virtual machines # Allow traffic from my machine to the jails/virtual machines
pass out on jail_nat from (jail_nat:network) pass out on jail_nat from (jail_nat:network)
#pass quick in on $ext_if proto {tcp6, udp6} from any to 2620:11f:7001:7:ffff:ffff:0ad7:0100/120
pass in quick on $ext_if from any to 2620:11f:7001:7:ffff:ffff:0ad7:0100/120
pass out quick on jail_nat to 2620:11f:7001:7:ffff:ffff:0ad7:0100/120
pass in on $ext_if proto tcp to any port $tcp_pass_in pass in on $ext_if proto tcp to any port $tcp_pass_in
pass in on $ext_if proto udp to any port $udp_pass_in pass in on $ext_if proto udp to any port $udp_pass_in

View File

@@ -1,5 +1,5 @@
ext_if = "{ wlan0 }" ext_if = "{ linfi_host }"
not_ext_if = "{ !wlan0 }" not_ext_if = "{ !linfi_host }"
jail_nat_v4 = "{ 10.215.1.0/24 }" jail_nat_v4 = "{ 10.215.1.0/24 }"
not_jail_nat_v4 = "{ any, !10.215.1.0/24 }" not_jail_nat_v4 = "{ any, !10.215.1.0/24 }"
rfc1918 = "{ 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 }" rfc1918 = "{ 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 }"
@@ -16,7 +16,7 @@ udp_pass_in = "{ 53 51820 }"
set skip on lo set skip on lo
# redirections # redirections
nat pass on $ext_if inet from $jail_nat_v4 to $not_jail_nat_v4 -> (wlan0) nat pass on $ext_if inet from $jail_nat_v4 to $not_jail_nat_v4 -> (linfi_host)
rdr pass on $not_ext_if proto {tcp, udp} from any to 10.215.1.1 port 53 -> 172.16.0.1 port 53 rdr pass on $not_ext_if proto {tcp, udp} from any to 10.215.1.1 port 53 -> 172.16.0.1 port 53
# Redirect jaeger ports to virtual machine. # Redirect jaeger ports to virtual machine.

View File

@@ -0,0 +1,3 @@
# Disable power save for wifi card because power save caused video stuttering in google meet on Linux. Both of these are currently the default on FreeBSD but I'm saving it just in case that default changes.
compat.linuxkpi.iwlwifi_power_save="0"
compat.linuxkpi.iwlwifi_mvm_power_scheme="1"

View File

@@ -1,5 +1,13 @@
options iwlwifi power_save=1 # Manually disable power save:
# iw wlan0 set power_save off
options iwlwifi uapsd_disable=0 ## High power:
options iwlwifi power_save=0
# options iwlwifi uapsd_disable=1
options iwlmvm power_scheme=1 # 1-active, 2-balanced, 3-low power, default: 2 (int)
options iwlmvm power_scheme=3 ## Low power:
# options iwlwifi power_save=1
# ? power_level:default power save level (range from 1 - 5, default: 1) (int)
# options iwlwifi uapsd_disable=0
# options iwlmvm power_scheme=3

View File

@@ -0,0 +1,285 @@
#!/usr/local/bin/bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Share a host directory to the guest via 9pfs.
#
# Inside the VM run:
# mount -t virtfs -o trans=virtio sharename /some/vm/path
# mount -t 9p -o cache=mmap -o msize=512000 sharename /mnt/9p
# mount -t 9p -o trans=virtio,cache=mmap,msize=512000 sharename /path/to/mountpoint
# bhyve_options="-s 28,virtio-9p,sharename=/"
# Enable Sound
# bhyve_options="-s 16,hda,play=/dev/dsp,rec=/dev/dsp"
# Example usage:
#
# doas bhyve_netgraph_bridge create-disk zdata/vm/poudriere /vm/poudriere 10
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere /vm/iso/FreeBSD-13.2-RELEASE-amd64-bootonly.iso
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere
: ${VERBOSE:="NO"} # or YES
: ${CPU_CORES:="1"}
: ${MEMORY:="1G"}
: ${NETWORK:="NAT"} # or RAW or BOTH
: ${IP_RANGE:="10.215.1.1/24"} # Ignored for RAW networks
: ${INTERFACE_NAME:="jail_nat"} # or the external interface like lagg0 for RAW networks
: ${BRIDGE_NAME:="bridge_$INTERFACE_NAME"} # or bridge_raw for RAW networks
: ${VNC_ENABLE:="NO"}
: ${VNC_LISTEN:="127.0.0.1:5900"}
: ${VNC_WIDTH:="1920"}
: ${VNC_HEIGHT:="1080"}
if [ "$VERBOSE" = "YES" ]; then
set -x
fi
############## Setup #########################
function cleanup {
for vm in "${vms[@]}"; do
log "Destroying bhyve vm $vm"
bhyvectl "--vm=$vm" --destroy
log "Destroyed bhyve vm $vm"
done
}
vms=()
for sig in EXIT; do
trap "set +e; sleep 10; cleanup" "$sig"
done
function die {
local status_code="$1"
shift
(>&2 echo "${@}")
exit "$status_code"
}
function log {
(>&2 echo "${@}")
}
############## Program #########################
function main {
local cmd="$1"
shift 1
if [ "$cmd" = "create-disk" ]; then
create_disk "${@}"
elif [ "$cmd" = "start" ]; then
start_vm "${@}"
else
die 1 "Unrecognized command $cmd"
fi
}
function create_disk {
local zfs_path="$1"
local mount_path="$2"
local gigabytes="$3"
zfs create -o "mountpoint=$mount_path" "$zfs_path"
cp /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd "${mount_path}/"
tee "${mount_path}/settings" <<EOF
CPU_CORES="$CPU_CORES"
MEMORY="$MEMORY"
NETWORK="$NETWORK"
IP_RANGE="$IP_RANGE"
BRIDGE_NAME="$BRIDGE_NAME"
INTERFACE_NAME="$INTERFACE_NAME"
EOF
zfs create -s "-V${gigabytes}G" -o volmode=dev -o primarycache=metadata -o secondarycache=none -o volblocksize=64K "$zfs_path/disk0"
}
function start_vm {
local name="$1"
local zfs_path="$2"
local mount_path="$3"
local mount_cd="${4:-}"
if [ -e "${mount_path}/settings" ]; then
source "${mount_path}/settings"
fi
local host_interface_name="$INTERFACE_NAME" # for raw, external interface
local bridge_name="$BRIDGE_NAME"
local ip_range="$IP_RANGE" # for raw this value does not matter
local mac_address
mac_address=$(calculate_mac_address "$name")
local additional_args=()
if [ "$NETWORK" = "NAT" ]; then
assert_bridge "$host_interface_name" "$bridge_name" "$ip_range"
local bridge_link_name=$(detect_available_link "${bridge_name}")
additional_args+=("-s" "2:0,e1000,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}")
elif [ "$NETWORK" = "RAW" ]; then
assert_raw "$host_interface_name" "$bridge_name"
local 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}")
elif [ "$NETWORK" = "BOTH" ]; then
assert_bridge "jail_nat" "$bridge_name" "$ip_range"
assert_raw "$host_interface_name" "bridge_raw"
local bridge_link_name=$(detect_available_link "${bridge_name}")
local raw_bridge_link_name=$(detect_available_link "bridge_raw")
local raw_mac_address=$(calculate_mac_address "${name}_raw")
additional_args+=("-s" "2:0,virtio-net,netgraph,path=${bridge_name}:,peerhook=${bridge_link_name},mac=${mac_address}")
additional_args+=("-s" "3:0,virtio-net,netgraph,path=bridge_raw:,peerhook=${raw_bridge_link_name},mac=${raw_mac_address}")
elif [ "$NETWORK" = "NONE" ]; then
(>&2 echo "Not using any network.")
else
die 1 "Unrecognized NETWORK type $NETWORK"
fi
# -H release the CPU when guest issues HLT instruction. Otherwise 100% of core will be consumed.
# -s 3,ahci-cd,/vm/.iso/archlinux-2023.04.01-x86_64.iso \
# -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080,wait \
# -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080 \
# TODO: Look into using nmdm instead of stdio for serial console
if [ -n "$mount_cd" ]; then
additional_args+=("-s" "5,ahci-cd,$mount_cd")
fi
if [ "$VNC_ENABLE" = "YES" ]; then
additional_args+=("-s" "29,fbuf,tcp=$VNC_LISTEN,w=$VNC_WIDTH,h=$VNC_HEIGHT,wait")
fi
vms+=("$name")
# Removes CPU_CORES because windows must be a single CPU in bhyve
# -c $CPU_CORES \
# We need tpm
# -l "tpm,passthru,/dev/tpm0" \
# -S \
while true; do
set -x
set +e
bhyve \
-D \
-c sockets=1,cores=2,threads=2 \
-m $MEMORY \
-H \
-w \
-o 'rtc.use_localtime=false' \
-s 0,hostbridge \
-s "4,nvme,/dev/zvol/${zfs_path}/disk0" \
-s 16,hda,play=/dev/dsp,rec=/dev/dsp \
-s 30,xhci,tablet \
-s 31,lpc -l com1,stdio \
-l "bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,${mount_path}/BHYVE_UEFI_VARS.fd" \
-U '5a63bcd1-5cb4-4401-8a6f-d4042fb928a6' \
"${additional_args[@]}" \
"$name"
local exit_code=$?
set -e
set +x
if [ $exit_code -eq 0 ]; then
echo "Rebooting."
sleep 5
elif [ $exit_code -eq 1 ]; then
echo "Powered off."
break
elif [ $exit_code -eq 2 ]; then
echo "Halted."
break
elif [ $exit_code -eq 3 ]; then
echo "Triple fault."
break
elif [ $exit_code -eq 4 ]; then
echo "Exited due to an error."
break
fi
done
}
function detect_available_link {
local bridge_name="$1"
local linknum=1
while true; do
local link_name="link${linknum}"
if ! ng_exists "${bridge_name}:${link_name}"; then
echo "$link_name"
return
fi
linknum=$((linknum + 1))
if [ "$linknum" -gt 90 ]; then
(>&2 echo "No available links on bridge $bridge_name")
exit 1
fi
done
}
function assert_bridge {
local host_interface_name="$1"
local bridge_name="$2"
local ip_range="$3"
if ! ng_exists "${bridge_name}:"; then
ngctl -d -f - <<EOF
mkpeer . eiface hook ether
name .:hook $host_interface_name
EOF
ngctl -d -f - <<EOF
mkpeer ${host_interface_name}: bridge ether link0
name ${host_interface_name}:ether $bridge_name
EOF
ifconfig $(ngctl msg "${host_interface_name}:" getifname | grep Args | cut -d '"' -f 2) name "${host_interface_name}" "$ip_range" up
fi
}
function assert_raw {
local extif="$1"
local bridge_name="$2"
kldload -n ng_bridge ng_eiface ng_ether
if ! ng_exists "${bridge_name}:"; then
ngctlcat <<EOF
# Create a bridge.
mkpeer $extif: bridge lower link0
# Assign a name to the bridge.
name $extif:lower ${bridge_name}
# Since the host is also using $extif, we need to connect the upper hook also. Otherwise we will lose connectivity.
connect $extif: ${bridge_name}: upper link1
# Enable promiscuous mode so the host ethernet adapter accepts packets for all addresses
msg $extif: setpromisc 1
# Do not overwrite source address on packets
msg $extif: setautosrc 0
EOF
fi
}
function ng_exists {
ngctl status "${1}" >/dev/null 2>&1
}
function calculate_mac_address {
local name="$1"
local source
source=$(md5 -r -s "$name" | awk '{print $1}')
echo "06:${source:0:2}:${source:2:2}:${source:4:2}:${source:6:2}:${source:8:2}"
}
function find_available_port {
local start_port="$1"
local port="$start_port"
while true; do
sockstat -P tcp -p 443
port=$((port + 1))
done
}
function ngctlcat {
if [ "$VERBOSE" = "YES" ]; then
tee /dev/tty | ngctl -d -f -
else
ngctl -d -f -
fi
}
main "${@}"

View File

@@ -1,2 +1,2 @@
# Set screen brightness. Ever since enabling adaptive brightness management, my brightness ends up sinking lower on re-boots (I suspect it is saving the actual brightness rather than the set brightness). This forces the brightness back to the level I prefer. # Set screen brightness. Ever since enabling adaptive brightness management, my brightness ends up sinking lower on re-boots (I suspect it is saving the actual brightness rather than the set brightness). This forces the brightness back to the level I prefer.
w- /sys/class/backlight/amdgpu_bl0/brightness - - - - 85 w- /sys/class/backlight/amdgpu_bl0/brightness - - - - 21845

View File

@@ -0,0 +1 @@
options cfg80211 ieee80211_regdom=US

View File

@@ -0,0 +1,46 @@
#!/bin/sh
#
# REQUIRE: LOGIN
# PROVIDE: windows
# KEYWORD: shutdown
. /etc/rc.subr
name=windows
rcvar=${name}_enable
start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
load_rc_config $name
tmux_name="windows"
windows_start() {
/usr/local/bin/tmux new-session -d -s "$tmux_name" "/usr/bin/env VNC_ENABLE=YES VNC_LISTEN=0.0.0.0:5900 /usr/local/bin/bash /usr/local/bin/launch_windows start windows zroot/freebsd/current/vm/windows /vm/windows /vm/.iso/Win11_23H2_English_x64v2.iso"
}
windows_status() {
if /usr/local/bin/tmux has-session -t $tmux_name 2>/dev/null; then
echo "$tmux_name is running."
else
echo "$tmux_name is not running."
return 1
fi
}
windows_stop() {
/usr/local/bin/tmux has-session -t $tmux_name 2>/dev/null && (
/usr/local/bin/tmux kill-session -t $tmux_name
sleep 10
bhyvectl --vm=windows --destroy
# kill `cat /var/run/windows.pid`
)
windows_wait_for_end
}
windows_wait_for_end() {
while /usr/local/bin/tmux has-session -t $tmux_name 2>dev/null; do
sleep 1
done
}
run_rc_command "$1"

View File

@@ -0,0 +1,3 @@
dependencies:
- role: bhyve
when: 'os_flavor == "freebsd"'

View File

@@ -1,5 +1,30 @@
# - name: Install packages - name: Install loader.conf
# package: copy:
# name: src: "files/{{ item }}_loader.conf"
# - foo dest: "/boot/loader.conf.d/{{ item }}.conf"
# state: present mode: 0644
owner: root
group: wheel
loop:
- disable_wifi_powersave
- name: Install scripts
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0755
owner: root
group: wheel
loop:
- src: launch_windows.bash
dest: /usr/local/bin/launch_windows
- name: Install rc script
copy:
src: "files/{{ item.src }}"
dest: "/usr/local/etc/rc.d/{{ item.dest|default(item.src) }}"
owner: root
group: wheel
mode: 0755
loop:
- src: windows

View File

@@ -30,10 +30,11 @@
- iwlwifi - iwlwifi
- snd_hda_intel - snd_hda_intel
- disable_sp5100_watchdog - disable_sp5100_watchdog
- wifi_us
- name: Configure kernel command line - name: Configure kernel command line
zfs: zfs:
name: "zroot/linux" name: "zroot/linux/archwork/be"
state: present state: present
extra_zfs_properties: extra_zfs_properties:
# amdgpu.abmlevel=3 :: Automatically reduce screen brightness but tweak colors to compensate for power reduction. # amdgpu.abmlevel=3 :: Automatically reduce screen brightness but tweak colors to compensate for power reduction.
@@ -42,7 +43,8 @@
# amd_pstate=passive :: Fully automated hardware pstate control. # amd_pstate=passive :: Fully automated hardware pstate control.
# amd_pstate=active :: Same as passive except we can set the energy performance preference (EPP) to suggest how much we prefer performance or energy efficiency. # amd_pstate=active :: Same as passive except we can set the energy performance preference (EPP) to suggest how much we prefer performance or energy efficiency.
# amd_pstate=guided :: Same as passive except we can set upper and lower frequency bounds. # amd_pstate=guided :: Same as passive except we can set upper and lower frequency bounds.
"org.zfsbootmenu:commandline": "rw quiet amdgpu.abmlevel=3 pcie_aspm=force pcie_aspm.policy=powersupersave nowatchdog" # amdgpu.dcdebugmask=0x10 :: Allegedly disables Panel Replay from https://community.frame.work/t/tracking-freezing-arch-linux-amd/39495/32
"org.zfsbootmenu:commandline": "rw quiet amdgpu.abmlevel=2 pcie_aspm=force pcie_aspm.policy=powersupersave nowatchdog amdgpu.dcdebugmask=0x10"
- name: Install Configuration - name: Install Configuration
copy: copy:
@@ -65,3 +67,34 @@
loop: loop:
- gpe10-boot.service - gpe10-boot.service
- gpe10-sleep.service - gpe10-sleep.service
# install swtpm
# install edk2-ovmf for /usr/share/ovmf/OVMF.fd
# install qemu-system-x86
# doas qemu-system-x86_64 -cdrom /vm/.iso/Win11_23H2_English_x64v2.iso -cpu Skylake-Client-v3 -enable-kvm -m 8192 —device chardev,socket,id=chrtpm,path=/tmp/emulated_tpm/swtpm-sock -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0 -smp 2 -device intel-hda -device hda-duplex -usb -nic user,ipv6=off,model=rtl8139,mac=84:1b:77:c9:03:a6 -bios /usr/share/edk2/x64/OVMF.fd -drive file=/dev/zvol/zroot/freebsd/current/vm/windows/disk0,format=raw,media=disk,if=none,id=nvm -device nvme,drive=nvm,serial=foo,opt_io_size=4096,min_io_size=4096,logical_block_size=4096,physical_block_size=4096
# 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
- 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
- wireless-regdb
state: present

View File

@@ -1,27 +1,27 @@
-----BEGIN PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEXZwWGhYJKwYBBAHaRw8BAQdAfv7qozKkmf4D+5PDzADsMm4aAKDGLha7+Cu0 mDMEaNLjzBYJKwYBBAHaRw8BAQdAoegj6iXzJgxBkW8LyRS8ANRzp0LqyFbW1kRr
0H+RsWG0HlRvbSBBbGV4YW5kZXIgPHdvcmtAZml6ei5idXp6PoiQBBMWCAA4FiEE Z4VtVRK0HlRvbSBBbGV4YW5kZXIgPHdvcmtAZml6ei5idXp6PoiQBBMWCAA4FiEE
uEgVk2PCh3kXlUvhJ95A2bhFXBsFAl+w+R0CGwMFCwkIBwIGFQoJCA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cb6jh5rXOnOuSIfgQYFggAJhYh
EgMBCAeIfgQYFggAJgIbDBYhBLhIFZNjwod5F5VL4SfeQNm4RVwbBQJlC4ZwBQkL BNJyyNYWfyaFlGdmb0J4KZ+4T2h1BQJo0uclAhsgBQkDwmcAAAoJEEJ4KZ+4T2h1
MdY5AAoJECfeQNm4RVwbXscA/A8zRRTCwQKxJ8iz5jmTcVFAhl2vD781Dtv8NvcW rREA/3QE6suVUDl4OS2tCi4z2fh/7kjt29I3IFo+/B0AOumgAP0ao8FGqJyFC8YA
d5t8APwIwcuFVZZA3yayhIxi3aqYpMRxpn2t6Nswax1MIM8DBQ== 7V6T4qrXHbhlqTeofGhQ+iu7HqZVCw==
=0HtE =OfDR
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----

View File

@@ -8,7 +8,6 @@
- libva-utils # for vainfo - libva-utils # for vainfo
- vdpauinfo # for vdpauinfo - vdpauinfo # for vdpauinfo
- libvdpau-va-gl # vdpau support - libvdpau-va-gl # vdpau support
- igt-gpu-tools # for intel_gpu_top
- vulkan-tools # For vulkaninfo - vulkan-tools # For vulkaninfo
state: present state: present

View File

@@ -1,4 +1,4 @@
tmpfs /jail/bastion/tmp tmpfs rw,mode=777 0 0 tmpfs /jail/bastion/tmp tmpfs rw,mode=777 0 0
tmpfs /jail/bastion/var/run tmpfs rw,mode=755 0 0 tmpfs /jail/bastion/var/run tmpfs rw,mode=755 0 0
/jail/certificate/usr/local/etc/letsencrypt/archive/stuff.fizz.buzz /jail/bastion/stuff.fizz.buzz nullfs ro,noexec 0 0 /jail/certificate/usr/local/etc/letsencrypt /jail/bastion/letsencrypt nullfs ro,noexec 0 0

View File

@@ -6,6 +6,8 @@ dagger {
exec.prestart += "/usr/local/bin/jail_netgraph_bridge start cloak ${name} 192.168.1.0/24"; exec.prestart += "/usr/local/bin/jail_netgraph_bridge start cloak ${name} 192.168.1.0/24";
exec.poststop += "sleep 10; /usr/local/bin/jail_netgraph_bridge stop cloak ${name}"; exec.poststop += "sleep 10; /usr/local/bin/jail_netgraph_bridge stop cloak ${name}";
devfs_ruleset = 15;
mount.devfs;
mount.fstab = "/etc/fstab.${name}"; mount.fstab = "/etc/fstab.${name}";
exec.start += "/bin/sh /etc/rc"; exec.start += "/bin/sh /etc/rc";

View File

@@ -0,0 +1,15 @@
momlaptop {
path = "/jail/${name}";
vnet;
exec.prestart += "/usr/local/bin/jail_netgraph_bridge start jail_nat jail${name} 10.215.1.1/24";
exec.poststop += "sleep 10; /usr/local/bin/jail_netgraph_bridge stop jail_nat jail${name}";
vnet.interface += "jail${name}";
devfs_ruleset = 14;
mount.devfs;
mount.fstab = "/etc/fstab.${name}";
exec.start += "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown jail";
exec.consolelog = "/var/log/jail_${name}_console.log";
}

View File

@@ -0,0 +1,15 @@
rg {
path = "/jail/${name}";
vnet;
exec.prestart += "/usr/local/bin/jail_netgraph_bridge start jail_nat jail${name} 10.215.1.1/24";
exec.poststop += "sleep 10; /usr/local/bin/jail_netgraph_bridge stop jail_nat jail${name}";
vnet.interface += "jail${name}";
devfs_ruleset = 14;
mount.devfs;
mount.fstab = "/etc/fstab.${name}";
exec.start += "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown jail";
exec.consolelog = "/var/log/jail_${name}_console.log";
}

View File

@@ -26,7 +26,7 @@ function by_src {
} }
function by_bin { function by_bin {
DESTRELEASE=13.2-RELEASE DESTRELEASE=14.3-RELEASE
DESTARCH=`uname -m` DESTARCH=`uname -m`
SOURCEURL=http://ftp.freebsd.org/pub/FreeBSD/releases/$DESTARCH/$DESTRELEASE/ SOURCEURL=http://ftp.freebsd.org/pub/FreeBSD/releases/$DESTARCH/$DESTRELEASE/
for component in base ports; do fetch $SOURCEURL/$component.txz -o - | tar -xf - -C "$DESTDIR" ; done for component in base ports; do fetch $SOURCEURL/$component.txz -o - | tar -xf - -C "$DESTDIR" ; done

View File

@@ -36,8 +36,8 @@ http {
include conf.d/tls_settings.include; include conf.d/tls_settings.include;
# RSA # RSA
ssl_certificate /stuff.fizz.buzz/fullchain1.pem; ssl_certificate /letsencrypt/live/stuff.fizz.buzz/fullchain.pem;
ssl_certificate_key /stuff.fizz.buzz/privkey1.pem; ssl_certificate_key /letsencrypt/live/stuff.fizz.buzz/privkey.pem;
# Nginx by default only allows file uploads up to 1M in size # Nginx by default only allows file uploads up to 1M in size
client_max_body_size 50M; client_max_body_size 50M;

View File

@@ -17,7 +17,7 @@
owner: root owner: root
group: wheel group: wheel
loop: loop:
- /stuff.fizz.buzz - /letsencrypt
- /etc/rc.conf.d - /etc/rc.conf.d
- /usr/local/etc/nginx/conf.d - /usr/local/etc/nginx/conf.d

View File

@@ -0,0 +1,15 @@
# Enable HTTP Strict Transport Security (HSTS) to force clients to
# always connect via HTTPS (do not use if only testing)
add_header Strict-Transport-Security "max-age=31536000;" always;
# Enable cross-site filter (XSS) and tell browser to block detected
# attacks
add_header X-XSS-Protection "1; mode=block" always;
# Prevent some browsers from MIME-sniffing a response away from the
# declared Content-Type
add_header X-Content-Type-Options "nosniff" always;
# Disallow the site to be rendered within a frame (clickjacking
# protection)
add_header X-Frame-Options "DENY" always;
# Indicate that we are serving http3 on port 443
add_header Alt-Svc 'h3=":8033"; ma=864000';

Binary file not shown.

View File

@@ -0,0 +1,2 @@
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/nginx/*.log 640 5 1000 @T00 GYC /var/run/nginx.pid SIGUSR1

View File

@@ -0,0 +1,48 @@
worker_processes auto;
user www www;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
types {
text/plain log;
}
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
include conf.d/headers.include;
server {
listen 443 quic reuseport;
listen [::]:443 quic reuseport;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name momlaptop.fizz.buzz;
include conf.d/tls_settings.include;
# RSA
ssl_certificate /momlaptop.fizz.buzz/tls.crt;
ssl_certificate_key /momlaptop.fizz.buzz/tls.key;
# Nginx by default only allows file uploads up to 50M in size
client_max_body_size 50M;
location / {
auth_basic "Stuff";
auth_basic_user_file conf.d/htpasswd;
alias /srv/http/;
autoindex on;
}
}
}

View File

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

View File

@@ -0,0 +1,9 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
# Settings for keepalive module for upstreams
proxy_http_version 1.1;
proxy_set_header Connection "";
# Requests sent with early data are subject to replay attacks so the application needs to protect against that by using the Early-Data header.
# proxy_set_header Early-Data $ssl_early_data;

View File

@@ -0,0 +1,3 @@
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
ssl_prefer_server_ciphers on;

View File

@@ -0,0 +1,2 @@
dependencies:
- syslog

View File

@@ -0,0 +1,55 @@
# - name: Create directories
# file:
# name: "{{ item }}"
# state: directory
# mode: 0755
# owner: root
# group: wheel
# loop:
# - /foo/bar
# - name: Install scripts
# copy:
# src: "files/{{ item.src }}"
# dest: "{{ item.dest }}"
# mode: 0755
# owner: root
# group: wheel
# loop:
# - src: foo.bash
# dest: /usr/local/bin/foo
# - name: Install Configuration
# copy:
# src: "files/{{ item.src }}"
# dest: "{{ item.dest }}"
# mode: 0600
# owner: root
# group: wheel
# loop:
# - src: foo.conf
# dest: /usr/local/etc/foo.conf
# - name: Clone Source
# git:
# repo: "https://foo.bar/baz.git"
# dest: /foo/bar
# version: "v1.0.2"
# force: true
# diff: false
- import_tasks: tasks/freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/linux.yaml
when: 'os_flavor == "linux"'
# - include_tasks:
# file: tasks/peruser.yaml
# apply:
# become: yes
# become_user: "{{ initialize_user }}"
# when: users is defined
# loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
# loop_control:
# loop_var: initialize_user

View File

@@ -0,0 +1,81 @@
- name: Create www group
group:
name: www
- name: Create www user
user:
name: www
home: /srv/http
createhome: false
group: www
- name: Create directories
file:
name: "{{ item }}"
state: directory
mode: 0755
owner: root
group: wheel
loop:
- /momlaptop.fizz.buzz
- /etc/rc.conf.d
- /usr/local/etc/nginx/conf.d
- name: Create directories
file:
name: "{{ item }}"
state: directory
mode: 0755
owner: www
group: www
loop:
- /srv/http
- name: Install packages
package:
name:
- nginx
state: present
# validate fails because nginx config relies on a local mime.types
- name: Install Configuration
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0644
owner: root
group: wheel
loop:
- src: nginx.conf
dest: /usr/local/etc/nginx/nginx.conf
- src: headers.include
dest: /usr/local/etc/nginx/conf.d/headers.include
- src: proxy.include
dest: /usr/local/etc/nginx/conf.d/proxy.include
- src: tls_settings.include
dest: /usr/local/etc/nginx/conf.d/tls_settings.include
# Generate htpasswd with `htpasswd -c files/htpasswd user1`
# or `printf "USER:$(openssl passwd)\n" >> files/htpasswd`
- src: htpasswd
dest: /usr/local/etc/nginx/conf.d/htpasswd
- name: Install newsyslog configuration
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0600
owner: root
group: wheel
loop:
- src: newsyslog.conf
dest: /usr/local/etc/newsyslog.conf.d/nginx.conf
- name: Install service configuration
copy:
src: "files/{{ item }}_rc.conf"
dest: "/etc/rc.conf.d/{{ item }}"
mode: 0644
owner: root
group: wheel
loop:
- nginx

View File

@@ -0,0 +1,29 @@
# - 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:
# - foo
# - name: Update cache
# when: buildaur.changed
# pacman:
# name: []
# state: present
# update_cache: true
# - name: Install packages
# package:
# name:
# - foo
# state: present
# - name: Enable services
# systemd:
# enabled: yes
# name: "{{ item }}"
# daemon_reload: yes
# loop:
# - foo.service

View File

@@ -0,0 +1,2 @@
- import_tasks: tasks/common.yaml
# when: foo is defined

View File

@@ -0,0 +1,29 @@
- include_role:
name: per_user
# - name: Create directories
# file:
# name: "{{ account_homedir.stdout }}/{{ item }}"
# state: directory
# mode: 0700
# owner: "{{ account_name.stdout }}"
# group: "{{ group_name.stdout }}"
# loop:
# - ".config/foo"
# - name: Copy files
# copy:
# src: "files/{{ item.src }}"
# dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
# mode: 0600
# owner: "{{ account_name.stdout }}"
# group: "{{ group_name.stdout }}"
# loop:
# - src: foo.conf
# dest: .config/foo/foo.conf
- import_tasks: tasks/peruser_freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/peruser_linux.yaml
when: 'os_flavor == "linux"'

View File

@@ -6,6 +6,7 @@
"subnet4": [ "subnet4": [
{ {
"subnet": "10.215.1.0/24", "subnet": "10.215.1.0/24",
"id": 1,
"pools": [ { "pool": "10.215.1.10-10.215.1.200" } ], "pools": [ { "pool": "10.215.1.10-10.215.1.200" } ],
"option-data": [ "option-data": [
{ {
@@ -61,12 +62,12 @@
}, },
{ {
// admin_git // admin_git
"hw-address": "58:9c:fc:10:fc:5a", "hw-address": "06:4c:9f:0e:e2:cc",
"ip-address": "10.215.1.210" "ip-address": "10.215.1.210"
}, },
{ {
// public_dns // public_dns
"hw-address": "58:9c:fc:10:ff:80", "hw-address": "06:81:a6:f4:ab:24",
"ip-address": "10.215.1.211" "ip-address": "10.215.1.211"
}, },
{ {
@@ -88,7 +89,59 @@
// bastion - hard-coded in rc.conf, reproduced here to reserve ip // bastion - hard-coded in rc.conf, reproduced here to reserve ip
"hw-address": "06:ca:1a:10:74:09", "hw-address": "06:ca:1a:10:74:09",
"ip-address": "10.215.1.217" "ip-address": "10.215.1.217"
},
{
// momlaptop - hard-coded in rc.conf, reproduced here to reserve ip
"hw-address": "06:85:69:c5:6a:d6",
"ip-address": "10.215.1.218"
},
{
// hydra
"hw-address": "06:84:36:68:03:77",
"ip-address": "10.215.1.219"
},
{
// certificate - hard-coded in rc.conf, reproduced here to reserve ip
"hw-address": "06:7b:e0:08:16:5d",
"ip-address": "10.215.1.220"
},
{
// nix controller0 - hard-coded in nix config, reproduced here to reserve ip
// IPv6: 2620:11f:7001:7:ffff:ffff:0ad7:01dd
"hw-address": "06:7b:e0:08:16:01",
"ip-address": "10.215.1.221"
},
{
// nix controller1 - hard-coded in nix config, reproduced here to reserve ip
// IPv6: 2620:11f:7001:7:ffff:ffff:0ad7:01de
"hw-address": "06:7b:e0:08:16:02",
"ip-address": "10.215.1.222"
},
{
// nix controller2 - hard-coded in nix config, reproduced here to reserve ip
// IPv6: 2620:11f:7001:7:ffff:ffff:0ad7:01df
"hw-address": "06:7b:e0:08:16:03",
"ip-address": "10.215.1.223"
},
{
// nix worker0 - hard-coded in nix config, reproduced here to reserve ip
// IPv6: 2620:11f:7001:7:ffff:ffff:0ad7:01e0
"hw-address": "06:7b:e0:08:16:04",
"ip-address": "10.215.1.224"
},
{
// nix worker1 - hard-coded in nix config, reproduced here to reserve ip
// IPv6: 2620:11f:7001:7:ffff:ffff:0ad7:01e1
"hw-address": "06:7b:e0:08:16:05",
"ip-address": "10.215.1.225"
},
{
// nix worker2 - hard-coded in nix config, reproduced here to reserve ip
// IPv6: 2620:11f:7001:7:ffff:ffff:0ad7:01e2
"hw-address": "06:7b:e0:08:16:06",
"ip-address": "10.215.1.226"
} }
] ]
} }
], ],

View File

@@ -1,19 +1,3 @@
- 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:
- nvm
- name: Update cache
when: buildaur.changed
pacman:
name: []
state: present
update_cache: true
- name: Install packages - name: Install packages
package: package:
name: name:

View File

@@ -1,3 +1,11 @@
profile office {
output eDP-1 disable
output "Dell Inc. DELL C2722DE 6PH6T83" enable
}
profile office2 {
output eDP-1 disable
output "BOE 0x0BCA Unknown" enable
}
profile docked { profile docked {
output eDP-1 disable output eDP-1 disable
output "Dell Inc. DELL U3014 P1V6N35M329L" enable output "Dell Inc. DELL U3014 P1V6N35M329L" enable

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
kubectl get pipelinerun --all-namespaces -o go-template='{{range .items}}{{.metadata.namespace}}/{{.metadata.name}}{{"\n"}}{{end}}' | while read p; do namespace=$(cut -d '/' -f 1 <<<"$p"); name=$(cut -d '/' -f 2 <<<"$p"); kubectl patch pipelinerun -n "$namespace" "$name" -p '{"metadata":{"finalizers":null}}' --type=merge; done

View File

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

View File

@@ -508,98 +508,372 @@
] ]
}, },
"key_leds": { "key_leds": {
"K00": null, "K00": [
"K01": null, 0,
"K02": null, 0
"K03": null, ],
"K04": null, "K01": [
"K05": null, 0,
"K06": null, 0
"K07": null, ],
"K08": null, "K02": [
"K09": null, 0,
"K0A": null, 0
"K0B": null, ],
"K0C": null, "K03": [
"K0D": null, 0,
"K0E": null, 0
"K10": null, ],
"K11": null, "K04": [
"K12": null, 0,
"K13": null, 0
"K14": null, ],
"K15": null, "K05": [
"K16": null, 0,
"K17": null, 0
"K18": null, ],
"K19": null, "K06": [
"K1A": null, 0,
"K1B": null, 0
"K1C": null, ],
"K1D": null, "K07": [
"K1E": null, 0,
"K20": null, 0
"K21": null, ],
"K22": null, "K08": [
"K23": null, 0,
"K24": null, 0
"K25": null, ],
"K26": null, "K09": [
"K27": null, 0,
"K28": null, 0
"K29": null, ],
"K2A": null, "K0A": [
"K2B": null, 0,
"K2C": null, 0
"K2D": null, ],
"K2E": null, "K0B": [
"K30": null, 0,
"K31": null, 0
"K32": null, ],
"K33": null, "K0C": [
"K34": null, 0,
"K35": null, 0
"K36": null, ],
"K37": null, "K0D": [
"K38": null, 0,
"K39": null, 0
"K3A": null, ],
"K3B": null, "K0E": [
"K3C": null, 0,
"K3D": null, 0
"K40": null, ],
"K41": null, "K10": [
"K42": null, 0,
"K43": null, 0
"K44": null, ],
"K45": null, "K11": [
"K46": null, 0,
"K47": null, 0
"K48": null, ],
"K49": null, "K12": [
"K4A": null, 0,
"K4B": null, 0
"K4C": null, ],
"K50": null, "K13": [
"K51": null, 0,
"K52": null, 0
"K53": null, ],
"K54": null, "K14": [
"K55": null, 0,
"K56": null, 0
"K57": null, ],
"K58": null, "K15": [
"K59": null, 0,
"K5A": null, 0
"K5B": null ],
"K16": [
0,
0
],
"K17": [
0,
0
],
"K18": [
0,
0
],
"K19": [
0,
0
],
"K1A": [
0,
0
],
"K1B": [
0,
0
],
"K1C": [
0,
0
],
"K1D": [
0,
0
],
"K1E": [
0,
0
],
"K20": [
0,
0
],
"K21": [
0,
0
],
"K22": [
0,
0
],
"K23": [
0,
0
],
"K24": [
0,
0
],
"K25": [
0,
0
],
"K26": [
0,
0
],
"K27": [
0,
0
],
"K28": [
0,
0
],
"K29": [
0,
0
],
"K2A": [
0,
0
],
"K2B": [
0,
0
],
"K2C": [
0,
0
],
"K2D": [
0,
0
],
"K2E": [
0,
0
],
"K30": [
0,
0
],
"K31": [
0,
0
],
"K32": [
0,
0
],
"K33": [
0,
0
],
"K34": [
0,
0
],
"K35": [
0,
0
],
"K36": [
0,
0
],
"K37": [
0,
0
],
"K38": [
0,
0
],
"K39": [
0,
0
],
"K3A": [
0,
0
],
"K3B": [
0,
0
],
"K3C": [
0,
0
],
"K3D": [
0,
0
],
"K40": [
0,
0
],
"K41": [
0,
0
],
"K42": [
0,
0
],
"K43": [
0,
0
],
"K44": [
0,
0
],
"K45": [
0,
0
],
"K46": [
0,
0
],
"K47": [
0,
0
],
"K48": [
0,
0
],
"K49": [
0,
0
],
"K4A": [
0,
0
],
"K4B": [
0,
0
],
"K4C": [
0,
0
],
"K50": [
0,
0
],
"K51": [
0,
0
],
"K52": [
0,
0
],
"K53": [
0,
0
],
"K54": [
0,
0
],
"K55": [
0,
0
],
"K56": [
0,
0
],
"K57": [
0,
0
],
"K58": [
0,
0
],
"K59": [
0,
0
],
"K5A": [
0,
0
],
"K5B": [
0,
0
]
}, },
"layers": [ "layers": [
{ {
"mode": [ "mode": [
7, 0,
127 127
], ],
"brightness": 135, "brightness": 109,
"color": [
0,
0
]
},
{
"mode": [
13,
127
],
"brightness": 109,
"color": [
21,
255
]
},
{
"mode": [
13,
127
],
"brightness": 109,
"color": [ "color": [
142, 142,
255 255
@@ -610,29 +884,7 @@
13, 13,
127 127
], ],
"brightness": 135, "brightness": 109,
"color": [
142,
255
]
},
{
"mode": [
13,
127
],
"brightness": 135,
"color": [
142,
255
]
},
{
"mode": [
13,
127
],
"brightness": 135,
"color": [ "color": [
142, 142,
255 255

View File

@@ -0,0 +1,7 @@
# linfi:
# enabled: true
# zfs_dataset: zroot/freebsd/current/vm/linfi
# zfs_mountpoint: /vm/linfi
# driver_blocklist: "if_iwm if_iwlwifi"
# pci_blocklist: "1/0/0"
# amd: true

View File

@@ -0,0 +1,239 @@
#!/usr/local/bin/bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Share a host directory to the guest via 9pfs.
#
# Inside the VM run:
# mount -t virtfs -o trans=virtio sharename /some/vm/path
# mount -t 9p -o cache=mmap -o msize=512000 sharename /mnt/9p
# mount -t 9p -o trans=virtio,cache=mmap,msize=512000 sharename /path/to/mountpoint
# bhyve_options="-s 28,virtio-9p,sharename=/"
# Enable Sound
# bhyve_options="-s 16,hda,play=/dev/dsp,rec=/dev/dsp"
# Example usage:
#
# doas bhyve_netgraph_bridge create-disk zdata/vm/poudriere /vm/poudriere 10
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere /vm/iso/FreeBSD-13.2-RELEASE-amd64-bootonly.iso
# doas bhyve_netgraph_bridge start poudriere zdata/vm/poudriere /vm/poudriere
: ${VERBOSE:="NO"} # or YES
: ${CPU_CORES:="1"}
: ${MEMORY:="1G"}
: ${NETWORK:="NAT"} # or RAW or BOTH
: ${IP_RANGE:="10.215.1.1/24"} # Ignored for RAW networks
: ${INTERFACE_NAME:="linfi_host"} # or the external interface like lagg0 for RAW networks
: ${BRIDGE_NAME:="bridge_$INTERFACE_NAME"} # or bridge_raw for RAW networks
: ${VNC_ENABLE:="NO"}
: ${VNC_LISTEN:="127.0.0.1:5900"}
: ${VNC_WIDTH:="1920"}
: ${VNC_HEIGHT:="1080"}
: ${PASSTHROUGH:="1/0/0"}
if [ "$VERBOSE" = "YES" ]; then
set -x
fi
############## Setup #########################
function cleanup {
for vm in "${vms[@]}"; do
log "Destroying bhyve vm $vm"
bhyvectl "--vm=$vm" --destroy
log "Destroyed bhyve vm $vm"
done
}
vms=()
for sig in EXIT; do
trap "set +e; sleep 10; cleanup" "$sig"
done
function die {
local status_code="$1"
shift
(>&2 echo "${@}")
exit "$status_code"
}
function log {
(>&2 echo "${@}")
}
############## Program #########################
function main {
local cmd="$1"
shift 1
if [ "$cmd" = "create-disk" ]; then
create_disk "${@}"
elif [ "$cmd" = "start" ]; then
start_vm "${@}"
else
die 1 "Unrecognized command $cmd"
fi
}
function create_disk {
local zfs_path="$1"
local mount_path="$2"
local gigabytes="$3"
zfs create -o "mountpoint=$mount_path" "$zfs_path"
cp /usr/local/share/edk2-bhyve/BHYVE_UEFI_VARS.fd "${mount_path}/"
tee "${mount_path}/settings" <<EOF
CPU_CORES="$CPU_CORES"
MEMORY="$MEMORY"
NETWORK="$NETWORK"
IP_RANGE="$IP_RANGE"
BRIDGE_NAME="$BRIDGE_NAME"
INTERFACE_NAME="$INTERFACE_NAME"
EOF
zfs create -s "-V${gigabytes}G" -o volmode=dev -o primarycache=metadata -o secondarycache=none -o volblocksize=64K "$zfs_path/disk0"
}
function start_vm {
local name="$1"
local zfs_path="$2"
local mount_path="$3"
local mount_cd="${4:-}"
if [ -e "${mount_path}/settings" ]; then
source "${mount_path}/settings"
fi
local additional_args=()
local host_interface_name="linfi_host"
local bridge_name="linfi_bridge"
assert_bridge "$host_interface_name" "$bridge_name"
local mac_address
mac_address=$(calculate_mac_address "$name")
local bridge_link_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}")
# -H release the CPU when guest issues HLT instruction. Otherwise 100% of core will be consumed.
# -s 3,ahci-cd,/vm/.iso/archlinux-2023.04.01-x86_64.iso \
# -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080,wait \
# -s 29,fbuf,tcp=0.0.0.0:5900,w=1920,h=1080 \
# TODO: Look into using nmdm instead of stdio for serial console
if [ -n "$mount_cd" ]; then
additional_args+=("-s" "5,ahci-cd,$mount_cd")
fi
if [ "$VNC_ENABLE" = "YES" ]; then
additional_args+=("-s" "29,fbuf,tcp=$VNC_LISTEN,w=$VNC_WIDTH,h=$VNC_HEIGHT")
fi
vms+=("$name")
while true; do
set -x
set +e
bhyve \
-D \
-c sockets=1,cores=1,threads=1 \
-m "$MEMORY" \
-H \
-w \
-o 'rtc.use_localtime=false' \
-s 0,hostbridge \
-s "4,nvme,/dev/zvol/${zfs_path}/disk0" \
-S \
-s "7,passthru,${PASSTHROUGH}" \
-s 30,xhci,tablet \
-s 31,lpc -l com1,stdio \
-l "bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd,${mount_path}/BHYVE_UEFI_VARS.fd" \
-U '08421734-875e-11ef-a0f3-f426796942c7' \
"${additional_args[@]}" \
"$name"
local exit_code=$?
set -e
set +x
if [ $exit_code -eq 0 ]; then
echo "Rebooting."
sleep 5
elif [ $exit_code -eq 1 ]; then
echo "Powered off."
break
elif [ $exit_code -eq 2 ]; then
echo "Halted."
break
elif [ $exit_code -eq 3 ]; then
echo "Triple fault."
break
elif [ $exit_code -eq 4 ]; then
echo "Exited due to an error."
break
fi
done
}
function detect_available_link {
local bridge_name="$1"
local linknum=1
while true; do
local link_name="link${linknum}"
if ! ng_exists "${bridge_name}:${link_name}"; then
echo "$link_name"
return
fi
linknum=$((linknum + 1))
if [ "$linknum" -gt 90 ]; then
(>&2 echo "No available links on bridge $bridge_name")
exit 1
fi
done
}
function assert_bridge {
local host_interface_name="$1"
local bridge_name="$2"
if ! ng_exists "${bridge_name}:"; then
ngctl -d -f - <<EOF
mkpeer . eiface hook ether
name .:hook $host_interface_name
EOF
ngctl -d -f - <<EOF
mkpeer ${host_interface_name}: bridge ether link0
name ${host_interface_name}:ether $bridge_name
EOF
ifconfig $(ngctl msg "${host_interface_name}:" getifname | grep Args | cut -d '"' -f 2) name "${host_interface_name}" 192.168.253.2/24 up
route add default 192.168.253.1
fi
}
function ng_exists {
ngctl status "${1}" >/dev/null 2>&1
}
function calculate_mac_address {
local name="$1"
local source
source=$(md5 -r -s "$name" | awk '{print $1}')
echo "06:${source:0:2}:${source:2:2}:${source:4:2}:${source:6:2}:${source:8:2}"
}
function find_available_port {
local start_port="$1"
local port="$start_port"
while true; do
sockstat -P tcp -p 443
port=$((port + 1))
done
}
function ngctlcat {
if [ "$VERBOSE" = "YES" ]; then
tee /dev/tty | ngctl -d -f -
else
ngctl -d -f -
fi
}
main "${@}"

View File

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

Some files were not shown because too many files have changed in this diff Show More