From a949848a9c28cb0442b0b7707686c7b805b85127 Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Sun, 4 Aug 2013 14:09:42 +0200 Subject: [PATCH] config/functions: add 'enable_service' function to enable systemd services by default Signed-off-by: Stephan Raue --- config/functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/config/functions b/config/functions index 1532100303..d03b083684 100644 --- a/config/functions +++ b/config/functions @@ -191,6 +191,22 @@ fix_module_depends() { rm new.modinfo* } +# Usage: enable_service [target] +enable_service () { + local unit="$1" + local unit_dir="/lib/systemd/system" + local target="$2" + local target_dir=$INSTALL + + [ -f "$target_dir/$unit_dir/$unit" ] || exit 1 + [ -z "$target" ] && target=`grep '^WantedBy' $target_dir/$unit_dir/$unit | cut -f2 -d=` + + if [ -n "$target" ]; then + mkdir -p ${target_dir}/$unit_dir/${target}.wants + ln -sf ../${unit} ${target_dir}/$unit_dir/${target}.wants/ + fi +} + check_path() { dashes="===========================" if [ "${PWD##/usr}" != "${PWD}" ]; then