working pppoe with readiness notification on ip-up
This commit is contained in:
parent
47f8fa9797
commit
5d51d15b86
2 changed files with 51 additions and 39 deletions
|
@ -4,45 +4,40 @@
|
|||
, busybox
|
||||
, ppp
|
||||
, pppoe
|
||||
, writeShellScript
|
||||
, writeAshScript
|
||||
} :
|
||||
let
|
||||
inherit (liminix.services) longrun;
|
||||
ip-up = writeShellScript "ip-up" ''
|
||||
action=$1
|
||||
env > /run/udhcp.values
|
||||
|
||||
set_address() {
|
||||
ip address replace $ip/$mask dev $interface
|
||||
mkdir -p data/outputs
|
||||
for i in lease mask ip router siaddr dns serverid subnet opt53 interface ; do
|
||||
echo ''${!i} > data/outputs/$i
|
||||
done
|
||||
}
|
||||
case $action in
|
||||
deconfig)
|
||||
ip address flush $interface
|
||||
ip link set up dev $interface
|
||||
;;
|
||||
bound)
|
||||
# this doesn't actually replace, it adds a new address.
|
||||
set_address
|
||||
;;
|
||||
renew)
|
||||
set_address
|
||||
;;
|
||||
nak)
|
||||
echo "received NAK on $interface"
|
||||
;;
|
||||
esac
|
||||
'';
|
||||
|
||||
in
|
||||
interface: {
|
||||
synchronous ? false
|
||||
, ppp-options ? []
|
||||
, ...
|
||||
} @ args: longrun {
|
||||
name = "${interface.device}.ppppoe";
|
||||
run = "${ppp}/bin/pppd pty '${pppoe}/bin/pppoe -I ${interface.device}' ${lib.concatStringsSep " " ppp-options}" ;
|
||||
} @ args:
|
||||
let
|
||||
name = "${interface.device}.pppoe";
|
||||
ip-up = writeAshScript "ip-up" {} ''
|
||||
outputs=/run/service-state/${name}.service/
|
||||
mkdir -p $outputs
|
||||
(cd $outputs
|
||||
echo $1 > ifname
|
||||
echo $2 > tty
|
||||
echo $3 > speed
|
||||
echo $4 > address
|
||||
echo $5 > peer-address
|
||||
)
|
||||
echo >/proc/self/fd/10
|
||||
'';
|
||||
ppp-options' = ppp-options ++ [
|
||||
"ip-up-script" ip-up
|
||||
"ipparam" name
|
||||
"nodetach"
|
||||
];
|
||||
|
||||
in
|
||||
longrun {
|
||||
inherit name;
|
||||
run = "${ppp}/bin/pppd pty '${pppoe}/bin/pppoe -I ${interface.device}' ${lib.concatStringsSep " " ppp-options'}" ;
|
||||
notification-fd = 10;
|
||||
dependencies = [ interface ];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue