functions-common: Use systemctl when applicable

We live in a new systemd world, use the native commands to talk to it
if available.

Change-Id: Iccdc35f0c9da2997f9e672bc1d24ca15d3403d98
This commit is contained in:
Kashyap Chamarthy 2016-05-20 13:34:41 +02:00 committed by Sean Dague
parent 730703a833
commit 247e44625c

View File

@ -2264,11 +2264,12 @@ function python_version {
# Service wrapper to restart services # Service wrapper to restart services
# restart_service service-name # restart_service service-name
function restart_service { function restart_service {
if is_ubuntu; then if [ -x /bin/systemctl ]; then
sudo /usr/sbin/service $1 restart sudo /bin/systemctl restart $1
else else
sudo /sbin/service $1 restart sudo service $1 restart
fi fi
} }
# Only change permissions of a file or directory if it is not on an # Only change permissions of a file or directory if it is not on an
@ -2286,20 +2287,20 @@ function safe_chown {
# Service wrapper to start services # Service wrapper to start services
# start_service service-name # start_service service-name
function start_service { function start_service {
if is_ubuntu; then if [ -x /bin/systemctl ]; then
sudo /usr/sbin/service $1 start sudo /bin/systemctl start $1
else else
sudo /sbin/service $1 start sudo service $1 start
fi fi
} }
# Service wrapper to stop services # Service wrapper to stop services
# stop_service service-name # stop_service service-name
function stop_service { function stop_service {
if is_ubuntu; then if [ -x /bin/systemctl ]; then
sudo /usr/sbin/service $1 stop sudo /bin/systemctl stop $1
else else
sudo /sbin/service $1 stop sudo service $1 stop
fi fi
} }