#!/bin/bash # The phusion/baseimage base image we use for a working Ubuntu # replaces the normal Upstart system service management with # a ligher-weight service management system called runit that # requires a different configuration. We need to create service # run files that do not daemonize. # This removes /etc/init.d service if service exists in runit. # It also creates a symlink from /usr/bin/sv to /etc/init.d/$service # to support SysV syntax: service $service or /etc/init.d/$service SERVICES=/etc/service/* for f in $SERVICES do service=$(basename "$f") if [ -d /etc/service/$service ]; then if [ -f /etc/init.d/$service ]; then mv /etc/init.d/$service /etc/init.d/$service.lsb chmod -x /etc/init.d/$service.lsb fi ln -s /usr/bin/sv /etc/init.d/$service fi done # Create runit services from sysv services. For most of the services, # there is a common pattern we can use: execute the init.d script that # the Ubuntu package installs, and then poll for the termination of # the daemon. function make_runit_service { INITD_NAME=$1 WAIT_ON_PROCESS_NAME=$2 mkdir -p /etc/service/$INITD_NAME cat > /etc/service/$INITD_NAME/run < /etc/service/$service/log/run <