Blob


1 #!/bin/sh
3 install_doas() {
4 node doas.conf && nodeinstall -m 600 -o root:wheel doas.conf /etc
5 }
7 install_login() {
8 node login.conf && nodeinstall -m 644 -o root:wheel login.conf /etc
9 }
11 install_hosts() {
12 node hosts && nodeinstall -m 644 -o root:wheel hosts /etc
13 }
15 install_sysctl() {
16 node sysctl.conf && nodeinstall -m 644 -o root:wheel sysctl.conf /etc &&
17 sysctl -f /etc/sysctl.conf
18 }
20 install_dwmcron() {
21 for cron in daily.local weekly.local monthly.local; do
22 node "$cron" && nodeinstall -m 644 -o root:wheel "$cron" /etc
23 done
24 }
26 install_installurl() {
27 node installurl && nodeinstall -m 644 -o root:wheel installurl /etc
28 }
30 networking_myname() {
31 node myname && nodeinstall -m 644 -o root:wheel myname /etc
32 }
34 networking_mygate() {
35 node mygate && nodeinstall -m 644 -o root:wheel mygate /etc
36 }
38 networking_hostname_if() {
39 for interface in "$(nodedir)"/hostname.*; do
40 ifname=${interface##*.}
41 install -m 640 -o root:wheel "$interface" /etc && sh /etc/netstart "$ifname"
42 done
43 }
45 networking_dhcpcd() {
46 node dhcpcd.conf && nodeinstall -m 644 -o root:wheel dhcpcd.conf /etc
47 }
49 networking_rad() {
50 node rad.conf && nodeinstall -m 644 -o root:wheel rad.conf /etc
51 }
53 firewall_pf() {
54 node pf.conf && nodeinstall -m 600 -o root:wheel pf.conf /etc &&
55 pfctl -nf /etc/pf.conf && pfctl -ef /etc/pf.conf
56 }
58 service_sshd() {
59 node ssh/ssh_config && nodeinstall -m 644 -o root:wheel ssh/ssh_config /etc/ssh
60 node ssh/sshd_config && nodeinstall -m 644 -o root:wheel ssh/sshd_config /etc/ssh &&
61 sshd -t && rcctl enable sshd && rcctl restart sshd
62 }
64 service_dhcpd() {
65 node dhcpd.conf && nodeinstall -m 640 -o root:wheel dhcpd.conf /etc &&
66 dhcpd -n && rcctl enable dhcpd && rcctl restart dhcpd
67 }
69 service_ntpd() {
70 node ntpd.conf && nodeinstall -m 640 -o root:wheel ntpd.conf /etc &&
71 ntpd -n && rcctl enable ntpd && rcctl restart ntpd
72 }
74 service_httpd() {
75 node httpd.conf && nodeinstall -m 644 -o root:wheel httpd.conf /etc &&
76 httpd -n && rcctl enable httpd && rcctl restart httpd
77 }
79 service_acme_client() {
80 node acme-client.conf && nodeinstall -m 640 -o root:wheel acme-client.conf /etc &&
81 acme-client -n
82 # TODO: crontab
83 }
85 service_unwind() {
86 node unwind.conf &&
87 unwind -nf "$(nodedir)/unwind.conf" &&
88 nodeinstall -m 644 -o root:wheel unwind.conf /etc &&
89 rcctl enable unwind && rcctl restart unwind
90 }
92 service_apmd() {
93 if ! node apmd.ignore; then
94 if ! rcctl get apmd flags | grep -qe '-A'; then
95 rcctl enable apmd
96 rcctl set apmd flags -A
97 rcctl restart apmd
98 fi
99 fi
102 # shellcheck disable=SC2046
103 packages_local() {
104 node packages.local && nodeinstall -m 640 -o root:wheel packages.local /etc &&
105 pkg_add $(cat /etc/packages.local)
108 state_storage_devices() {
109 dmesg | grep -e ^sd -e ^wd
112 state_storage_disknames() {
113 sysctl hw.disknames
116 state_storage_disklabel() (
117 drives=$(
118 sysctl -n hw.disknames | tr , \\n |
119 awk -F: '{ print $1 }'
121 for drive in $drives; do
122 disklabel "$drive"
123 done
126 state_firmware_upgrades() {
127 fw_update -n
130 state_system_patches() {
131 syspatch -c
134 state_packages_upgrades() {
135 pkg_add -xnu
138 state_packages_repository() {
139 cat /etc/installurl
142 state_networking_interfaces() {
143 ifconfig -a