#!/bin/sh # # 2008-2009 Nico Schottelius (nico-cinit at schottelius.org) # # This file is part of cinit. # # cinit is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # cinit is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with cinit-conf. If not, see . # # cinit: create dependency: service a needs or wants service b # set -e . "$(dirname $0)/cinit-conf.read-conf" if [ $# -lt 3 ]; then echo "`basename $0`: service_A [wants|needs] service_B" echo "" echo " Service A needs or wants Service B." echo " You must specify whether to use wants or needs." echo "" exit 23 fi SVC_A="$1"; shift DEP="$1"; shift # adding 'wishes' for x-mas and requires for 'the mass' and 'tv' case "${DEP}" in wishes|wants) DEP="$C_WANTS" ;; needs|requires) DEP="$C_NEEDS" ;; *) echo "Use \"want\" or \"need\" as type of dependency." esac SVC_A_LDIR="${R_SVC_DIR}/${SVC_A}/${DEP}" # Try to create dependency directory, if it does not exist if [ ! -d "${SVC_A_LDIR}" ]; then echo "${SVC_A}:+${DEP}" mkdir "${SVC_A_LDIR}" fi # allow multiple dependencies to be added in one run while [ $# -gt 0 ]; do SVC_B="$1"; shift # remove slashes in the name for destination SVC_B_LNAME="$(echo "$SVC_B" | sed 's#/#-#g')" SVC_B_SOURCE="${T_SVC_DIR}/${SVC_B}" SVC_A_LDEST="${SVC_A_LDIR}/${SVC_B_LNAME}" echo "${SVC_A} ${DEP} ${SVC_B} (${SVC_B_LNAME})" ln -sf "${SVC_B_SOURCE}" "${SVC_A_LDEST}" done exit 0