config/functions: add 'enable_service' function to enable systemd services by default

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2013-08-04 14:09:42 +02:00
parent b8ea8f2201
commit a949848a9c

View File

@ -191,6 +191,22 @@ fix_module_depends() {
rm new.modinfo*
}
# Usage: enable_service <unit> [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