diff --git a/elements/os-svc-install/bin/os-svc-daemon b/elements/os-svc-install/bin/os-svc-daemon index 2df77f372..7181fc96a 100755 --- a/elements/os-svc-install/bin/os-svc-daemon +++ b/elements/os-svc-install/bin/os-svc-daemon @@ -12,6 +12,8 @@ usage() { echo "" echo " -h Show help and exit" echo " -p Print the job file instead of writing to disk" + echo " -d Only create the systemd service that creates the run time directory," + echo " not the actual systemd daemon service. Ignored for upstart." echo " -s POSTSTART post_start will be added to the upstart job. Ignored with systemd." echo " default: $DEFAULT_POSTSTART" echo " -e ENV Environment name=value entries to set in the service/job" @@ -27,6 +29,7 @@ SERVICENAME=${SERVICENAME:-""} RUNAS=${RUNAS:-""} RUNCMD=${RUNCMD:-""} ENV=${ENV:-""} +CREATE_DIR_ONLY=${CREATE_DIR_ONLY:-""} # The default helps avoid race with daemon listening. http://pad.lv/1179766 POSTSTART=${POSTSTART:-$DEFAULT_POSTSTART} @@ -41,7 +44,7 @@ print_to_file() { OUTPUT=print_to_file nshift=0 -while getopts "phs:n:u:c:e:" opt; do +while getopts "phds:n:u:c:e:" opt; do case "$opt" in n) SERVICENAME=$OPTARG;; u) RUNAS=$OPTARG;; @@ -49,6 +52,7 @@ while getopts "phs:n:u:c:e:" opt; do s) POSTSTART=$OPTARG;; e) ENV=$OPTARG;; p) OUTPUT=print_only;; + d) CREATE_DIR_ONLY=1;; h) usage; exit 0;; \?) usage; exit 1;; :) usage; exit 1;; @@ -137,13 +141,22 @@ WantedBy=multi-user.target Alias=$name.service EOF +} + +function install_create_dir_systemd { + local name=$(map-services $1) + local user=$2 + $OUTPUT /usr/lib/systemd/system/$name-create-dir.service <&2 fi - install_systemd $SERVICENAME $RUNAS $RUNCMD $* + if [ -z "$CREATE_DIR_ONLY" ]; then + install_systemd $SERVICENAME $RUNAS $RUNCMD $* + fi + install_create_dir_systemd $SERVICENAME $RUNAS fi diff --git a/elements/os-svc-install/bin/os-svc-enable b/elements/os-svc-install/bin/os-svc-enable index 7cb08c7f8..eb9e5d391 100755 --- a/elements/os-svc-install/bin/os-svc-enable +++ b/elements/os-svc-install/bin/os-svc-enable @@ -50,7 +50,12 @@ function enable_upstart_service { function enable_systemd_service { local name=$1 - systemctl enable $(map-services $name).service + local service_name=$(map-services $name) + systemctl enable $service_name.service + # Also enable the create-dir service if it exists + if [ -f /usr/lib/systemd/system/$service_name-create-dir.service ]; then + systemctl enable $service_name-create-dir.service + fi } # TODO: SysV init fallback support