2022-09-25 12:54:31 +02:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, lib
|
|
|
|
, busybox
|
|
|
|
, ppp
|
|
|
|
, pppoe
|
2022-09-25 22:12:23 +02:00
|
|
|
, writeAshScript
|
2022-09-25 12:54:31 +02:00
|
|
|
} :
|
|
|
|
let
|
|
|
|
inherit (liminix.services) longrun;
|
|
|
|
in
|
|
|
|
interface: {
|
|
|
|
synchronous ? false
|
|
|
|
, ppp-options ? []
|
|
|
|
, ...
|
2022-09-25 22:12:23 +02:00
|
|
|
} @ args:
|
|
|
|
let
|
|
|
|
name = "${interface.device}.pppoe";
|
|
|
|
ip-up = writeAshScript "ip-up" {} ''
|
2022-09-27 23:35:29 +02:00
|
|
|
outputs=/run/service-state/${name}/
|
2022-09-25 22:12:23 +02:00
|
|
|
mkdir -p $outputs
|
|
|
|
(cd $outputs
|
|
|
|
echo $1 > ifname
|
|
|
|
echo $2 > tty
|
|
|
|
echo $3 > speed
|
|
|
|
echo $4 > address
|
|
|
|
echo $5 > peer-address
|
2023-02-25 21:31:41 +01:00
|
|
|
echo $DNS1 > ns1
|
|
|
|
echo $DNS1 > ns2
|
2022-09-25 22:12:23 +02:00
|
|
|
)
|
|
|
|
echo >/proc/self/fd/10
|
|
|
|
'';
|
|
|
|
ppp-options' = ppp-options ++ [
|
|
|
|
"ip-up-script" ip-up
|
|
|
|
"ipparam" name
|
|
|
|
"nodetach"
|
2023-02-25 21:31:41 +01:00
|
|
|
"usepeerdns"
|
2022-09-27 23:57:06 +02:00
|
|
|
"logfd" "2"
|
2022-09-25 22:12:23 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
in
|
|
|
|
longrun {
|
|
|
|
inherit name;
|
|
|
|
run = "${ppp}/bin/pppd pty '${pppoe}/bin/pppoe -I ${interface.device}' ${lib.concatStringsSep " " ppp-options'}" ;
|
|
|
|
notification-fd = 10;
|
|
|
|
dependencies = [ interface ];
|
2022-09-25 12:54:31 +02:00
|
|
|
}
|