summarylogtreecommitdiffstats
path: root/00-pdnsd
diff options
context:
space:
mode:
authorFrederik "Freso" S. Olesen2012-09-27 17:20:49 +0200
committerFrederik “Freso” S. Olesen2012-09-27 17:20:49 +0200
commit7336cd0b46b225f2b951ea0c8dfd7bb041faf74b (patch)
tree2958b40c3ae5190ebc38588df6ea832a360af416 /00-pdnsd
parent700987a621e8d97f5f9be65d1b7e123d656aab75 (diff)
downloadaur-7336cd0b46b225f2b951ea0c8dfd7bb041faf74b.tar.gz
networkmanager-dispatcher-pdnsd: Abstracted check for whether pDNSd is running.
Diffstat (limited to '00-pdnsd')
-rwxr-xr-x00-pdnsd41
1 files changed, 29 insertions, 12 deletions
diff --git a/00-pdnsd b/00-pdnsd
index ec2cff1c8e35..f597e017aa54 100755
--- a/00-pdnsd
+++ b/00-pdnsd
@@ -11,23 +11,15 @@ no_valid_init() {
exit 1
}
-pdnsd_going_up() {
- # Check whether pDNSd is already running before starting it.
+pdnsd_is_runnning() {
+ # Check whether pDNSd is running.
case "$INIT" in
'systemd')
systemctl is-active pdnsd.service -q
- if [ ! $? = 0 ]; then
- systemctl start pdnsd.service
- else
- systemctl restart pdnsd.service
- fi
+ return [ ! $? = 0 ]
;;
'init')
- if [ `rc.d list|grep pdnsd|cut -f1 -d']'|cut -d'[' -f2` == 'STOPPED' ]; then
- rc.d start pdnsd
- else
- rc.d restart pdnsd
- fi
+ return [ `rc.d list|grep pdnsd|cut -f1 -d']'|cut -d'[' -f2` == 'STARTED' ]
;;
*)
no_valid_init
@@ -35,6 +27,31 @@ pdnsd_going_up() {
esac
}
+pdnsd_going_up() {
+ if [ ! pdnsd_is_running ]; then
+ # pDNSd isn't running. Start it.
+ case "$INIT" in
+ 'systemd')
+ systemctl start pdnsd.service
+ ;;
+ 'init')
+ rc.d start pdnsd
+ ;;
+ esac
+ else
+ # pDNSd is running. Restart it.
+ case "$INIT" in
+ 'systemd')
+ systemctl restart pdnsd.service
+ ;;
+ 'init')
+ rc.d restart pdnsd
+ ;;
+ esac
+
+ fi
+}
+
pdnsd_going_down() {
# Check for active interface, take offline if none is active
if [ ! `nm-tool|grep State|cut -f2 -d' '` = 'connected' ]; then