summaryrefslogtreecommitdiff
path: root/cgi
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2010-09-26 12:38:38 +0200
committerDaniel Baumann <daniel@debian.org>2010-09-26 15:11:45 +0200
commit152d608f61fd22a1414c3a90ba061b790200350a (patch)
tree44a6d3a12cd11067aea2a4d43eb9133cc25bad2f /cgi
downloadvyos-live-build-152d608f61fd22a1414c3a90ba061b790200350a.tar.gz
vyos-live-build-152d608f61fd22a1414c3a90ba061b790200350a.zip
Adding debian version 3.0~a1-1.
Diffstat (limited to 'cgi')
-rw-r--r--cgi/Makefile19
-rwxr-xr-xcgi/cgi235
-rwxr-xr-xcgi/cron192
-rw-r--r--cgi/crontab7
-rw-r--r--cgi/default17
-rw-r--r--cgi/logrotate11
6 files changed, 481 insertions, 0 deletions
diff --git a/cgi/Makefile b/cgi/Makefile
new file mode 100644
index 000000000..27a010766
--- /dev/null
+++ b/cgi/Makefile
@@ -0,0 +1,19 @@
+# Makefile
+
+install:
+ install -D -m 0755 cgi $(DESTDIR)/usr/lib/cgi-bin/live-build
+ install -D -m 0755 cron $(DESTDIR)/etc/cron.d/live-build.cgi
+ install -D -m 0644 default $(DESTDIR)/etc/default/live-build.cgi
+ install -D -m 0644 logrotate $(DESTDIR)/etc/logrotate.d/live-build.cgi
+
+ install -d -m 0755 $(DESTDIR)/var/log
+ touch $(DESTDIR)/var/log/live
+ chown www-data:www-data $(DESTDIR)/var/log/live
+
+uninstall:
+ rm -f $(DESTDIR)/usr/lib/cgi-bin/live-build
+ rm -f $(DESTDIR)/etc/cron.d/live-build.cgi
+ rm -f $(DESTDIR)/etc/default/live-build.cgi
+ rm -f $(DESTDIR)/etc/logrotate.d/live-build.cgi
+
+reinstall: uninstall install
diff --git a/cgi/cgi b/cgi/cgi
new file mode 100755
index 000000000..2ab6e5b0b
--- /dev/null
+++ b/cgi/cgi
@@ -0,0 +1,235 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>
+##
+## live-build comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+# Including common functions
+. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
+
+# Reading defaults
+if [ -r /etc/default/live-build.cgi ]
+then
+ . /etc/default/live-build.cgi
+else
+ echo "E: /etc/default/live-build.cgi missing"
+ exit 1
+fi
+
+# Turn on debug if enabled
+if [ "${_DEBUG}" = "enabled" ]
+then
+ set -x
+fi
+
+# Sending http header
+echo "Content-type: text/html"
+echo
+
+# Sending html header
+cat "${_TEMPLATES}"/header.html
+
+# CGI
+if [ -z "${QUERY_STRING}" ]
+then
+ # Sending html form
+ sed -e "s#LB_MIRROR_BOOTSTRAP#${LB_MIRROR_BOOTSTRAP}#" \
+ -e "s#LB_MIRROR_BINARY_SECURITY#${LB_MIRROR_BINARY_SECURITY}#" \
+ -e "s#LB_MIRROR_BINARY#${LB_MIRROR_BINARY}#" \
+ -e "s/VERSION/${VERSION}/" \
+ -e "s/DATE/`date +%Y%m%d-%H:%M`/" \
+ "${_TEMPLATES}"/form.html
+else
+ # Converting spaces: sed 's/+/ /g'
+ # Converting '@': sed 's/%40/@/g'
+ # Converting ':': sed 's/%3A/:/g'
+ # Converting ';': sed 's/%3B/\;/g'
+ # Converting '/': sed 's/%2F/\//g'
+ # Converting '~': sed 's/%7E/\~/g'
+ # Converting '=': sed 's/%3D/=/g'
+ # Converting '+': sed 's/%2B/+/g'
+
+ # Translate parameters
+ QUERY_STRING=$(echo "${QUERY_STRING}" | sed -e 's/%2F/\//g' -e 's/+/ /g' -e 's/%3B/;/g' -e 's/%7E/~/g' -e 's/%3A/:/g' -e 's/%40/@/g' -e 's/%3D/=/g' -e 's/%2B/+/g')
+ # Debug the filtering string
+ # echo ${QUERY_STRING}
+
+ # Email
+ _EMAIL=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])email=[-0-9a-zA-Z._@]+' | cut -f 2 -d '=' | head -n1)
+
+ # Standard options
+ LB_BINARY_IMAGES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])binary_images=[-a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_DISTRIBUTION=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])distribution=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_PACKAGES_LISTS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])packages_lists=[-0-9a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_TASKS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])tasks=[-0-9a-zA-Z. _]+' | cut -f 2 -d '=' | head -n1)
+ LB_PACKAGES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])packages=[-0-9a-zA-Z. _]+' | cut -f 2 -d '=' | head -n1)
+
+ # Advanced bootstrap options
+ LB_ARCHITECTURE=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])architecture=[0-9a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_BOOTSTRAP_FLAVOUR=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])bootstrap_flavour=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_MIRROR_BOOTSTRAP=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])mirror_bootstrap=[-0-9a-zA-Z.~:/_]+' | cut -f 2 -d '=' | head -n1)
+ LB_MIRROR_BINARY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])mirror_binary=[-0-9a-zA-Z.~:/_]+' | cut -f 2 -d '=' | head -n1)
+ LB_MIRROR_BINARY_SECURITY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])mirror_binary_security=[-0-9a-zA-Z.~:/_]+' | cut -f 2 -d '=' | head -n1)
+ LB_ARCHIVE_AREAS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])archive_areas=[a-z]+' | cut -f 2 -d '=' | head -n1)
+
+ # Advanced chroot options
+ LB_CHROOT_FILESYSTEM=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])chroot_filesystem=[0-9a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_LINUX_FLAVOURS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])linux_flavours=[-0-9a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_SECURITY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])security=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_SYMLINKS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])symlinks=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_SYSVINIT=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])sysvinit=[a-z]+' | cut -f 2 -d '=' | head -n1)
+
+ # Advanced binary options
+ LB_BINARY_INDICES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])binary_indices=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_BOOTAPPEND_INSTALL=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])bootappend_install=[-0-9a-zA-Z. _+=:/]+' | cut -f2- -d '=' | head -n1)
+ LB_BOOTAPPEND_LIVE=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])bootappend_live=[-0-9a-zA-Z. _+=:/]+' | cut -f2- -d '=' | head -n1)
+ LB_BOOTLOADER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])bootloader=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_DEBIAN_INSTALLER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])debian_installer=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_ENCRYPTION=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])encryption=[0-9a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_ISO_APPLICATION=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_application=[-0-9a-zA-Z. ~;:/_]+' | cut -f 2 -d '=' | head -n1)
+ LB_ISO_PREPARER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_preparer=[-0-9a-zA-Z. ~;:/_]+' | cut -f 2 -d '=' | head -n1)
+ LB_ISO_PUBLISHER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_publisher=[-0-9a-zA-Z. ~;:/_@]+' | cut -f 2 -d '=' | head -n1)
+ LB_ISO_VOLUME=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_volume=[-0-9a-zA-Z. ~;:/_]+' | cut -f 2 -d '=' | head -n1)
+ LB_MEMTEST=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])memtest=[0-9a-z+]+' | cut -f 2 -d '=' | head -n1)
+ LB_NET_ROOT_PATH=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])net_path=[-0-9a-zA-Z._/]+' | cut -f 2 -d '=' | head -n1)
+ LB_NET_ROOT_SERVER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])net_server=[0-9.]+' | cut -f 2 -d '=' | head -n1)
+
+ # Advanced source options
+ LB_SOURCE=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])source=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ LB_SOURCE_IMAGES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])source_images=[a-z]+' | cut -f 2 -d '=' | head -n1)
+
+ # Unofficial options
+ _CUSTOM_BOOTSTRAP=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])custom_bootstrap=[-0-9a-zA-Z.~:/_]+' | cut -f 2 -d '=' | head -n1)
+ _CUSTOM_BINARY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])custom_binary=[-0-9a-zA-Z.~:/_]+' | cut -f 2 -d '=' | head -n1)
+
+ # FIXME: filter invalid options
+ unset QUERY_STRING
+
+ if [ -z "${_EMAIL}" ]
+ then
+ echo "<h2><div style='color: red;'>Error: No email address specified.</div></h2>"
+
+ sed -e "s#LB_MIRROR_BOOTSTRAP#${LB_MIRROR_BOOTSTRAP}#" \
+ -e "s#LB_MIRROR_BINARY_SECURITY#${LB_MIRROR_BINARY_SECURITY}#" \
+ -e "s#LB_MIRROR_BINARY#${LB_MIRROR_BINARY}#" \
+ -e "s/VERSION/${VERSION}/" \
+ -e "s/DATE/`date +%Y%m%d-%H:%M`/" \
+ "${_TEMPLATES}"/form.html
+
+ exit
+ fi
+
+ # Getting build identifier
+ _BUILD=$(date +%Y%m%d.%H%M%S.%N)
+
+ #echo "${QUERY_STRING}"
+ # Sending html confirmation
+ # Note: On each string remember to use a delimeter that is not in the string.
+ sed -e "s/BUILD/${_BUILD}/g" \
+ -e "s/EMAIL/${_EMAIL}/" \
+ -e "s/LB_BINARY_IMAGES/${LB_BINARY_IMAGES}/" \
+ -e "s/LB_DISTRIBUTION/${LB_DISTRIBUTION}/" \
+ -e "s/LB_PACKAGES_LISTS/${LB_PACKAGES_LISTS}/" \
+ -e "s/LB_TASKS/${LB_TASKS}/" \
+ -e "s/LB_PACKAGES/${LB_PACKAGES}/" \
+ -e "s/LB_ARCHITECTURE/${LB_ARCHITECTURE}/" \
+ -e "s/LB_BOOTSTRAP_FLAVOUR/${LB_BOOTSTRAP_FLAVOUR}/" \
+ -e "s#LB_MIRROR_BOOTSTRAP#${LB_MIRROR_BOOTSTRAP}#" \
+ -e "s#LB_MIRROR_BINARY_SECURITY#${LB_MIRROR_BINARY_SECURITY}#" \
+ -e "s#LB_MIRROR_BINARY#${LB_MIRROR_BINARY}#" \
+ -e "s/LB_ARCHIVE_AREAS/${LB_ARCHIVE_AREAS}/" \
+ -e "s/LB_CHROOT_FILESYSTEM/${LB_CHROOT_FILESYSTEM}/" \
+ -e "s/LB_LINUX_FLAVOURS/${LB_LINUX_FLAVOURS}/" \
+ -e "s/LB_SECURITY/${LB_SECURITY}/" \
+ -e "s/LB_SYMLINKS/${LB_SYMLINKS}/" \
+ -e "s/LB_SYSVINIT/${LB_SYSVINIT}/" \
+ -e "s/LB_BINARY_INDICES/${LB_BINARY_INDICES}/" \
+ -e "s#LB_BOOTAPPEND_INSTALL#${LB_BOOTAPPEND_INSTALL}#" \
+ -e "s#LB_BOOTAPPEND_LIVE#${LB_BOOTAPPEND_LIVE}#" \
+ -e "s/LB_BOOTLOADER/${LB_BOOTLOADER}/" \
+ -e "s/LB_DEBIAN_INSTALLER/${LB_DEBIAN_INSTALLER}/" \
+ -e "s/LB_ENCRYPTION/${LB_ENCRYPTION}/" \
+ -e "s#LB_ISO_APPLICATION#${LB_ISO_APPLICATION}#" \
+ -e "s#LB_ISO_PREPARER#${LB_ISO_PREPARER}#" \
+ -e "s#LB_ISO_PUBLISHER#${LB_ISO_PUBLISHER}#" \
+ -e "s#LB_ISO_VOLUME#${LB_ISO_VOLUME}#" \
+ -e "s/LB_MEMTEST/${LB_MEMTEST}/" \
+ -e "s#LB_NET_ROOT_PATH#${LB_NET_ROOT_PATH}#" \
+ -e "s/LB_NET_ROOT_SERVER/${LB_NET_ROOT_SERVER}/" \
+ -e "s#SERVER#${_SERVER}#g" \
+ -e "s/LB_SOURCE_IMAGES/${LB_SOURCE_IMAGES}/" \
+ -e "s/LB_SOURCE/${LB_SOURCE}/" \
+ -e "s#CUSTOM_BOOTSTRAP#${_CUSTOM_BOOTSTRAP}#" \
+ -e "s#CUSTOM_BINARY#${_CUSTOM_BINARY}#" \
+ "${_TEMPLATES}"/build.html
+
+ # Creating temporary directory
+ mkdir -p "${_TEMPDIR}"
+
+# Writing build file
+cat > "${_TEMPDIR}"/"${_BUILD}".build << EOF
+# live-build.cgi "${VERSION}" build file
+# `date -R`
+
+_BUILD="${_BUILD}"
+_EMAIL="${_EMAIL}"
+
+REMOTE_ADDR="${REMOTE_ADDR}"
+
+# Standard options
+LB_BINARY_IMAGES="${LB_BINARY_IMAGES}"
+LB_DISTRIBUTION="${LB_DISTRIBUTION}"
+LB_PACKAGES_LISTS="${LB_PACKAGES_LISTS}"
+LB_TASKS="${LB_TASKS}"
+LB_PACKAGES="${LB_PACKAGES}"
+
+# Advanced bootstrap options
+LB_ARCHITECTURE="${LB_ARCHITECTURE}"
+LB_MIRROR_BOOTSTRAP="${LB_MIRROR_BOOTSTRAP}"
+LB_MIRROR_BINARY_SECURITY="${LB_MIRROR_BINARY_SECURITY}"
+LB_MIRROR_BINARY="${LB_MIRROR_BINARY}"
+LB_ARCHIVE_AREAS="${LB_ARCHIVE_AREAS}"
+
+# Advanced chroot options
+LB_CHROOT_FILESYSTEM="${LB_CHROOT_FILESYSTEM}"
+LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS}"
+LB_SECURITY="${LB_SECURITY}"
+LB_SYMLINKS="${LB_SYMLINKS}"
+LB_SYSVINIT="${LB_SYSVINIT}"
+
+# Advanced binary options
+LB_BINARY_INDICES="${LB_BINARY_INDICES}"
+LB_BOOTAPPEND_INSTALL="${LB_BOOTAPPEND_INSTALL}"
+LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE}"
+LB_BOOTLOADER="${LB_BOOTLOADER}"
+LB_DEBIAN_INSTALLER="${LB_DEBIAN_INSTALLER}"
+LB_ENCRYPTION="${LB_ENCRYPTION}"
+LB_ISO_APPLICATION="${LB_ISO_APPLICATION}"
+LB_ISO_PREPARER="${LB_ISO_PREPARER}"
+LB_ISO_PUBLISHER="${LB_ISO_PUBLISHER}"
+LB_ISO_VOLUME="${LB_ISO_VOLUME}"
+LB_MEMTEST="${LB_MEMTEST}"
+LB_NET_ROOT_PATH="${LB_NET_ROOT_PATH}"
+LB_NET_ROOT_SERVER="${LB_NET_ROOT_SERVER}"
+
+# Advanced source options
+LB_SOURCE_IMAGES="${LB_SOURCE_IMAGES}"
+LB_SOURCE="${LB_SOURCE}"
+
+# Unofficial options
+_CUSTOM_BOOTSTRAP="${_CUSTOM_BOOTSTRAP}"
+_CUSTOM_BINARY="${_CUSTOM_BINARY}"
+
+# Other
+LB_REPOSITORIES="${LB_REPOSITORIES}"
+EOF
+
+ echo "$(date +%b\ %d\ %H:%M:%S) ${HOSTNAME} live-build.cgi: add web build (${_BUILD}) from ${REMOTE_ADDR}." >> /var/log/live
+ echo "$(date +%b\ %d\ %H:%M:%S) ${HOSTNAME} live-build.cgi: options ${_BUILD} |email ${_EMAIL}|binary_images ${LB_BINARY_IMAGES}|distribution ${LB_DISTRIBUTION}|packages_lists ${LB_PACKAGES_LISTS}|tasks ${LB_TASKS}|packages ${LB_PACKAGES}|architecture ${LB_ARCHITECTURE}|mirror_bootstrap_security ${LB_MIRROR_BOOTSTRAP}|mirror_bootstrap ${LB_MIRROR_BOOTSTRAP}|mirror_binary_security ${LB_MIRROR_BINARY_SECURITY}|mirror_binary ${LB_MIRROR_BINARY}|archive_areas ${LB_ARCHIVE_AREAS}|chroot_filesystem ${LB_CHROOT_FILESYSTEM}|linux_flavours ${LB_LINUX_FLAVOURS}|security ${LB_SECURITY}|symlinks ${LB_SYMLINKS}|sysvinit ${LB_SYSVINIT}|binary_indices ${LB_BINARY_INDICES}|bootappend_install ${LB_BOOTAPPEND_INSTALL}|bootappend_live ${LB_BOOTAPPEND_LIVE}|bootloader ${LB_BOOTLOADER}|debian_installer ${LB_DEBIAN_INSTALLER}|encryption ${LB_ENCRYPTION}|iso_application ${LB_ISO_APPLICATION}|iso_preparer ${LB_ISO_PREPARER}|iso_publisher ${LB_ISO_PUBLISHER}|iso_volume ${LB_ISO_VOLUME}|memtest ${LB_MEMTEST}|net_path ${LB_NET_ROOT_PATH}|net_server ${LB_NET_ROOT_SERVER}|source_images ${LB_SOURCE_IMAGES}|source ${LB_SOURCE}|custom_bootstrap ${_CUSTOM_BOOTSTRAP}|custom_binary ${_CUSTOM_BINARY}\n" >> /var/log/live
+fi
+
+sed -e "s/VERSION/${VERSION}/" "${_TEMPLATES}"/footer.html
diff --git a/cgi/cron b/cgi/cron
new file mode 100755
index 000000000..1cbf018d7
--- /dev/null
+++ b/cgi/cron
@@ -0,0 +1,192 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>
+##
+## live-build comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
+## This is free software, and you are welcome to redistribute it
+## under certain conditions; see COPYING for details.
+
+
+# Including common functions
+. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh
+
+# Reading defaults
+if [ -r /etc/default/live-build.cgi ]
+then
+ . /etc/default/live-build.cgi
+else
+ echo "E: /etc/default/live-build.cgi missing"
+ exit 1
+fi
+
+# Exit if disabled
+if [ "${_WEBBUILD}" != "enabled" ]
+then
+ exit 0
+fi
+
+# Turn on debug if enabled
+if [ "${_DEBUG}" = "enabled" ]
+then
+ set -x
+fi
+
+# Checking lock file
+if [ -f /var/lock/live-build.cgi.lock ]
+then
+ echo "E: live-build.cgi already/still running."
+ exit 1
+fi
+
+# Creating lock trap
+trap "test -f /var/lock/live-build.cgi.lock && rm -f /var/lock/live-build.cgi.lock; exit 0" 0 1 2 3 9 15
+
+# Creating lock file
+touch /var/lock/live-build.cgi.lock
+
+# Cleanup old builds: cron should be run at least once per hour to take effect
+if ls "${_DESTDIR}"/`date -d yesterday +%Y%m%d.%H`* > /dev/null 2>&1
+then
+ rm -rf "${_DESTDIR}"/`date -d yesterday +%Y%m%d.%H`*
+
+ echo "`date +%b\ %d\ %H:%M:%S` ${HOSTNAME} live-build.cgi: remove web build (`date -d yesterday +%Y%m%d.%H`*)." >> /var/log/live
+fi
+
+# Ok from here spin through the live-build.cgi files we have waiting to build
+#if ls "${_TEMPDIR}"/*.build > /dev/null 2>&1
+if Find_files ${_TEMPDIR}/*.build
+then
+ for _FILE in "${_TEMPDIR}"/*.build
+ do
+ # Pull in the variables we want from the config file.
+ # Pul in the build number
+ _BUILD=`awk -F\" '/^_BUILD=/{print $2}' ${_FILE}`
+ # Pull in the email address
+ _EMAIL=`awk -F\" '/^_EMAIL=/{print $2}' ${_FILE}`
+ # Pull in the remote address, atchitecture, and distribution
+ _REMOTE_ADDR=`awk -F\" '/^REMOTE_ADDR=/{print $2}' ${_FILE}`
+ _LB_ARCHITECTURE=`awk -F\" '/^LB_ARCHITECTURE=/{print $2}' ${_FILE}`
+ _LB_DISTRIBUTION=`awk -F\" '/^LB_DISTRIBUTION=/{print $2}' ${_FILE}`
+ _LB_PACKAGES_LISTS=`awk -F\" '/^LB_PACKAGES_LISTS=/{print $2}' ${_FILE}`
+ _LB_PACKAGES=`awk -F\" '/^LB_PACKAGES=/{print $2}' ${_FILE}`
+ # Pull in the custom bootstrap
+ _CUSTOM_BOOTSTRAP=`awk -F\" '/^_CUSTOM_BOOTSTRAP=/{print $2}' ${_FILE}`
+ # Pull in the custom binary
+ _CUSTOM_BINARY=`awk -F\" '/^_CUSTOM_BINARY=/{print $2}' ${_FILE}`
+
+ # Drop out some build data for information if something goes wrong.
+ echo "`date +%b\ %d\ %H:%M:%S` ${HOSTNAME} live-build.cgi: begin web build (${_BUILD})." >> /var/log/live
+
+ # Creating build directory which also creates the config/chroot_sources folder
+ mkdir -p "${_TEMPDIR}"/"${_BUILD}"/config/chroot_sources
+
+ # The next two tests are for unofficial third party repositories
+ if [ -n "${_CUSTOM_BOOTSTRAP}" ]
+ then
+ echo "${_CUSTOM_BOOTSTRAP}" > "${_TEMPDIR}"/"${_BUILD}"/config/chroot_sources/custom.bootstrap
+ fi
+
+ if [ -n "${_CUSTOM_BINARY}" ]
+ then
+ echo "${_CUSTOM_BINARY}" > "${_TEMPDIR}"/"${_BUILD}"/config/chroot_sources/custom.binary
+ fi
+
+ _DATE_START="`date -R`"
+ echo "Begin: ${_DATE_START}" > "${_TEMPDIR}"/"${_BUILD}"/log
+
+ # Generating image
+ cd "${_TEMPDIR}"/"${_BUILD}"
+ lb config -c ${_FILE} >> "${_TEMPDIR}"/"${_BUILD}"/log 2>&1
+ _ERRORCONFIG="${?}"
+ lb build >> "${_TEMPDIR}"/"${_BUILD}"/log 2>&1
+ _ERRORBUILD="${?}"
+
+ _DATE_END="`date -R`"
+ echo "End: ${_DATE_END}" >> "${_TEMPDIR}"/"${_BUILD}"/log
+
+ # Creating image directory
+ mkdir -p "${_DESTDIR}"/"${_BUILD}"
+
+ # Creating mail and logging.
+ if [ "${_ERRORCONFIG}" -eq "0" ] && [ "${_ERRORBUILD}" -eq "0" ]
+ then
+ _STATUS="maybe-successful"
+ echo "${_REMOTE_ADDR} - - `date +[%d/%b/%Y:%H:%m:%S\ %z]` \"${_BUILD} ${_LB_ARCHITECTURE}/${_LB_DISTRIBUTION}/${_LB_PACKAGES_LISTS}/${_LB_PACKAGES}\" 200 - \"-\" \"\"">>/var/log/live-cgi.builds
+ else
+ _STATUS="maybe-failed"
+ echo "${_REMOTE_ADDR} - - `date +[%d/%b/%Y:%H:%m:%S\ %z]` \"${_BUILD} ${_LB_ARCHITECTURE}/${_LB_DISTRIBUTION}/${_LB_PACKAGES_LISTS}/${_LB_PACKAGES}\" 404 - \"-\" \"\"">>/var/log/live-cgi.builds
+ fi
+
+ sed -e "s/BUILD/${_BUILD}/g" \
+ -e "s/EMAIL/${_EMAIL}/" \
+ -e "s/VERSION/${VERSION}/" \
+ -e "s/DATE_START/${_DATE_START}/" \
+ -e "s/DATE_END/${_DATE_END}/" \
+ -e "s/STATUS/${_STATUS}/" \
+ -e "s#SERVER#${_SERVER}#" \
+ "${_TEMPLATES}"/mail.txt > "${_DESTDIR}"/"${_BUILD}"/mail
+
+cat >> "${_DESTDIR}"/"${_BUILD}"/mail << EOF
+
+---
+
+Here's a list of all build-options that were used to build your image:
+
+EOF
+
+ cat "${_TEMPDIR}"/"${_BUILD}".build >> "${_DESTDIR}"/"${_BUILD}"/mail
+
+ # Moving binary image
+ #if ls "${_TEMPDIR}"/"${_BUILD}"/binary*.* > /dev/null 2>&1
+ if Find_files ${_TEMPDIR}/${_BUILD}/binary*.*
+ then
+ mv "${_TEMPDIR}"/"${_BUILD}"/binary*.* "${_DESTDIR}"/"${_BUILD}"
+ fi
+
+ # Moving source image
+ #if ls "${_TEMPDIR}"/"${_BUILD}"/source.* > /dev/null 2>&1
+ if Find_files ${_TEMPDIR}/${_BUILD}/source.*
+ then
+ mv "${_TEMPDIR}"/"${_BUILD}"/source.* "${_DESTDIR}"/"${_BUILD}"
+ fi
+
+ # Moving build
+ mv "${_TEMPDIR}"/"${_BUILD}".build "${_DESTDIR}"/"${_BUILD}"/build
+
+ # Moving log
+ mv "${_TEMPDIR}"/"${_BUILD}"/log "${_DESTDIR}"/"${_BUILD}"
+
+ # Generating md5sum
+ cd "${_DESTDIR}"/"${_BUILD}"
+ md5sum * > md5sum
+ cd "${OLDPWD}"
+
+ # Sending mail
+ cat "${_DESTDIR}"/"${_BUILD}"/mail | /usr/sbin/sendmail -t
+
+ # Unmounting devpts-live
+ #if ls "${_TEMPDIR}"/"${_BUILD}"/chroot/dev/pts/* > /dev/null 2>&1
+ if Find_files ${_TEMPDIR}/${_BUILD}/chroot/dev/pts/*
+ then
+ umount "${_TEMPDIR}"/${_BUILD}/chroot/dev/pts
+ fi
+
+ # Unmounting proc
+ if [ -f "${_TEMPDIR}"/"${_BUILD}"/chroot/proc/version ]
+ then
+ umount "${_TEMPDIR}"/"${_BUILD}"/chroot/proc
+ fi
+
+ # Unmounting sysfs
+ if [ -d "${_TEMPDIR}"/"${_BUILD}"/chroot/sys/kernel ]
+ then
+ umount "${_TEMPDIR}"/${_BUILD}/chroot/sys
+ fi
+
+ # Removing build directory
+ rm -rf "${_TEMPDIR}"/"${_BUILD}"
+
+ echo "`date +%b\ %d\ %H:%M:%S` ${HOSTNAME} live-build.cgi: end web build (${_BUILD}: ${_STATUS})." >> /var/log/live
+ done
+fi
diff --git a/cgi/crontab b/cgi/crontab
new file mode 100644
index 000000000..0cb78a330
--- /dev/null
+++ b/cgi/crontab
@@ -0,0 +1,7 @@
+# /etc/crontab - system-wide crontab
+
+SHELL=/bin/sh
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+
+# m h dom mon dow user command
+*/1 * * * * root /etc/cron.hourly/live-webhelper > /dev/null 2>&1
diff --git a/cgi/default b/cgi/default
new file mode 100644
index 000000000..37a879b25
--- /dev/null
+++ b/cgi/default
@@ -0,0 +1,17 @@
+# Defaults for /etc/cron.daily/live-build.cgi
+
+_WEBBUILD="disabled"
+
+_MODE="debian-official"
+
+_DEBUG="disabled"
+
+_DESTDIR="/srv/debian-live/build/www"
+_TEMPLATES="/usr/share/live/build/templates/cgi/${_MODE}"
+_TEMPDIR="/srv/debian-live/build/tmp"
+
+LB_MIRROR_BOOTSTRAP="http://ftp.de.debian.org/debian/"
+LB_MIRROR_BINARY="http://ftp.debian.org/debian/"
+LB_MIRROR_BINARY_SECURITY="http://security.debian.org/"
+
+_SERVER="http://live.debian.net/build"
diff --git a/cgi/logrotate b/cgi/logrotate
new file mode 100644
index 000000000..75d89a9eb
--- /dev/null
+++ b/cgi/logrotate
@@ -0,0 +1,11 @@
+# /etc/logrotate.d/live-build
+
+/var/log/live
+{
+ compress
+ copytruncate
+ missingok
+ monthly
+ notifempty
+ rotate 24
+}