In my case, the laptop can be start in two states :

-> Start with the network cable plug in , then there are no problem for the
nis client to connect to the master
-> Start without the network cable plugin, then the ypbind doesn't stop and
the use of computer correctly is no possible (login + command latency :
ypbind tried to connect to the master in loop)


And as the use of laptop it can be use on one place or another, but i
understand your advice :)

I make a systemd service who start or stop nis service in fonction of the
network cable (it is less dirty that modify /etc/init.d/nis), here the
script who do it :

#!/bin/bash

export PATH=/bin:/usr/bin

cat << EOF > /etc/systemd/system/nisplus.service
[Unit]
Description=Lance service nis si cable up
Documentation=man:interfaces(5) man:ifup(8)
DefaultDependencies=no
After=network-online.target
After=rpcbind.target
After=remote-fs.target


[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutStartSec=2min
ExecStart=/usr/sbin/nispluscheck.sh

[Install]
WantedBy=graphical.target
EOF

cat << EOF > /usr/sbin/nispluscheck.sh
#!/bin/bash

export PATH=/bin:/usr/bin

if [ \$(cat /sys/class/net/eth0/carrier) -eq 1 ]
        then
        chmod +x /usr/sbin/ypbind
        /etc/init.d/nis start
        else
        killall -9 ypbind
        chmod -x /usr/sbin/ypbind
        /etc/init.d/nis stop
fi
EOF

chmod 755 /usr/sbin/nispluscheck.sh

systemctl daemon-reload
systemctl enable nisplus.service

exit 0

If you know a way to timeout the ypbind process i bought it.

thanks for your time

Reply via email to