Compare commits
12 Commits
91e957ced7
...
9dd3cf23b4
Author | SHA1 | Date | |
---|---|---|---|
9dd3cf23b4 | |||
4e9227dff3 | |||
eaa45906ff | |||
7fc5d2934d | |||
12e25722fa | |||
09fe21260e | |||
4bd3ccc8fd | |||
3e163d4253 | |||
9487cb2567 | |||
907a9de773 | |||
b25103be2e | |||
353a199ab2 |
42
THOUGHTS.txt
42
THOUGHTS.txt
@ -2137,10 +2137,11 @@ Thu Aug 31 23:53:54 BST 2023
|
||||
[done] - packet forwarding
|
||||
- dhcp6 client
|
||||
- what to do with acquire-{wan,lan} scripts?
|
||||
- resolvconf
|
||||
- [done] anything in vanilla-configuration ditto
|
||||
- packet forwarding
|
||||
- and arhcive
|
||||
- rsync
|
||||
- [not doing] rsync
|
||||
- [done] watchdog
|
||||
- [done] mount
|
||||
- nftables syntax error
|
||||
@ -2149,7 +2150,7 @@ Thu Aug 31 23:53:54 BST 2023
|
||||
- [done] services for liminix.networking
|
||||
- [done] write a blog entry
|
||||
- [done] ntp is not setting the time
|
||||
- static dhcp(6) lease support reqd for dogfooding
|
||||
- [done] static dhcp(6) lease support reqd for dogfooding
|
||||
|
||||
Sat Sep 2 21:35:41 BST 2023
|
||||
|
||||
@ -2247,3 +2248,40 @@ 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
|
||||
would make it easier to write a basic wlan example that works
|
||||
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?
|
||||
|
||||
|
||||
|
||||
|
32
pkgs/anoia/fs.fnl
Normal file
32
pkgs/anoia/fs.fnl
Normal file
@ -0,0 +1,32 @@
|
||||
(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 }
|
@ -14,6 +14,7 @@ let packages = [
|
||||
linotify
|
||||
anoia
|
||||
fennel
|
||||
lua.pkgs.luafilesystem
|
||||
];
|
||||
join = ps: builtins.concatStringsSep ";" ps;
|
||||
luapath = join (builtins.map (f:
|
||||
@ -34,7 +35,7 @@ in writeScriptBin "fennelrepl" ''
|
||||
end
|
||||
if #arg > 0 then
|
||||
script = table.remove(arg, 1)
|
||||
fennel.dofile(script, {}, arg)
|
||||
fennel.dofile(script, {correlate = true}, arg)
|
||||
else
|
||||
fennel.repl()
|
||||
end
|
||||
|
26
pkgs/odhcp-script/expected
Normal file
26
pkgs/odhcp-script/expected
Normal file
@ -0,0 +1,26 @@
|
||||
./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
|
@ -1,6 +1,9 @@
|
||||
(local { : split : merge } (require :anoia))
|
||||
(local { : view } (require :fennel))
|
||||
(local { : mktree : rmtree } (require :anoia.fs))
|
||||
|
||||
(local state-directory (assert (os.getenv "SERVICE_STATE")))
|
||||
(os.execute (.. "mkdir -p " state-directory))
|
||||
(mktree state-directory)
|
||||
|
||||
(fn write-value [name value]
|
||||
(let [path (.. state-directory "/" name)]
|
||||
@ -10,10 +13,34 @@
|
||||
(fn write-value-from-env [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
|
||||
;; a half-updated snapshot
|
||||
(os.remove (.. state-directory "/state"))
|
||||
|
||||
;; remove parsed addresses/prefixes from any previous run
|
||||
(rmtree (.. state-directory "/prefix"))
|
||||
(rmtree (.. state-directory "/address"))
|
||||
|
||||
(let [wanted
|
||||
[
|
||||
:addresses
|
||||
@ -48,7 +75,10 @@
|
||||
:sntp_fqdn
|
||||
]]
|
||||
(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
|
||||
ready (match state
|
||||
|
29
pkgs/odhcp-script/test.env
Normal file
29
pkgs/odhcp-script/test.env
Normal file
@ -0,0 +1,29 @@
|
||||
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
|
21
pkgs/odhcp-script/test.sh
Executable file
21
pkgs/odhcp-script/test.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/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
|
@ -5,10 +5,11 @@ let
|
||||
liminix-config = ./vanilla-configuration.nix;
|
||||
inherit nixpkgs;
|
||||
});
|
||||
here = builtins.toString ./.;
|
||||
in liminix.buildEnv.overrideAttrs (o: {
|
||||
nativeBuildInputs = o.nativeBuildInputs ++ [ (import nixpkgs {}).sphinx ] ;
|
||||
shellHook = ''
|
||||
publish(){ make -C doc html && rsync -azv doc/_build/html/ myhtic.telent.net:/var/www/blogs/www.liminix.org/_site/doc; }
|
||||
'';
|
||||
FENNEL_PATH = "pkgs/?/init.fnl;pkgs/?.fnl";
|
||||
FENNEL_PATH = "${here}/pkgs/?/init.fnl;${here}/pkgs/?.fnl";
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user