diff options
Diffstat (limited to 'debian/tmp')
-rw-r--r-- | debian/tmp/live-build-cron-manual.config | 50 | ||||
-rw-r--r-- | debian/tmp/live-build-cron-manual.postinst | 111 | ||||
-rw-r--r-- | debian/tmp/live-build-cron-manual.postrm | 37 | ||||
-rw-r--r-- | debian/tmp/live-build-cron-manual.templates | 29 |
4 files changed, 227 insertions, 0 deletions
diff --git a/debian/tmp/live-build-cron-manual.config b/debian/tmp/live-build-cron-manual.config new file mode 100644 index 000000000..264477825 --- /dev/null +++ b/debian/tmp/live-build-cron-manual.config @@ -0,0 +1,50 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +_FILES="/etc/live/autobuild.conf /etc/live/autobuild.d/*" + +for _FILE in "${_FILES}" +do + if [ -e "${_FILE}" ] + then + _DEBCONF="true" + + . "${_FILE}" || true + fi +done + +if [ "${_DEBCONF}" = "true" ] +then + db_set live-autobuild-manual/enable "${LIVE_AUTOBUILD_MANUAL}" +fi + +db_settitle live-autobuild-manual/title +db_input high live-autobuild-manual/enable || true +db_go + +db_get live-autobuild-manual/enable +LIVE_AUTOBUILD_MANUAL="${RET}" + +if [ "${LIVE_AUTOBUILD_MANUAL}" != "true" ] +then + db_stop + + exit 0 +fi + +db_settitle live-autobuild-manual/title +db_input low live-autobuild-manual/username || true +db_go + +db_settitle live-autobuild-manual/title +db_input low live-autobuild-manual/directory || true +db_go + +db_settitle live-autobuild-manual/title +db_input low live-autobuild-manual/cron || true +db_go + +db_stop diff --git a/debian/tmp/live-build-cron-manual.postinst b/debian/tmp/live-build-cron-manual.postinst new file mode 100644 index 000000000..45c645dfe --- /dev/null +++ b/debian/tmp/live-build-cron-manual.postinst @@ -0,0 +1,111 @@ +#!/bin/sh + +set -e + +. /usr/share/debconf/confmodule + +_FILE="/etc/live/autobuild.d/manual.conf" + +case "${1}" in + configure) + db_get live-autobuild-manual/enable + LIVE_AUTOBUILD_MANUAL="${RET}" # boolean + + db_get live-autobuild-manual/username + _USERNAME="${RET:-live-autobuild-manual}" # string (w/o empty) + + db_get live-autobuild-manual/directory + LIVE_AUTOBUILD_MANUAL_DIRECTORY="${RET:-/srv/debian.net/live/cdimage}" # string (w/o empty) + + db_get live-autobuild-manual/cron + _CRON="${RET}" # string (w empty) + + db_stop + + if [ ! -e "${_FILE}" ] + then + + mkdir -p "$(dirname ${_FILE})" + +cat > "${_FILE}" << EOF +# /etc/live/autobuild.d/manual.conf + +LIVE_AUTOBUILD_MANUAL="${LIVE_AUTOBUILD_MANUAL}" +LIVE_AUTOBUILD_MANUAL_DIRECTORY="${LIVE_AUTOBUILD_MANUAL_DIRECTORY}" + +export LIVE_AUTOBUILD_MANUAL LIVE_AUTOBUILD_MANUAL_DIRECTORY +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_AUTOBUILD_MANUAL}" || \ + grep -Eq '^ *LIVE_AUTOBUILD_MANUAL=' "${_FILE}" || \ + echo "LIVE_AUTOBUILD_MANUAL=" >> "${_FILE}" + + test -z "${LIVE_AUTOBUILD_MANUAL_DIRECTORY}" || \ + grep -Eq '^ *LIVE_AUTOBUILD_MANUAL_DIRECTORY=' "${_FILE}" || \ + echo "LIVE_AUTOBUILD_MANUAL_DIRECTORY=" >> "${_FILE}" + + sed -e "s|^ *LIVE_AUTOBUILD_MANUAL=.*|LIVE_AUTOBUILD_MANUAL=\"${LIVE_AUTOBUILD_MANUAL}\"|" \ + -e "s|^ *LIVE_AUTOBUILD_MANUAL_DIRECTORY=.*|LIVE_AUTOBUILD_MANUAL_DIRECTORY=\"${LIVE_AUTOBUILD_MANUAL_DIRECTORY}\"|" \ + "${_FILE}" > "${_FILE}.tmp" + + mv -f "${_FILE}.tmp" "${_FILE}" + + if ! getent passwd "${_USERNAME}" + then + adduser --quiet --system --home ${LIVE_AUTOBUILD_MANUAL_DIRECTORY} --shell /bin/sh --disabled-password --no-create-home --gecos 'live-autobuild-manual' --group ${_USERNAME} + elif ! getent group "${_USERNAME}" + then + addgroup --system --quiet ${_USERNAME} + gpasswd -a ${_USERNAME} ${_USERNAME} + fi + + mkdir -p "${LIVE_AUTOBUILD_MANUAL_DIRECTORY}" + chown ${_USERNAME}:${_USERNAME} "${LIVE_AUTOBUILD_MANUAL_DIRECTORY}" -R + + if [ -n "${_CRON}" ] + then + +cat > /etc/cron.d/live-autobuild-manual << EOF +# /etc/cron.d/live-autobuild-manual + +PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +# m h dom mon dow user command +${_CRON} ${_USERNAME} /usr/bin/live-autobuild-manual +EOF + + else + rm -f /etc/cron.d/live-autobuild-manual + 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 diff --git a/debian/tmp/live-build-cron-manual.postrm b/debian/tmp/live-build-cron-manual.postrm new file mode 100644 index 000000000..6e15675b5 --- /dev/null +++ b/debian/tmp/live-build-cron-manual.postrm @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +_USERNAME="live-autobuild-manual" +_DIRECTORY="/srv/debian.net/live-manual" + +case "${1}" in + remove) + if [ -x /usr/sbin/deluser ] + then + deluser --system ${_USERNAME} || true + fi + + if [ -d "${_DIRECTORY}" ] + then + rmdir --ignore-fail-on-non-empty "${_DIRECTORY}" || true + fi + ;; + + purge) + rm -rf "${_DIRECTORY}" + ;; + + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + + ;; + + *) + echo "postrm called with unknown argument \`${1}'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/tmp/live-build-cron-manual.templates b/debian/tmp/live-build-cron-manual.templates new file mode 100644 index 000000000..9baa0a0e8 --- /dev/null +++ b/debian/tmp/live-build-cron-manual.templates @@ -0,0 +1,29 @@ +Template: live-autobuild-manual/title +Type: title +Description: Debian Live - System Build Scripts + +Template: live-autobuild-manual/enable +Type: boolean +Default: false +Description: Enable live-autobuild-manual? + Do you want to enable live-autobuild-manual? + . + If unsure, use 'no' (default). + +Template: live-autobuild-manual/username +Type: string +Default: live-autobuild-manual +Description: What useraccount to use to build the manual? + Enter the name of the username. + +Template: live-autobuild-manual/directory +Type: string +Default: /srv/debian.net/live-manual +Description: What directory to put builds to? + Enter the directory where the manual should be stored in. + +Template: live-autobuild-manual/cron +Type: string +Default: 0-59/10 * * * * +Description: What directory to put builds to? + Enter the cron times where the manual should be build. |