the following patch is broken at line 111. i implemented if-then
statements to adapt commands to the init system installed, but am
unsure how to call the bit that starts network manager from inside an
if-then statement. perhaps something better could be used like a global
variable stating the init system. i'm not sure and would love feedback
---
scripts/f_networks | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/scripts/f_networks b/scripts/f_networks
index 88e61f8..2563bb6 100755
--- a/scripts/f_networks
+++ b/scripts/f_networks
@@ -50,7 +50,12 @@ installpolkitrule() {
});
' | sudo tee "$TARGETFILE"
sudo chmod -R +r "$(dirname "$TARGETFILE")"
- sudo addgroup "$USER" plugdev
+ if ps --no-headers -o comm 1 | grep openrc; then
+ sudo addgroup "$USER" plugdev
+ elif ps --no-headers -o comm 1 | grep systemd; then
+ sudo groupadd plugdev
+ sudo gpasswd -a "$USER" plugdev
+ fi
}
}
@@ -101,13 +106,27 @@ networkslist() {
}
ensurenmrunning() {
- rc-service networkmanager status | grep started &&
- rc-service ntpd status | grep started ||
+ if ps --no-headers -o comm 1 | grep openrc; then
+ rc-service networkmanager status | grep started &&
+ rc-service ntpd status | grep started ||
+ elif ps --no-headers -o comm 1 | grep systemd; then
+ systemctl status NetworkManager | grep running &&
+ systemctl status ntpd | grep running ||
+ fi
+
{
- sudo /etc/init.d/networkmanager start
- sudo /etc/init.d/ntpd start
- sudo rc-update add networkmanager boot
- sudo rc-update add ntpd boot
+ if ps --no-headers -o comm 1 | grep openrc; then
+ sudo /etc/init.d/networkmanager start
+ sudo /etc/init.d/ntpd start
+ sudo rc-update add networkmanager boot
+ sudo rc-update add ntpd boot
+ fi
+ if ps --no-headers -o comm 1 | grep systemd; then
+ sudo systemctl start NetworkManager
+ sudo systemctl start ntpd
+ sudo systemctl enable NetworkManager
+ sudo systemctl enable ntpd
+ fi
}
}
--
2.37.3