summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2013-06-25 09:04:42 +0200
committerDaniel Baumann <mail@daniel-baumann.ch>2013-06-25 09:04:42 +0200
commit86746ac72fb9dc558e40914de9aea26ad58d19b1 (patch)
treec8b99efde0ed4d6e77351eb9cc189d635162e188 /frontend
parent1807e40dd3666564851b2b0d855513bd004a927d (diff)
downloadvyos-live-build-86746ac72fb9dc558e40914de9aea26ad58d19b1.tar.gz
vyos-live-build-86746ac72fb9dc558e40914de9aea26ad58d19b1.zip
Reorganizing frontend in source tree.
Diffstat (limited to 'frontend')
-rw-r--r--frontend/cgi/Makefile21
-rwxr-xr-xfrontend/cgi/live-build-cgi217
-rwxr-xr-xfrontend/cgi/live-build-cgi.cron208
-rw-r--r--frontend/cgi/live-build-cgi.crontab7
-rw-r--r--frontend/cgi/live-build-cgi.default19
-rw-r--r--frontend/cgi/live-build-cgi.logrotate11
-rwxr-xr-xfrontend/cli/lb80
-rwxr-xr-xfrontend/cli/live-build37
8 files changed, 600 insertions, 0 deletions
diff --git a/frontend/cgi/Makefile b/frontend/cgi/Makefile
new file mode 100644
index 000000000..8ac08ddac
--- /dev/null
+++ b/frontend/cgi/Makefile
@@ -0,0 +1,21 @@
+# Makefile
+
+install:
+ install -D -m 0755 live-build-cgi $(DESTDIR)/usr/lib/cgi-bin/live-build
+ install -D -m 0755 live-build-cgi.cron $(DESTDIR)/etc/cron.hourly/live-build-cgi
+ install -D -m 0644 live-build-cgi.crontab $(DESTDIR)/etc/cron.d/live-build-cgi
+ install -D -m 0644 live-build-cgi.default $(DESTDIR)/etc/default/live-build-cgi
+ install -D -m 0644 live-build-cgi.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/cron.hourly/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/frontend/cgi/live-build-cgi b/frontend/cgi/live-build-cgi
new file mode 100755
index 000000000..49cb1e5bf
--- /dev/null
+++ b/frontend/cgi/live-build-cgi
@@ -0,0 +1,217 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## This program 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
+. /usr/lib/live/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
+
+_HOSTNAME="$(hostname -f)"
+
+# Turn on debug if true
+if [ "${_DEBUG}" = "true" ]
+then
+ set -x
+fi
+
+# Sending http header
+echo "Content-type: text/html"
+echo
+
+# If we are passed something then read it in.
+if [ "$REQUEST_METHOD" = "POST" ] && [ "$CONTENT_LENGTH" -gt 0 ]
+then
+ #QUERY_STRING=`cat /dev/stdin`
+ QUERY_STRING=$(cat /dev/stdin)
+ #read -n $CONTENT_LENGTH POST_DATA <&0
+fi
+
+# Translate parameters
+QUERY_STRING=$(echo "${POST_DATA}" | 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}
+
+
+# Sending html header
+cat "${_TEMPLATES}"/header.html
+
+# CGI
+if [ -z "${QUERY_STRING}" ]
+then
+ # Sending html form
+ sed -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'
+
+ # Email
+ _EMAIL=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])email=[-0-9a-zA-Z._@]+' | cut -f 2 -d '=' | head -n1)
+
+ # CGI Packages List
+ _LB_CGIPACKAGES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])cgipackages=[-0-9a-zA-Z. _+]+' | cut -f 2 -d '=' | head -n1)
+
+ # CGI Config for git
+ _LB_CONFIG=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])config=[-a-z]+' | cut -f 2 -d '=' | head -n1)
+
+ # Standard options
+ LIVE_IMAGE_TYPE=$(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)
+
+ # Advanced bootstrap options
+ LIVE_IMAGE_ARCHITECTURE=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])architectures=[0-9a-z]+' | cut -f 2 -d '=' | head -n1)
+ LIVE_IMAGE_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)
+
+ # Advanced binary options
+ LB_APT_INDICES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])apt_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_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)
+
+ # 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/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)
+
+ # Getting number of builds pending.
+ _QUEUENUM=$(ls "${_TEMPDIR}"/*.build | wc -l)
+
+ #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/QUEUENUM/${_QUEUENUM}/" \
+ -e "s/LIVE_IMAGE_TYPE/${LIVE_IMAGE_TYPE}/" \
+ -e "s/LB_DISTRIBUTION/${LB_DISTRIBUTION}/" \
+ -e "s#_LB_CONFIG#${_LB_CONFIG}#" \
+ -e "s/_LB_CGIPACKAGES/${_LB_CGIPACKAGES}/" \
+ -e "s/LIVE_IMAGE_ARCHITECTURE/${LIVE_IMAGE_ARCHITECTURE}/" \
+ -e "s/LIVE_IMAGE_ARCHIVE_AREAS/${LIVE_IMAGE_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_APT_INDICES/${LB_APT_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_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}/" \
+ "${_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}"
+
+# CGI Packages List
+_LB_CGIPACKAGES="${_LB_CGIPACKAGES}"
+
+# CGI Config for git
+_LB_CONFIG="${_LB_CONFIG}"
+
+# Standard options
+LIVE_IMAGE_TYPE="${LIVE_IMAGE_TYPE}"
+LB_DISTRIBUTION="${LB_DISTRIBUTION}"
+
+# Advanced bootstrap options
+LIVE_IMAGE_ARCHITECTURE="${LIVE_IMAGE_ARCHITECTURE}"
+LIVE_IMAGE_ARCHIVE_AREAS="${LIVE_IMAGE_ARCHIVE_AREAS}"
+
+# Advanced chroot options
+LB_CHROOT_FILESYSTEM="${LB_CHROOT_FILESYSTEM}"
+LB_LINUX_FLAVOURS="${LB_LINUX_FLAVOURS}"
+LB_SECURITY="${LB_SECURITY}"
+
+# Advanced binary options
+LB_APT_INDICES="${LB_APT_INDICES}"
+LB_BOOTAPPEND_INSTALL="${LB_BOOTAPPEND_INSTALL}"
+LB_BOOTAPPEND_LIVE="${LB_BOOTAPPEND_LIVE}"
+LB_BOOTLOADER="${LB_BOOTLOADER}"
+LB_DEBIAN_INSTALLER="${LB_DEBIAN_INSTALLER}"
+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}"
+
+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 ${LIVE_IMAGE_TYPE}|distribution ${LB_DISTRIBUTION}|config ${_LB_CONFIG}|cgipackages ${_LB_CGIPACKAGES}|architectures ${LIVE_IMAGE_ARCHITECTURE}|archive_areas ${LIVE_IMAGE_ARCHIVE_AREAS}|chroot_filesystem ${LB_CHROOT_FILESYSTEM}|linux_flavours ${LB_LINUX_FLAVOURS}|security ${LB_SECURITY}|apt_indices ${LB_APT_INDICES}|bootappend_install ${LB_BOOTAPPEND_INSTALL}|bootappend_live ${LB_BOOTAPPEND_LIVE}|bootloader ${LB_BOOTLOADER}|debian_installer ${LB_DEBIAN_INSTALLER}|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}|sources ${LB_SOURCE}" >> /var/log/live
+fi
+
+sed -e "s/VERSION/${VERSION}/" "${_TEMPLATES}"/footer.html
diff --git a/frontend/cgi/live-build-cgi.cron b/frontend/cgi/live-build-cgi.cron
new file mode 100755
index 000000000..bd2694d8f
--- /dev/null
+++ b/frontend/cgi/live-build-cgi.cron
@@ -0,0 +1,208 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## This program 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
+. /usr/lib/live/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}" != "true" ]
+then
+ exit 0
+fi
+
+_HOSTNAME="$(hostname -f)"
+
+# Turn on debug if true
+if [ "${_DEBUG}" = "true" ]
+then
+ set -x
+fi
+
+# Locknum sets the lock enumeration for multiple instances of l-b-cgi
+_LOCKNUM="$(expr 1 + $(expr $(date +%M) % ${_INSTANCES}))"
+
+# Checking lock file
+if [ -f /var/lock/live-build-cgi-${_LOCKNUM}.lock ]
+then
+ echo "E: live-build-cgi instance ${_LOCKNUM} already/still running."
+ exit 1
+fi
+
+# Creating lock trap
+trap "test -f /var/lock/live-build-cgi-${_LOCKNUM}.lock && rm -f /var/lock/live-build-cgi-${_LOCKNUM}.lock; exit 0" 0 1 2 3 9 15
+
+# Creating lock file
+touch /var/lock/live-build-cgi-${_LOCKNUM}.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
+ _FILE=$(ls "${_TEMPDIR}"/*.build | sort | head -1)
+ # Pull in variables from the build file.
+ . "${_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
+
+ # Clone the git config to target build directory
+ git clone ${_LB_GIT} "${_TEMPDIR}"/"${_BUILD}" >> /var/log/live
+ _ERRORGIT="${?}"
+
+ # Moving build file to the tempdir and remove from submission area.
+ mv "${_TEMPDIR}"/"${_BUILD}".build "${_TEMPDIR}"/"${_BUILD}"/
+
+ # Sanity check to default to something since we are going to build from git clone.
+ if [ -z "${_LB_CONFIG}" ]
+ then
+ _LB_CONFIG="standard"
+ fi
+
+ # Now set a variable for the correct build path
+ _BUILD_PATH="${_TEMPDIR}/${_BUILD}/images/${_LB_CONFIG}"
+
+ _DATE_START="`date -R`"
+ echo "Begin live-build-cgi: ${_DATE_START}" > "${_BUILD_PATH}"/log
+ echo "Info live-build-cgi: Config tree cloned from ${_LB_GIT} for build ${_BUILD}" >> "${_BUILD_PATH}"/log
+
+ # Creating directory for the config/package-lists
+ mkdir -p "${_BUILD_PATH}"/config/package-lists
+
+ # Add cgipackages.list.chroot
+ if [ -n "${_LB_CGIPACKAGES}" ]
+ then
+ echo "${_LB_CGIPACKAGES}" > "${_BUILD_PATH}"/config/package-lists/cgipackages.list.chroot
+ fi
+
+ # Generating config here
+ if [ "${_ERRORGIT}" -eq "0" ]
+ then
+ cd "${_BUILD_PATH}"
+ # Do config with git and stack on config file params to build
+ lb config ${_CGI_CONFIG_APPEND} --distribution "${LB_DISTRIBUTION}" --binary-images "${LB_BINARY_IMAGES}" --architectures "${LIVE_IMAGE_ARCHITECTURE}" --archive-areas "${LIVE_IMAGE_ARCHIVE_AREAS}" --chroot-filesystem "${LB_CHROOT_FILESYSTEM}" --linux-flavours "${LB_LINUX_FLAVOURS}" --security "${LB_SECURITY}" --apt-indices "${LB_APT_INDICES}" --bootappend-install "${LB_BOOTAPPEND_INSTALL}" --bootappend-live "${LB_BOOTAPPEND_LIVE}" --bootloader "${LB_BOOTLOADER}" --debian-installer "${LB_DEBIAN_INSTALLER}" --iso-application "${LB_ISO_APPLICATION}" --iso-preparer "${LB_ISO_PREPARER}" --iso-publisher "${LB_ISO_PUBLISHER}" --iso-volume "${LB_ISO_VOLUME}" --memtest "${LB_MEMTEST}" --net-root-path "${LB_NET_ROOT_PATH}" --net-root-server "${LB_NET_ROOT_SERVER}" --source-images "${LB_SOURCE_IMAGES}" --source "${LB_SOURCE}"
+ _ERRORCONFIG="${?}"
+ else
+ echo "Config stage skipped. The git clone produced an error: ${_ERRORGIT}" >> "${_BUILD_PATH}"/log
+ fi
+
+ # Run build if config went ok
+ if [ "${_ERRORCONFIG}" -eq "0" ]
+ then
+ # We need to finish script.
+ set +e
+ lb build noauto >> "${_BUILD_PATH}"/log 2>&1
+ _ERRORBUILD="${?}"
+ else
+ echo "Build stage skipped. Config produced an error: ${_ERRORCONFIG}" >> "${_BUILD_PATH}"/log
+ fi
+
+ _DATE_END="`date -R`"
+ echo "End: ${_DATE_END}" >> "${_BUILD_PATH}"/log
+
+ # Creating image directory
+ mkdir -p "${_DESTDIR}"/"${_BUILD}"
+
+ # Creating mail and logging.
+ if [ "${_ERRORGIT}" -eq "0" ] && [ "${_ERRORCONFIG}" -eq "0" ] && [ "${_ERRORBUILD}" -eq "0" ]
+ then
+ _STATUS="maybe-successful"
+ echo "${REMOTE_ADDR} - - `date +[%d/%b/%Y:%H:%m:%S\ %z]` \"${_BUILD} ${LIVE_IMAGE_ARCHITECTURE}/${LB_DISTRIBUTION}/${_LB_CGIPACKAGES}\" 200 - \"-\" \"\"">>/var/log/live-cgi.builds
+ else
+ _STATUS="maybe-failed"
+ echo "${REMOTE_ADDR} - - `date +[%d/%b/%Y:%H:%m:%S\ %z]` \"${_BUILD} ${LIVE_IMAGE_ARCHITECTURE}/${LB_DISTRIBUTION}/${_LB_CGIPACKAGES}\" 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}".build >> "${_DESTDIR}"/"${_BUILD}"/mail
+
+ # Moving binary image
+ #if ls "${_TEMPDIR}"/"${_BUILD}"/binary*.* > /dev/null 2>&1
+ if Find_files ${_BUILD_PATH}/binary*.*
+ then
+ mv "${_BUILD_PATH}"/binary*.* "${_DESTDIR}"/"${_BUILD}"
+ fi
+
+ # Moving source image
+ #if ls "${_TEMPDIR}"/"${_BUILD}"/source.* > /dev/null 2>&1
+ if Find_files ${_BUILD_PATH}/source.*
+ then
+ mv "${_BUILD_PATH}"/source.* "${_DESTDIR}"/"${_BUILD}"
+ fi
+
+ # Moving build
+ mv "${_TEMPDIR}"/"${_BUILD}"/"${_BUILD}".build "${_DESTDIR}"/"${_BUILD}"/build
+
+ # Moving log
+ mv "${_BUILD_PATH}"/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 ${_BUILD_PATH}/chroot/dev/pts/*
+ then
+ umount "${_BUILD_PATH}"/chroot/dev/pts
+ fi
+
+ # Unmounting proc
+ if [ -f "${_BUILD_PATH}"/chroot/proc/version ]
+ then
+ umount "${_BUILD_PATH}"/chroot/proc
+ fi
+
+ # Unmounting sysfs
+ if [ -d "${_BUILD_PATH}"/chroot/sys/kernel ]
+ then
+ umount "${_BUILD_PATH}"/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
+fi
diff --git a/frontend/cgi/live-build-cgi.crontab b/frontend/cgi/live-build-cgi.crontab
new file mode 100644
index 000000000..1bf7a815d
--- /dev/null
+++ b/frontend/cgi/live-build-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-build-cgi > /dev/null 2>&1
diff --git a/frontend/cgi/live-build-cgi.default b/frontend/cgi/live-build-cgi.default
new file mode 100644
index 000000000..c7e26bc5f
--- /dev/null
+++ b/frontend/cgi/live-build-cgi.default
@@ -0,0 +1,19 @@
+# Defaults for /etc/cron.daily/live-build-cgi
+
+_WEBBUILD="false"
+
+_MODE="debian"
+
+_DEBUG="false"
+
+_INSTANCES="1"
+
+_DESTDIR="/srv/debian-live/build/www"
+_TEMPLATES="/usr/share/live/build/templates/cgi/${_MODE}"
+_TEMPDIR="/srv/debian-live/build/tmp"
+
+_SERVER="http://live-systems.org/build"
+
+_LB_GIT="git://live-systems.org/git/live-images.git"
+
+_CGI_CONFIG_APPEND=""
diff --git a/frontend/cgi/live-build-cgi.logrotate b/frontend/cgi/live-build-cgi.logrotate
new file mode 100644
index 000000000..75d89a9eb
--- /dev/null
+++ b/frontend/cgi/live-build-cgi.logrotate
@@ -0,0 +1,11 @@
+# /etc/logrotate.d/live-build
+
+/var/log/live
+{
+ compress
+ copytruncate
+ missingok
+ monthly
+ notifempty
+ rotate 24
+}
diff --git a/frontend/cli/lb b/frontend/cli/lb
new file mode 100755
index 000000000..a57577f94
--- /dev/null
+++ b/frontend/cli/lb
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## This program 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.
+
+
+set -e
+
+# Including common functions
+[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
+
+# Setting static variables
+DESCRIPTION="$(Echo 'utility to build live systems')"
+HELP="FIXME"
+USAGE="FIXME"
+
+case "${1}" in
+ -h|--help)
+ if [ -x "$(which man 2>/dev/null)" ]
+ then
+ man lb
+ exit 0
+ else
+ ${0} --usage
+ exit 0
+ fi
+ ;;
+
+ ""|-u|--usage)
+ Usage
+ ;;
+
+ -v|--version)
+ echo "${VERSION}"
+ exit 0
+ ;;
+
+ *)
+ COMMAND="${1}"
+ shift
+
+ ENV=""
+
+ for _FILE in config/environment config/environment.binary
+ do
+ if [ -e "${_FILE}" ]
+ then
+ ENV="${ENV} $(grep -v '^#' ${_FILE})"
+ fi
+ done
+
+ if [ -x "${LIVE_BUILD}/scripts/build/${COMMAND}" ]
+ then
+ # User has live-build copied locally in the system
+ SCRIPT="${LIVE_BUILD}/scripts/build/${COMMAND}"
+ elif [ -x "local/live-build/scripts/build/${COMMAND}" ]
+ then
+ # User has live-build copied locally in the config
+ SCRIPT="local/live-build/scripts/build/${COMMAND}"
+ elif [ -x /usr/lib/live/build/${COMMAND} ]
+ then
+ # User has live-build installed in the system
+ SCRIPT=/usr/lib/live/build/"${COMMAND}"
+ elif [ -x "$(which ${COMMAND} 2>/dev/null)" ]
+ then
+ # User has live-build commands in path
+ SCRIPT="${COMMAND}"
+ else
+ Echo_error "no such script: ${COMMAND}"
+ exit 1
+ fi
+
+ Echo "[%s] %s" "$(date +'%F %T')" "lb ${COMMAND} $(echo ${@})"
+ ${ENV} exec "${SCRIPT}" "${@}"
+ ;;
+esac
diff --git a/frontend/cli/live-build b/frontend/cli/live-build
new file mode 100755
index 000000000..d78060bef
--- /dev/null
+++ b/frontend/cli/live-build
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+## live-build(7) - System Build Scripts
+## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+##
+## The complete text of the GNU General Public License
+## can be found in /usr/share/common-licenses/GPL-3 file.
+
+
+set -e
+
+if [ -x "$(which man 2>/dev/null)" ]
+then
+ man live-build
+else
+
+cat << EOF
+live-build contains the scripts to build a live system from a configuration
+directory.
+
+An introduction to live-build can be found in the live-build(7) manpage.
+EOF
+
+fi