summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2013-05-12 21:54:19 +0200
committerFlorian Bruhin <git@the-compiler.org>2013-05-12 21:54:19 +0200
commit2ecb6e08be51ac69bc0457f79be7e0312dce501e (patch)
tree191bb99f3cd863058b7432bb8b389ef8e4bd1e29
parent00f789acbe62ff50fc9a77a1168a1179dcb28cac (diff)
downloadproxyswitch_polipo-master.tar.gz
proxyswitch_polipo-master.zip
Add systemctlHEADmaster
-rw-r--r--proxyswitch.sh20
1 files changed, 17 insertions, 3 deletions
diff --git a/proxyswitch.sh b/proxyswitch.sh
index 58a115c..0f3e30a 100644
--- a/proxyswitch.sh
+++ b/proxyswitch.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# vim: set fileencoding=utf-8 ts=4 sts=4 sw=4 tw=80 expandtab :
-# Copyright (C) 2012 Florian Bruhin <me@the-compiler.org>
+# Copyright (C) 2012-2013 Florian Bruhin <me@the-compiler.org>
# proxyswitch-polipo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,12 +30,15 @@ if [[ ! -f "$polipo_conf" ]]; then
echo "Is polipo really installed?"
exit 1
fi
-if [[ -f /etc/rc.d/polipo ]]; then
+if which systemctl &>/dev/null; then
+ systemd=1
+elif [[ -f /etc/rc.d/polipo ]]; then
service_file="/etc/rc.d/polipo"
elif [[ -f /etc/init.d/polipo ]]; then
service_file="/etc/init.d/polipo"
else
echo "Error: Neither /etc/rc.d/polipo nor /etc/init.d/polipo exist."
+ echo "Also systemd is not installed."
echo "Is polipo really installed?"
exit 1
fi
@@ -97,4 +100,15 @@ if [[ $auth ]]; then
"$polipo_conf"
fi
-"$service_file" restart
+if [[ $systemd ]]; then
+ systemctl restart polipo
+ status=$?
+else
+ "$service_file" restart
+ status=$?
+fi
+
+if ((status != 0)); then
+ echo "Error: restarting failed" >&2
+ exit $status
+fi