#!/bin/bash
[[ ! -w /etc/init ]] && abort "Cannot write to /etc/init folder, unable to initialise upstart script"

local cfgFile=/etc/init/$1.conf
local version=${2-$versionKey}

shift; shift;

# if the file already exists then do nothing
if [ ! -f $cfgFile ]; then
  log "installing upstart script for $1"

  # fetch the template
  fetch templates/upstart/$1.conf

  cat $BASHINATE_HOME/templates/upstart/$1.conf | \
    sed -e "s#%%INSTALL%%#$BASHINATE_INSTALL#g" | \
    sed -e "s#%%VERSION%%#$version#g" > $cfgFile
fi