#!/bin/sh
#
MY_MANUAL="manual # PLYMOUTH_DISABLER"
MY_MANUAL_REGEX="manual[ 	]\+#[ 	]*PLYMOUTH_DISABLER"
# dpkg -L plymouth | sed -n -e 's,.conf$,,' -e 's,/etc/init/,,p' | sort
PLYMOUTH_JOBS="plymouth plymouth-log plymouth-ready plymouth-splash
   plymouth-stop plymouth-upstart-bridge"

set -e

if [ "$1" = "configure" ]; then
   [ -d "/etc/init" ] || mkdir -p "/etc/init"
   for job in $PLYMOUTH_JOBS; do
      cfg="/etc/init/$job.conf.override"
      [ -f "$cfg" ] && grep -q "$MY_MANUAL" "$cfg" &&
         existing=true || existing=false

      # first install or install after purge. clean out anything.
      if [ -z "$1" -a "$existing" = "true" ]; then
         sed -i "/${MY_MANUAL_REGEX}/d" "$cfg"
         existing=false
      fi

      # only add the line if it wasn't there. to allow user to comment out.
      if [ "$existing" = "false" ]; then
         echo "$MY_MANUAL" >> "$cfg"
      fi
   done
fi

#DEBHELPER#
