1
0

Compare commits

..

No commits in common. "9dd3cf23b4ce78820e1b65fedc6242a403b2cb15" and "91e957ced7fc6c83caadbaa50495f8c04ef46f4a" have entirely different histories.

8 changed files with 6 additions and 184 deletions

View File

@ -2137,11 +2137,10 @@ Thu Aug 31 23:53:54 BST 2023
[done] - packet forwarding [done] - packet forwarding
- dhcp6 client - dhcp6 client
- what to do with acquire-{wan,lan} scripts? - what to do with acquire-{wan,lan} scripts?
- resolvconf
- [done] anything in vanilla-configuration ditto - [done] anything in vanilla-configuration ditto
- packet forwarding - packet forwarding
- and arhcive - and arhcive
- [not doing] rsync - rsync
- [done] watchdog - [done] watchdog
- [done] mount - [done] mount
- nftables syntax error - nftables syntax error
@ -2150,7 +2149,7 @@ Thu Aug 31 23:53:54 BST 2023
- [done] services for liminix.networking - [done] services for liminix.networking
- [done] write a blog entry - [done] write a blog entry
- [done] ntp is not setting the time - [done] ntp is not setting the time
- [done] static dhcp(6) lease support reqd for dogfooding - static dhcp(6) lease support reqd for dogfooding
Sat Sep 2 21:35:41 BST 2023 Sat Sep 2 21:35:41 BST 2023
@ -2248,40 +2247,3 @@ I think we might rename wlan_24 to wlan and wlan_5 to wlan1.
This is on the assumption that almost no device is 5GHz only, so This is on the assumption that almost no device is 5GHz only, so
would make it easier to write a basic wlan example that works would make it easier to write a basic wlan example that works
both on 2.4GHz boards and dual radio boards both on 2.4GHz boards and dual radio boards
Mon Sep 4 23:15:26 BST 2023
If dhcpcd parsed the update-script output into separate files, half
the complexity of acquire-lan-prefix would go away. The other half is
because it subscribes to changes in the outputs instead of just
running once. Perhaps there's a better way to do that?
Could separate prefixes and addresses something like this...
outputs/prefix/2001\:8b0\:de3a\:40dc\:\:/prefix
outputs/prefix/2001\:8b0\:de3a\:40dc\:\:/length
outputs/prefix/2001\:8b0\:de3a\:40dc\:\:/preferred
outputs/prefix/2001\:8b0\:de3a\:40dc\:\:/valid
outputs/prefix/2001\:8b0\:de3a\:80\:\:/prefix
outputs/prefix/2001\:8b0\:de3a\:80\:\:/length
outputs/prefix/2001\:8b0\:de3a\:80\:\:/preferred
outputs/prefix/2001\:8b0\:de3a\:80\:\:/valid
the directory name is arbitrary as long as it's unique. Might even be better to
remove the colons
outputs/prefix/200108b0de3a40dc/valid
or we could adopt the MS convention and replace with hyphens
outputs/prefix/2001-8b0-de3a-40dc--/prefix
Also: we should write some kind of test for this...
Tue Sep 5 21:36:39 BST 2023
How do we set the cpu governor?

View File

@ -1,32 +0,0 @@
(local lfs (require :lfs))
(fn directory? [pathname]
(= (lfs.symlinkattributes pathname :mode) "directory"))
(fn mktree [pathname]
(if (or (= pathname "") (= pathname "/"))
(error (.. "can't mkdir " pathname)))
(or (directory? pathname)
(let [parent (string.gsub pathname "/[^/]+/?$" "")]
(or (directory? parent) (mktree parent))
(assert (lfs.mkdir pathname)))))
(fn rmtree [pathname]
(case (lfs.symlinkattributes pathname)
nil true
{:mode "directory"}
(do
(each [f (lfs.dir pathname)]
(when (not (or (= f ".") (= f "..")))
(rmtree ( .. pathname "/" f)))
(lfs.rmdir pathname)))
{:mode "file"}
(os.remove pathname)
{:mode "link"}
(os.remove pathname)
unknown
(error (.. "can't remove " pathname " of kind \"" unknown.mode "\""))))
{ : mktree : rmtree }

View File

@ -14,7 +14,6 @@ let packages = [
linotify linotify
anoia anoia
fennel fennel
lua.pkgs.luafilesystem
]; ];
join = ps: builtins.concatStringsSep ";" ps; join = ps: builtins.concatStringsSep ";" ps;
luapath = join (builtins.map (f: luapath = join (builtins.map (f:
@ -35,7 +34,7 @@ in writeScriptBin "fennelrepl" ''
end end
if #arg > 0 then if #arg > 0 then
script = table.remove(arg, 1) script = table.remove(arg, 1)
fennel.dofile(script, {correlate = true}, arg) fennel.dofile(script, {}, arg)
else else
fennel.repl() fennel.repl()
end end

View File

@ -1,26 +0,0 @@
./address/2001-8b0-1111-1111-0-ffff-1234-5678/address:2001:8b0:1111:1111:0:ffff:1234:5678
./address/2001-8b0-1111-1111-0-ffff-1234-5678/len:128
./address/2001-8b0-1111-1111-0-ffff-1234-5678/preferred:3600
./address/2001-8b0-1111-1111-0-ffff-1234-5678/valid:7200
./addresses:2001:8b0:1111:1111:0:ffff:1234:5678/128,3600,7200
./ifname:ppp0
./option_1:000300018cfdf02420eb
./option_2:000300010df0feca0df0
./passthru:00170020200108b0000000000000000000002020200108b0000000000000000000002021
./prefix/2001-8b0-de3a-22/address:2001:8b0:de3a:22::
./prefix/2001-8b0-de3a-22/len:64
./prefix/2001-8b0-de3a-22/preferred:7200
./prefix/2001-8b0-de3a-22/valid:7200
./prefix/2001-8b0-de3a-abcd/address:2001:8b0:de3a:abcd::
./prefix/2001-8b0-de3a-abcd/len:64
./prefix/2001-8b0-de3a-abcd/preferred:7200
./prefix/2001-8b0-de3a-abcd/valid:7200
./prefixes:2001:8b0:de3a:abcd::/64,7200,7200 2001:8b0:de3a:22::/64,7200,7200
./ra_hoplimit:64
./ra_mtu:0
./ra_reachable:0
./ra_retransmit:0
./ra_routes:::/0,fe80::203:97ff:fed6:0,65533,512
./rdnss:2001:8b0::2020 2001:8b0::2021
./server:fe80::203:97ff:fed6:0
./state:bound

View File

@ -1,9 +1,6 @@
(local { : split : merge } (require :anoia))
(local { : view } (require :fennel))
(local { : mktree : rmtree } (require :anoia.fs))
(local state-directory (assert (os.getenv "SERVICE_STATE"))) (local state-directory (assert (os.getenv "SERVICE_STATE")))
(mktree state-directory) (os.execute (.. "mkdir -p " state-directory))
(fn write-value [name value] (fn write-value [name value]
(let [path (.. state-directory "/" name)] (let [path (.. state-directory "/" name)]
@ -13,34 +10,10 @@
(fn write-value-from-env [name] (fn write-value-from-env [name]
(write-value name (os.getenv (string.upper name)))) (write-value name (os.getenv (string.upper name))))
(fn parse-address [str]
(fn parse-extra [s]
(let [out {}]
(each [name val (string.gmatch s ",(.-)=([^,]+)")]
(tset out name val))
out))
(let [(address len preferred valid extra)
(string.match str "(.-)/(%d+),(%d+),(%d+)(.*)$")]
(merge {: address : len : preferred : valid} (parse-extra extra))))
(fn write-addresses [prefix addresses]
(each [_ a (ipairs (split " " addresses))]
(let [address (parse-address a)
keydir (.. prefix (-> address.address
(: :gsub "::$" "")
(: :gsub ":" "-")))]
(mktree (.. state-directory "/" keydir))
(each [k v (pairs address)]
(write-value (.. keydir "/" k) v)))))
;; we remove state before updating to ensure that consumers don't get ;; we remove state before updating to ensure that consumers don't get
;; a half-updated snapshot ;; a half-updated snapshot
(os.remove (.. state-directory "/state")) (os.remove (.. state-directory "/state"))
;; remove parsed addresses/prefixes from any previous run
(rmtree (.. state-directory "/prefix"))
(rmtree (.. state-directory "/address"))
(let [wanted (let [wanted
[ [
:addresses :addresses
@ -75,10 +48,7 @@
:sntp_fqdn :sntp_fqdn
]] ]]
(each [_ n (ipairs wanted)] (each [_ n (ipairs wanted)]
(write-value-from-env n)) (write-value-from-env n)))
(write-addresses "address/" (os.getenv :ADDRESSES))
(write-addresses "prefix/" (os.getenv :PREFIXES)))
(let [[ifname state] arg (let [[ifname state] arg
ready (match state ready (match state

View File

@ -1,29 +0,0 @@
RA_ADDRESSES=
RA_REACHABLE=0
USER=root
CER=
PASSTHRU=00170020200108b0000000000000000000002020200108b0000000000000000000002021
SHLVL=2
SERVER=fe80::203:97ff:fed6:0
HOME=/home/root/
RA_MTU=0
RA_ROUTES=::/0,fe80::203:97ff:fed6:0,65533,512
OPTION_1=000300018cfdf02420eb
NTP_FQDN=
OPTION_2=000300010df0feca0df0
RA_DOMAINS=
DOMAINS=
LOGNAME=root
AFTR=
SIP_IP=
NTP_IP=
PREFIXES="2001:8b0:de3a:abcd::/64,7200,7200 2001:8b0:de3a:22::/64,7200,7200"
RA_HOPLIMIT=64
SHELL=/bin/sh
RA_DNS=
RDNSS="2001:8b0::2020 2001:8b0::2021"
SNTP_IP=
RA_RETRANSMIT=0
SIP_DOMAIN=
PWD=/home/root
ADDRESSES=2001:8b0:1111:1111:0:ffff:1234:5678/128,3600,7200

View File

@ -1,21 +0,0 @@
#!/usr/bin/env sh
set -e
statedir=$(mktemp -d)
cleanup(){
test -n "$statedir" && test -d $statedir && rm -rf $statedir
}
trap 'exit 1' INT HUP QUIT TERM ALRM USR1
trap 'cleanup' EXIT
# call the script twice with different state, to test that it cleans
# out old values when it runs again
(set -a; . ./test.env ; ADDRESSES=2001:80:111:111:0:fff:123:567/128,3600,7200 SERVICE_STATE=$statedir fennelrepl odhcp6-script.fnl ppp0 bound) 10>&1
(set -a; . ./test.env ; SERVICE_STATE=$statedir fennelrepl odhcp6-script.fnl ppp0 bound) 10>&1
(cd $statedir && find . -type f | xargs grep '' | sort) > actual
diff -u expected actual
cmp expected actual

View File

@ -5,11 +5,10 @@ let
liminix-config = ./vanilla-configuration.nix; liminix-config = ./vanilla-configuration.nix;
inherit nixpkgs; inherit nixpkgs;
}); });
here = builtins.toString ./.;
in liminix.buildEnv.overrideAttrs (o: { in liminix.buildEnv.overrideAttrs (o: {
nativeBuildInputs = o.nativeBuildInputs ++ [ (import nixpkgs {}).sphinx ] ; nativeBuildInputs = o.nativeBuildInputs ++ [ (import nixpkgs {}).sphinx ] ;
shellHook = '' shellHook = ''
publish(){ make -C doc html && rsync -azv doc/_build/html/ myhtic.telent.net:/var/www/blogs/www.liminix.org/_site/doc; } publish(){ make -C doc html && rsync -azv doc/_build/html/ myhtic.telent.net:/var/www/blogs/www.liminix.org/_site/doc; }
''; '';
FENNEL_PATH = "${here}/pkgs/?/init.fnl;${here}/pkgs/?.fnl"; FENNEL_PATH = "pkgs/?/init.fnl;pkgs/?.fnl";
}) })