diff options
author | Daniel Baumann <daniel@debian.org> | 2011-07-15 20:31:44 +0200 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2011-07-15 20:38:39 +0200 |
commit | 7e4c34b6f2259425ed4258d8f36b55e6d468efdf (patch) | |
tree | 043237418591a3036d18eae06029d380586ef8bd /debian/live-build-cron.postinst | |
parent | e24497b72306d4519d8c2999c6b7c0dbec9166ef (diff) | |
download | vyos-live-build-7e4c34b6f2259425ed4258d8f36b55e6d468efdf.tar.gz vyos-live-build-7e4c34b6f2259425ed4258d8f36b55e6d468efdf.zip |
Adding initial live-build-cron package.
Diffstat (limited to 'debian/live-build-cron.postinst')
-rw-r--r-- | debian/live-build-cron.postinst | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/debian/live-build-cron.postinst b/debian/live-build-cron.postinst new file mode 100644 index 000000000..837d992db --- /dev/null +++ b/debian/live-build-cron.postinst @@ -0,0 +1,176 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +_FILE="/etc/live/build-cron.d/images.conf" + +case "${1}" in + configure) + db_get live-build-cron-images/enable + LIVE_BUILD_CRON_IMAGES="${RET}" # boolean + + db_get live-build-cron-images/directory + LIVE_BUILD_CRON_IMAGES_DIRECTORY="${RET:-/srv/debian.net/live/cdimage}" # string (w/o empty) + + db_get live-build-cron-images/build + LIVE_BUILD_CRON_IMAGES_BUILD="${RET}" # select + + db_get live-build-cron-images/daily-distributions + LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS="$(echo ${RET} | sed -e 's|,||g')" # multiselect + + db_get live-build-cron-images/daily-flavours + LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS="$(echo ${RET} | sed -e 's|,||g')" # multiselect + + db_get live-build-cron-images/weekly-distributions + LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS="$(echo ${RET} | sed -e 's|,||g')" # multiselect + + db_get live-build-cron-images/weekly-flavours + LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS="$(echo ${RET} | sed -e 's|,||g')" # multiselect + + db_get live-build-cron-images/monthly-distributions + LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS="$(echo ${RET} | sed -e 's|,||g')" # multiselect + + db_get live-build-cron-images/monthly-flavours + LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS="$(echo ${RET} | sed -e 's|,||g')" # multiselect + + db_get live-build-cron-images/source + LIVE_BUILD_CRON_IMAGES_SOURCE="${RET}" # boolean + + db_get live-build-cron-images/cron + _CRON="${RET}" # string (w empty) + + db_stop + + if [ ! -e "${_FILE}" ] + then + + mkdir -p "$(dirname ${_FILE})" + +cat > "${_FILE}" << EOF +# /etc/live/build-cron.d/images.conf + +LIVE_BUILD_CRON_IMAGES="${LIVE_BUILD_CRON_IMAGES}" +LIVE_BUILD_CRON_IMAGES_DIRECTORY="${LIVE_BUILD_CRON_IMAGES_DIRECTORY}" +LIVE_BUILD_CRON_IMAGES_BUILD="${LIVE_BUILD_CRON_IMAGES_BUILD}" + +LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS="${LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS}" +LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS="${LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS}" + +LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS="${LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS}" +LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS="${LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS}" + +LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS="${LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS}" +LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS="${LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS}" + +export LIVE_BUILD_CRON_IMAGES LIVE_BUILD_CRON_IMAGES_DIRECTORY +export LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS +export LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS +export LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS +export LIVE_BUILD_CRON_IMAGES_SOURCE +EOF + + fi + + cp -a -f "${_FILE}" "${_FILE}.tmp" + + # If the admin deleted or commented some variables but then set + # them via debconf, (re-)add them to the config file. + + test -z "${LIVE_BUILD_CRON_IMAGES}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_DIRECTORY=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_DIRECTORY=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_BUILD}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_BUILD=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_BUILD=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS=" >> "${_FILE}" + + test -z "${LIVE_BUILD_CRON_IMAGES_SOURCE}" || \ + grep -Eq '^ *LIVE_BUILD_CRON_IMAGES_SOURCE=' "${_FILE}" || \ + echo "LIVE_BUILD_CRON_IMAGES_SOURCE=" >> "${_FILE}" + + sed -e "s|^ *LIVE_BUILD_CRON_IMAGES=.*|LIVE_BUILD_CRON_IMAGES=\"${LIVE_BUILD_CRON_IMAGES}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_DIRECTORY=.*|LIVE_BUILD_CRON_IMAGES_DIRECTORY=\"${LIVE_BUILD_CRON_IMAGES_DIRECTORY}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_BUILD=.*|LIVE_BUILD_CRON_IMAGES_BUILD=\"${LIVE_BUILD_CRON_IMAGES_BUILD}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS=.*|LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS=\"${LIVE_BUILD_CRON_IMAGES_DAILY_DISTRIBUTIONS}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS=.*|LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS=\"${LIVE_BUILD_CRON_IMAGES_DAILY_FLAVOURS}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS=.*|LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS=\"${LIVE_BUILD_CRON_IMAGES_WEEKLY_DISTRIBUTIONS}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS=.*|LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS=\"${LIVE_BUILD_CRON_IMAGES_WEEKLY_FLAVOURS}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS=.*|LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS=\"${LIVE_BUILD_CRON_IMAGES_MONTHLY_DISTRIBUTIONS}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS=.*|LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS=\"${LIVE_BUILD_CRON_IMAGES_MONTHLY_FLAVOURS}\"|" \ + -e "s|^ *LIVE_BUILD_CRON_IMAGES_SOURCE=.*|LIVE_BUILD_CRON_IMAGES_SOURCE=\"${LIVE_BUILD_CRON_IMAGES_SOURCE}\"|" \ + "${_FILE}" > "${_FILE}.tmp" + + mv -f "${_FILE}.tmp" "${_FILE}" + + mkdir -p "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}" + + if [ -n "${_CRON}" ] + then + +cat > /etc/cron.d/live-build-cron-images << EOF +# /etc/cron.d/live-build-cron-images + +PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +# m h dom mon dow user command +${_CRON} root /usr/bin/live-build-cron-images +EOF + + else + rm -f /etc/cron.d/live-build-cron-images + fi + + if [ -x "/etc/init.d/cron" ] + then + if [ -x "$(which invoke-rc.d 2>/dev/null)" ] + then + invoke-rc.d cron restart || exit ${?} + else + /etc/init.d/cron restart || exit ${?} + fi + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`${1}'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 |