From 8be5f9d036bad60cf9ad7169c3e7c356aeba55b6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Mar 2010 11:49:29 +0100 Subject: Merging live-webhelper. --- Makefile | 6 +- cgi/cgi | 239 ++++++++++++++++++ cgi/common | 1 + cgi/cron | 175 ++++++++++++++ cgi/default | 18 ++ docs/ChangeLog.live-webhelper | 182 ++++++++++++++ examples/cron/crontab | 7 + templates/cgi/debian-official/build.html | 78 ++++++ templates/cgi/debian-official/footer.html | 7 + templates/cgi/debian-official/form.html | 338 ++++++++++++++++++++++++++ templates/cgi/debian-official/header.html | 43 ++++ templates/cgi/debian-official/mail.txt | 16 ++ templates/cgi/debian-unofficial/build.html | 85 +++++++ templates/cgi/debian-unofficial/footer.html | 7 + templates/cgi/debian-unofficial/form.html | 359 ++++++++++++++++++++++++++++ templates/cgi/debian-unofficial/header.html | 43 ++++ templates/cgi/debian-unofficial/mail.txt | 16 ++ 17 files changed, 1617 insertions(+), 3 deletions(-) create mode 100755 cgi/cgi create mode 100644 cgi/common create mode 100755 cgi/cron create mode 100644 cgi/default create mode 100644 docs/ChangeLog.live-webhelper create mode 100644 examples/cron/crontab create mode 100644 templates/cgi/debian-official/build.html create mode 100644 templates/cgi/debian-official/footer.html create mode 100644 templates/cgi/debian-official/form.html create mode 100644 templates/cgi/debian-official/header.html create mode 100644 templates/cgi/debian-official/mail.txt create mode 100644 templates/cgi/debian-unofficial/build.html create mode 100644 templates/cgi/debian-unofficial/footer.html create mode 100644 templates/cgi/debian-unofficial/form.html create mode 100644 templates/cgi/debian-unofficial/header.html create mode 100644 templates/cgi/debian-unofficial/mail.txt diff --git a/Makefile b/Makefile index aa61e1c..6bae1cd 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ all: test install test: # Checking for syntax errors - for SCRIPT in live-helper.sh functions/* examples/*/*.sh helpers/* hooks/*; \ + for SCRIPT in live-helper.sh cgi/* functions/* examples/*/*.sh helpers/* hooks/*; \ do \ sh -n $$SCRIPT; \ done @@ -16,7 +16,7 @@ test: # Checking for bashisms if [ -x /usr/bin/checkbashisms ]; \ then \ - checkbashisms live-helper.sh functions/* examples/*/*.sh helpers/* hooks/*; \ + checkbashisms live-helper.sh cgi/* functions/* examples/*/*.sh helpers/* hooks/*; \ else \ echo "WARNING: skipping bashism test - you need to install devscripts."; \ fi @@ -27,7 +27,7 @@ build: install: # Installing shared data mkdir -p $(DESTDIR)/usr/share/live-helper - cp -r data examples live-helper.sh functions helpers hooks includes lists templates $(DESTDIR)/usr/share/live-helper + cp -r cgi data examples live-helper.sh functions helpers hooks includes lists templates $(DESTDIR)/usr/share/live-helper # Installing executables mkdir -p $(DESTDIR)/usr/bin diff --git a/cgi/cgi b/cgi/cgi new file mode 100755 index 0000000..c38054e --- /dev/null +++ b/cgi/cgi @@ -0,0 +1,239 @@ +#!/bin/bash + +# live-webhelper - web interface to live-helper +# Copyright (C) 2007-2010 Daniel Baumann +# +# 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 2 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, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# On Debian systems, the complete text of the GNU General Public License +# can be found in /usr/share/common-licenses/GPL-2 file. + +# Reading common +. /usr/share/live-webhelper/common + +# Reading defaults +if [ -r /etc/default/live-webhelper ] +then + . /etc/default/live-webhelper +else + echo "E: /etc/default/live-webhelper missing" + exit 1 +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#LH_MIRROR_BOOTSTRAP_SECURITY#${LH_MIRROR_BOOTSTRAP_SECURITY}#" \ + -e "s#LH_MIRROR_BOOTSTRAP#${LH_MIRROR_BOOTSTRAP}#" \ + -e "s#LH_MIRROR_BINARY_SECURITY#${LH_MIRROR_BINARY_SECURITY}#" \ + -e "s#LH_MIRROR_BINARY#${LH_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' + + # 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') + # Debug the filtering string + # echo ${QUERY_STRING} + + # Email + _EMAIL=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])email=[0-9,a-z,A-Z,.,_,-,@]+' | cut -f 2 -d '=' | head -n1) + + # Standard options + LH_BINARY_IMAGES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])binary_images=[a-z,-]+' | cut -f 2 -d '=' | head -n1) + LH_DISTRIBUTION=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])distribution=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_PACKAGES_LISTS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])packages_lists=[0-9,a-z,-]+' | cut -f 2 -d '=' | head -n1) + LH_PACKAGES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])packages=[0-9,a-z,A-Z,., ,_,-]+' | cut -f 2 -d '=' | head -n1) + + # Advanced bootstrap options + LH_ARCHITECTURE=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])architecture=[0-9,a-z]+' | cut -f 2 -d '=' | head -n1) + LH_BOOTSTRAP_FLAVOUR=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])bootstrap_flavour=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_MIRROR_BOOTSTRAP=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])mirror_bootstrap=[0-9,a-z,A-Z,.,~,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_MIRROR_BOOTSTRAP_SECURITY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])mirror_bootstrap=[0-9,a-z,A-Z,.,~,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_MIRROR_BINARY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])mirror_binary=[0-9,a-z,A-Z,.,~,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_MIRROR_BINARY_SECURITY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])mirror_binary_security=[0-9,a-z,A-Z,.,~,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_SECTIONS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])sections=[a-z]+' | cut -f 2 -d '=' | head -n1) + + # Advanced chroot options + LH_CHROOT_FILESYSTEM=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])chroot_filesystem=[0-9,a-z]+' | cut -f 2 -d '=' | head -n1) + LH_LINUX_FLAVOURS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])linux_flavours=[0-9,a-z,-]+' | cut -f 2 -d '=' | head -n1) + LH_SECURITY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])security=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_SYMLINKS=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])symlinks=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_SYSVINIT=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])sysvinit=[a-z]+' | cut -f 2 -d '=' | head -n1) + + # Advanced binary options + LH_BINARY_INDICES=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])binary_indices=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_BOOTAPPEND=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])bootappend=[0-9,a-z,A-Z,., ,_,+,-]+' | cut -f 2 -d '=' | head -n1) + LH_BOOTLOADER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])bootloader=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_DEBIAN_INSTALLER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])debian_installer=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_ENCRYPTION=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])encryption=[0-9,a-z,A-Z]+' | cut -f 2 -d '=' | head -n1) + LH_HOSTNAME=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])hostname=[0-9,a-z,A-Z,.,-]+' | cut -f 2 -d '=' | head -n1) + LH_ISO_APPLICATION=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_application=[0-9,a-z,A-Z,., ,~,;,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_ISO_PREPARER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_preparer=[0-9,a-z,A-Z,., ,~,;,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_ISO_PUBLISHER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_publisher=[0-9,a-z,A-Z,., ,~,;,:,/,_,/,-]+' | cut -f 2 -d '=' | head -n1) + LH_ISO_VOLUME=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])iso_volume=[0-9,a-z,A-Z,., ,~,;,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_MEMTEST=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])memtest=[0-9,a-z,A-Z,.,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_NET_ROOT_PATH=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])net_path=[0-9,a-z,A-Z,.,_,/,-]+' | cut -f 2 -d '=' | head -n1) + LH_NET_ROOT_SERVER=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])net_server=[0-9,a-z,A-Z,.,_,-]+' | cut -f 2 -d '=' | head -n1) + LH_USERNAME=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])username=[0-9,a-z,A-Z,.,-]+' | cut -f 2 -d '=' | head -n1) + + # Advanced source options + LH_SOURCE=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])source=[a-z]+' | cut -f 2 -d '=' | head -n1) + LH_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-9,a-z,A-Z,., ,~,;,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + _CUSTOM_BINARY=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])custom_binary=[0-9,a-z,A-Z,., ,~,;,:,/,_,-]+' | cut -f 2 -d '=' | head -n1) + + # FIXME: filter invalid options + unset QUERY_STRING + + if [ -z "${_EMAIL}" ] + then + echo "

Error: No email address specified.

" + + sed -e "s#LH_MIRROR_BOOTSTRAP_SECURITY#${LH_MIRROR_BOOTSTRAP_SECURITY}#" \ + -e "s#LH_MIRROR_BOOTSTRAP#${LH_MIRROR_BOOTSTRAP}#" \ + -e "s#LH_MIRROR_BINARY_SECURITY#${LH_MIRROR_BINARY_SECURITY}#" \ + -e "s#LH_MIRROR_BINARY#${LH_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/LH_BINARY_IMAGES/${LH_BINARY_IMAGES}/" \ + -e "s/LH_DISTRIBUTION/${LH_DISTRIBUTION}/" \ + -e "s/LH_PACKAGES_LISTS/${LH_PACKAGES_LISTS}/" \ + -e "s/LH_PACKAGES/${LH_PACKAGES}/" \ + -e "s/LH_ARCHITECTURE/${LH_ARCHITECTURE}/" \ + -e "s/LH_BOOTSTRAP_FLAVOUR/${LH_BOOTSTRAP_FLAVOUR}/" \ + -e "s#LH_MIRROR_BOOTSTRAP_SECURITY#${LH_MIRROR_BOOTSTRAP_SECURITY}#" \ + -e "s#LH_MIRROR_BOOTSTRAP#${LH_MIRROR_BOOTSTRAP}#" \ + -e "s#LH_MIRROR_BINARY_SECURITY#${LH_MIRROR_BINARY_SECURITY}#" \ + -e "s#LH_MIRROR_BINARY#${LH_MIRROR_BINARY}#" \ + -e "s/LH_SECTIONS/${LH_SECTIONS}/" \ + -e "s/LH_CHROOT_FILESYSTEM/${LH_CHROOT_FILESYSTEM}/" \ + -e "s/LH_LINUX_FLAVOURS/${LH_LINUX_FLAVOURS}/" \ + -e "s/LH_SECURITY/${LH_SECURITY}/" \ + -e "s/LH_SYMLINKS/${LH_SYMLINKS}/" \ + -e "s/LH_SYSVINIT/${LH_SYSVINIT}/" \ + -e "s/LH_BINARY_INDICES/${LH_BINARY_INDICES}/" \ + -e "s/LH_BOOTAPPEND/${LH_BOOTAPPEND}/" \ + -e "s/LH_BOOTLOADER/${LH_BOOTLOADER}/" \ + -e "s/LH_DEBIAN_INSTALLER/${LH_DEBIAN_INSTALLER}/" \ + -e "s/LH_ENCRYPTION/${LH_ENCRYPTION}/" \ + -e "s/LH_HOSTNAME/${LH_HOSTNAME}/" \ + -e "s#LH_ISO_APPLICATION#${LH_ISO_APPLICATION}#" \ + -e "s#LH_ISO_PREPARER#${LH_ISO_PREPARER}#" \ + -e "s#LH_ISO_PUBLISHER#${LH_ISO_PUBLISHER}#" \ + -e "s#LH_ISO_VOLUME#${LH_ISO_VOLUME}#" \ + -e "s/LH_MEMTEST/${LH_MEMTEST}/" \ + -e "s#LH_NET_ROOT_PATH#${LH_NET_ROOT_PATH}#" \ + -e "s/LH_NET_ROOT_SERVER/${LH_NET_ROOT_SERVER}/" \ + -e "s#SERVER#${_SERVER}#g" \ + -e "s/LH_USERNAME/${LH_USERNAME}/" \ + -e "s/LH_SOURCE_IMAGES/${LH_SOURCE_IMAGES}/" \ + -e "s/LH_SOURCE/${LH_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-webhelper "${VERSION}" build file +# `date -R` + +_BUILD="${_BUILD}" +_EMAIL="${_EMAIL}" + +# Standard options +LH_BINARY_IMAGES="${LH_BINARY_IMAGES}" +LH_DISTRIBUTION="${LH_DISTRIBUTION}" +LH_PACKAGES_LISTS="${LH_PACKAGES_LISTS}" +LH_PACKAGES="${LH_PACKAGES}" + +# Advanced bootstrap options +LH_ARCHITECTURE="${LH_ARCHITECTURE}" +LH_MIRROR_BOOTSTRAP_SECURITY="${LH_MIRROR_BOOTSTRAP}" +LH_MIRROR_BOOTSTRAP="${LH_MIRROR_BOOTSTRAP}" +LH_MIRROR_BINARY_SECURITY="${LH_MIRROR_BINARY_SECURITY}" +LH_MIRROR_BINARY="${LH_MIRROR_BINARY}" +LH_SECTIONS="${LH_SECTIONS}" + +# Advanced chroot options +LH_CHROOT_FILESYSTEM="${LH_CHROOT_FILESYSTEM}" +LH_LINUX_FLAVOURS="${LH_LINUX_FLAVOURS}" +LH_SECURITY="${LH_SECURITY}" +LH_SYMLINKS="${LH_SYMLINKS}" +LH_SYSVINIT="${LH_SYSVINIT}" + +# Advanced binary options +LH_BINARY_INDICES="${LH_BINARY_INDICES}" +LH_BOOTAPPEND="${LH_BOOTAPPEND}" +LH_BOOTLOADER="${LH_BOOTLOADER}" +LH_DEBIAN_INSTALLER="${LH_DEBIAN_INSTALLER}" +LH_ENCRYPTION="${LH_ENCRYPTION}" +LH_HOSTNAME="${LH_HOSTNAME}" +LH_ISO_APPLICATION="${LH_ISO_APPLICATION}" +LH_ISO_PREPARER="${LH_ISO_PREPARER}" +LH_ISO_PUBLISHER="${LH_ISO_PUBLISHER}" +LH_ISO_VOLUME="${LH_ISO_VOLUME}" +LH_MEMTEST="${LH_MEMTEST}" +LH_NET_ROOT_PATH="${LH_NET_ROOT_PATH}" +LH_NET_ROOT_SERVER="${LH_NET_ROOT_SERVER}" +LH_USERNAME="${LH_USERNAME}" + +# Advanced source options +LH_SOURCE_IMAGES="${LH_SOURCE_IMAGES}" +LH_SOURCE="${LH_SOURCE}" + +# Unofficial options +_CUSTOM_BOOTSTRAP="${_CUSTOM_BOOTSTRAP}" +_CUSTOM_BINARY="${_CUSTOM_BINARY}" +EOF + + echo "$(date +%b\ %d\ %H:%M:%S) ${HOSTNAME} live-webhelper: add web build (${_BUILD})." >> /var/log/live + echo "$(date +%b\ %d\ %H:%M:%S) ${HOSTNAME} live-webhelper: options ${_BUILD} |email ${_EMAIL}|binary_images ${LH_BINARY_IMAGES}|distribution ${LH_DISTRIBUTION}|packages_lists ${LH_PACKAGES_LISTS}|packages ${LH_PACKAGES}|architecture ${LH_ARCHITECTURE}|mirror_bootstrap_security ${LH_MIRROR_BOOTSTRAP}|mirror_bootstrap ${LH_MIRROR_BOOTSTRAP}|mirror_binary_security ${LH_MIRROR_BINARY_SECURITY}|mirror_binary ${LH_MIRROR_BINARY}|sections ${LH_SECTIONS}|chroot_filesystem ${LH_CHROOT_FILESYSTEM}|linux_flavours ${LH_LINUX_FLAVOURS}|security ${LH_SECURITY}|symlinks ${LH_SYMLINKS}|sysvinit ${LH_SYSVINIT}|binary_indices ${LH_BINARY_INDICES}|bootappend ${LH_BOOTAPPEND}|bootloader ${LH_BOOTLOADER}|debian_installer ${LH_DEBIAN_INSTALLER}|encryption ${LH_ENCRYPTION}|hostname ${LH_HOSTNAME}|iso_application ${LH_ISO_APPLICATION}|iso_preparer ${LH_ISO_PREPARER}|iso_publisher ${LH_ISO_PUBLISHER}|iso_volume ${LH_ISO_VOLUME}|memtest ${LH_MEMTEST}|net_path ${LH_NET_ROOT_PATH}|net_server ${LH_NET_ROOT_SERVER}|username ${LH_USERNAME}|source_images ${LH_SOURCE_IMAGES}|source ${LH_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/common b/cgi/common new file mode 100644 index 0000000..1e4bcb2 --- /dev/null +++ b/cgi/common @@ -0,0 +1 @@ +VERSION="1.0~a20" diff --git a/cgi/cron b/cgi/cron new file mode 100755 index 0000000..fca2db0 --- /dev/null +++ b/cgi/cron @@ -0,0 +1,175 @@ +#!/bin/sh + +# live-webhelper - web interface to live-helper +# Copyright (C) 2007-2010 Daniel Baumann +# +# live-webhelper 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 +LH_BASE="${LH_BASE:-/usr/share/live-helper}" + +for _FUNCTION in "${LH_BASE}"/functions/*.sh +do + . "${_FUNCTION}" +done + +# Reading common +. /usr/share/live-webhelper/common + +# Reading defaults +if [ -r /etc/default/live-webhelper ] +then + . /etc/default/live-webhelper +else + echo "E: /etc/default/live-webhelper missing" + exit 1 +fi + +# Exit if disabled +if [ "${_WEBBUILD}" != "enabled" ] +then + exit 0 +fi + +# Checking lock file +if [ -f /var/lock/live-webhelper.lock ] +then + echo "E: live-webhelper already/still running." + exit 1 +fi + +# Creating lock trap +trap "test -f /var/lock/live-webhelper.lock && rm -f /var/lock/live-webhelper.lock; exit 0" 0 1 2 3 9 15 + +# Creating lock file +touch /var/lock/live-webhelper.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-webhelper: remove web build (`date -d yesterday +%Y%m%d.%H`*)." >> /var/log/live +fi + +# Ok from here spin through the live-webhelper 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 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-webhelper: 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}" + lh_config -c ${_FILE} >> "${_TEMPDIR}"/"${_BUILD}"/log 2>&1 + _ERRORCONFIG="${?}" + lh_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 + if [ "${_ERRORCONFIG}" -eq "0" ] && [ "${_ERRORBUILD}" -eq "0" ] + then + _STATUS="maybe-successful" + else + _STATUS="maybe-failed" + 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 + + # 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-webhelper: end web build (${_BUILD}: ${_STATUS})." >> /var/log/live + done +fi diff --git a/cgi/default b/cgi/default new file mode 100644 index 0000000..f2403bd --- /dev/null +++ b/cgi/default @@ -0,0 +1,18 @@ +# Defaults for /etc/cron.daily/live-webhelper + +_WEBBUILD="disabled" + +_MODE="debian-official" + +_DEBUG="disabled" + +_DESTDIR="/srv/debian-live/www/webhelper" +_TEMPLATES="/usr/share/live-webhelper/templates/${_MODE}" +_TEMPDIR="/srv/tmp/live-webhelper" + +LH_MIRROR_BOOTSTRAP="http://ftp.de.debian.org/debian/" +LH_MIRROR_BOOTSTRAP_SECURITY="http://ftp.de.debian.org/debian-security/" +LH_MIRROR_BINARY="http://ftp.debian.org/debian/" +LH_MIRROR_BINARY_SECURITY="http://security.debian.org/" + +_SERVER="http://live.debian.net/webhelper" diff --git a/docs/ChangeLog.live-webhelper b/docs/ChangeLog.live-webhelper new file mode 100644 index 0000000..b6e3df7 --- /dev/null +++ b/docs/ChangeLog.live-webhelper @@ -0,0 +1,182 @@ +commit 1f4cf146edbd72a2d61ac2e60324d392569c9f24 +Author: Daniel Baumann +Date: Wed Oct 14 13:35:25 2009 +0200 + + Updating vcs fields. + +commit d1ab019de29691407e3bde1af2ff5efe9a284380 +Author: Richard Nelson +Date: Wed May 27 09:42:55 2009 -0500 + + Update quoting on variables for safety. + +commit 601b25634d291706fc477342b712554a54c42016 +Author: Richard Nelson +Date: Sat Mar 14 22:19:41 2009 -0500 + + update copyright years + +commit fed4e5adfd49b339bec16b0338b73f9f90ca40ce +Author: Richard Nelson +Date: Sat Mar 14 21:47:27 2009 -0500 + + Set lenny as defualt build + +commit 083a14f46cc1298b33908991dea145cf4ec7415d +Author: Richard Nelson +Date: Sun Nov 30 16:41:15 2008 -0600 + + Bug fix on usb-hdd builds. + +commit 7742576d3a9b84807c6456007ad3bc0147ca3024 +Author: Richard Nelson +Date: Thu Nov 27 22:44:51 2008 -0600 + + Remove -x flag left on cron during debug operations. + +commit 6817dca69fd0c53578c1e14c9c5333d5be94419d +Author: Richard Nelson +Date: Thu Nov 27 22:42:58 2008 -0600 + + Update to start using more live-helper functions. + +commit 649fc3a0fac8eae1b8a239a9ba250e89f4b89dfd +Author: Richard Nelson +Date: Wed Nov 26 22:13:57 2008 -0600 + + Update Copyright (C) to 2007-2008 + +commit 5449c921111b2f300006cc41d7b6582270959a82 +Author: Daniel Baumann +Date: Fri Nov 7 18:08:01 2008 +0100 + + Replacing obsolete dh_clean -k with dh_prep. + +commit cd7a4a353ae652a45057da5726467e23401be52d +Author: Richard Nelson +Date: Tue Nov 4 18:40:06 2008 -0600 + + Bug fix on custom bootstrap and custom binary. + +commit fc227fc32f06ba8e5af8c9ebdcd147f98790b6ea +Author: Richard Nelson +Date: Thu Oct 2 17:24:37 2008 -0500 + + Bug fix in netboot server and path. + +commit 446a99439bfee38c89615e1e24bb4729b2223e9e +Author: Richard Nelson +Date: Mon Sep 8 21:39:37 2008 -0500 + + Include common functions from live-helper for code reuse. + +commit 359e51591318966e97128b00bff38c62d07c6827 +Author: Richard Nelson +Date: Mon Sep 8 21:35:52 2008 -0500 + + Added test for unmounting devpts-live. + +commit 3fdcc59654986d57f014b6c6721b2a3abde2f722 +Author: Richard Nelson +Date: Mon Sep 8 21:29:41 2008 -0500 + + Local variable prefix with _ on VAR i.e. _VAR + +commit 4bbf10e31754f290d3aa0e158a45d09316487544 +Author: Richard Nelson +Date: Mon Sep 8 16:12:22 2008 -0500 + + Local variable LH_ removal/cleanup. + +commit 472a6a0825656fbc16f4df6cb19bb16e1df8605f +Author: Richard Nelson +Date: Mon Sep 8 16:02:36 2008 -0500 + + Minor local variable confusion for LH_ prefix cleanup. + +commit df23442fca1c727dd43ca1ea464b277e3617cb0f +Author: Richard Nelson +Date: Mon Sep 8 15:59:08 2008 -0500 + + Upgrade variables to have the LH_ prefix for LH_* variable, to work with the current live-helper version. + +commit f00e0cb212e0c84268e099ca35ca386982e4d82b +Author: Daniel Baumann +Date: Sun Sep 7 21:57:51 2008 +0200 + + Removing currently unused Upstream-Depends field in control. + +commit 4c85494fa2907a54dd99eaf17816a4d403ddb5bc +Author: Daniel Baumann +Date: Sun Sep 7 21:57:41 2008 +0200 + + Updating vcs fields in control file. + +commit eaf87ebd9f828740430cc60d3e9f201d88c67c25 +Author: Daniel Baumann +Date: Thu Aug 28 23:40:35 2008 +0200 + + Setting project email address to the new debian-live@lists.debian.org. + +commit 6fbca8e14be271dc62988d5555bba9f453ddbaa7 +Author: Daniel Baumann +Date: Wed Apr 23 18:50:17 2008 +0200 + + Updating Richards email address. + +commit 25e1e7bc4f6a095aaf248a80aeaa3795f4a3e3a9 +Author: Daniel Baumann +Date: Tue Oct 30 11:04:42 2007 +0100 + + Correcting vcs fields. + +commit c49d9ff77bd5be73d5367fd567a9e39fccf78410 +Author: Daniel Baumann +Date: Wed Oct 3 09:11:29 2007 +0200 + + Fixing wrong homepage field. + +commit 8e01ba16a737d04a0367ecf1d4f3d7f80437fe97 +Author: Daniel Baumann +Date: Sun Sep 23 16:04:04 2007 +0200 + + Using new Homepage field now. + +commit 49ca83a4d57051b2b4b4b950178063c6df25e222 +Author: Daniel Baumann +Date: Sun Sep 23 16:04:04 2007 +0200 + + Adding Upstream-Depends field. + +commit 39a9d3e82c71451734f0d4ddb630b67c9d55541a +Author: Daniel Baumann +Date: Sun Sep 23 16:04:04 2007 +0200 + + Moving from svn to git. + +commit 7e823babbe815bdf520becbfd6f4ccec814aa7e2 +Author: Daniel Baumann +Date: Sun Sep 23 16:04:03 2007 +0200 + + Removing not uploaded versions. + +commit 46e8777246485a15fc6d5a202a361662f4e724b5 +Author: Daniel Baumann +Date: Sun Sep 23 16:03:52 2007 +0200 + + Adding live-webhelper trunk 20070911. + +2007-07-19 Daniel Baumann + + * Introducing build modes. + +2007-07-14 Daniel Baumann + + * scripts/cgi: + - Quick fix in EMAIL. + +2007-06-04 Daniel Baumann + + * templates/form.html: + - Set default source image to 'generic'. + * Starting live-webhelper. diff --git a/examples/cron/crontab b/examples/cron/crontab new file mode 100644 index 0000000..0cb78a3 --- /dev/null +++ b/examples/cron/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/templates/cgi/debian-official/build.html b/templates/cgi/debian-official/build.html new file mode 100644 index 0000000..f03df68 --- /dev/null +++ b/templates/cgi/debian-official/build.html @@ -0,0 +1,78 @@ +
+ +

Your build 'BUILD' was recorded and will processed soon. Depending on the options you have selected, the build takes about between 5 and 20 minutes. You will be notified by email when the attempt has completed.

+ +
+ +

Your build will be available at: SERVER/BUILD/.

+ +
+
+ +
+ +Options + +Standard options + + + + + + + +
Email: EMAIL
--binary-image: LH_BINARY_IMAGES
--distribution: LH_DISTRIBUTION
--packages-lists: LH_PACKAGES_LISTS
--packages: LH_PACKAGES
+ +Advanced bootstrap options + + + + + + + + + +
--architecture: LH_ARCHITECTURE
--bootstrap-flavour: LH_BOOTSTRAP_FLAVOUR
--mirror-bootstrap: LH_MIRROR_BOOTSTRAP
--mirror-bootstrap-security: LH_MIRROR_BOOTSTRAP_SECURITY
--mirror-binary: LH_MIRROR_BINARY
--mirror-binary-security: LH_MIRROR_BINARY_SECURITY
--sections: LH_SECTIONS
+ +Advanced chroot options + + + + + + + +
--chroot-fileystem: LH_CHROOT_FILESYSTEM
--linux-flavours: LH_LINUX_FLAVOURS
--security: LH_SECURITY
--symlinks: LH_SYMLINKS
--sysvinit: LH_SYSVINIT
+ +Advanced binary options + + + + + + + + + + + + + + + + +
--binary-indices: LH_BINARY_INDICES
--bootappend: LH_BOOTAPPEND
--bootloader: LH_BOOTLOADER
--debian-installer: LH_DEBIAN_INSTALLER
--encryption: LH_ENCRYPTION
--hostname: LH_HOSTNAME
--iso-application: LH_ISO_APPLICATION
--iso-preparer: LH_ISO_PREPARER
--iso-publisher: LH_ISO_PUBLISHER
--iso-volume: LH_ISO_VOLUME
--memtest: LH_MEMTEST
--net-path: LH_NET_ROOT_PATH
--net-server: LH_NET_ROOT_SERVER
--username: username
+ +Advanced source options + + + + +
--source: LH_SOURCE
--source-images: LH_SOURCE_IMAGES
+ +
+ +
+ +

Thank you for your submission.

diff --git a/templates/cgi/debian-official/footer.html b/templates/cgi/debian-official/footer.html new file mode 100644 index 0000000..880028b --- /dev/null +++ b/templates/cgi/debian-official/footer.html @@ -0,0 +1,7 @@ + + + + diff --git a/templates/cgi/debian-official/form.html b/templates/cgi/debian-official/form.html new file mode 100644 index 0000000..b523e99 --- /dev/null +++ b/templates/cgi/debian-official/form.html @@ -0,0 +1,338 @@ +
+ +

Submit your parameters (working email address is required) to generate your very own Debian Live system.

+ +
+
+ +
+ +
+ +Options + + + + + + +
+ + + Standard options (click to collapse) +
+
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
+ + + Advanced bootstrap options (click to expand) +
+
+ + + + + Advanced chroot options (click to expand) +
+
+ + + + + Advanced binary options (click to expand) +
+
+ + + + + Advanced source options (click to expand) +
+
+ + + +
+ +
+ + +  + + +
diff --git a/templates/cgi/debian-official/header.html b/templates/cgi/debian-official/header.html new file mode 100644 index 0000000..d52efa6 --- /dev/null +++ b/templates/cgi/debian-official/header.html @@ -0,0 +1,43 @@ + + + + Debian Live Webhelper + + + + + + + + + + + + + + +
+

This is webhelper of the Debian Live project.

+
diff --git a/templates/cgi/debian-official/mail.txt b/templates/cgi/debian-official/mail.txt new file mode 100644 index 0000000..f0e8222 --- /dev/null +++ b/templates/cgi/debian-official/mail.txt @@ -0,0 +1,16 @@ +Subject: Debian Live Webhelper - Build BUILD +From: Debian Live Webhelper +To: EMAIL + +Hi, + +This is webhelper of the Debian Live project . + +Your build BUILD was started DATE_START and ended DATE_END with status 'STATUS'. + +You can see the log file and download the images from . + +Note that builds are removed after 24 hours. + +Have fun, +The Debian Live Team diff --git a/templates/cgi/debian-unofficial/build.html b/templates/cgi/debian-unofficial/build.html new file mode 100644 index 0000000..19bc255 --- /dev/null +++ b/templates/cgi/debian-unofficial/build.html @@ -0,0 +1,85 @@ +
+ +

Your build 'BUILD' was recorded and will processed soon. Depending on the options you have selected, the build takes about between 5 and 20 minutes. You will be notified by email when the attempt has completed.

+ +
+ +

Your build will be available at: SERVER/BUILD/.

+ +
+
+ +
+ +Options + +Standard options + + + + + + + +
Email: EMAIL
--binary-image: LH_BINARY_IMAGES
--distribution: LH_DISTRIBUTION
--packages-lists: LH_PACKAGES_LISTS
--packages: LH_PACKAGES
+ +Advanced bootstrap options + + + + + + + + + +
--architecture: LH_ARCHITECTURE
--bootstrap-flavour: LH_BOOTSTRAP_FLAVOUR
--mirror-bootstrap: LH_MIRROR_BOOTSTRAP
--mirror-bootstrap-security: LH_MIRROR_BOOTSTRAP_SECURITY
--mirror-binary: LH_MIRROR_BINARY
--mirror-binary-security: LH_MIRROR_BINARY_SECURITY
--sections: LH_SECTIONS
+ +Advanced chroot options + + + + + + + +
--chroot-fileystem: LH_CHROOT_FILESYSTEM
--linux-flavours: LH_LINUX_FLAVOURS
--security: LH_SECURITY
--symlinks: LH_SYMLINKS
--sysvinit: LH_SYSVINIT
+ +Advanced binary options + + + + + + + + + + + + + + + + +
--binary-indices: LH_BINARY_INDICES
--bootappend: LH_BOOTAPPEND
--bootloader: LH_BOOTLOADER
--debian-installer: LH_DEBIAN_INSTALLER
--encryption: LH_ENCRYPTION
--hostname: LH_HOSTNAME
--iso-application: LH_ISO_APPLICATION
--iso-preparer: LH_ISO_PREPARER
--iso-publisher: LH_ISO_PUBLISHER
--iso-volume: LH_ISO_VOLUME
--memtest: LH_MEMTEST
--net-path: LH_NET_ROOT_PATH
--net-server: LH_NET_ROOT_SERVER
--username: username
+ +Advanced source options + + + + +
--source: LH_SOURCE
--source-images: LH_SOURCE_IMAGES
+ +Unofficial options + + + + +
custom.bootstrap: CUSTOM_BOOTSTRAP
custom.binary: CUSTOM_BINARY
+ +
+ +
+ +

Thank you for your submission.

diff --git a/templates/cgi/debian-unofficial/footer.html b/templates/cgi/debian-unofficial/footer.html new file mode 100644 index 0000000..880028b --- /dev/null +++ b/templates/cgi/debian-unofficial/footer.html @@ -0,0 +1,7 @@ + + + + diff --git a/templates/cgi/debian-unofficial/form.html b/templates/cgi/debian-unofficial/form.html new file mode 100644 index 0000000..ffd6db6 --- /dev/null +++ b/templates/cgi/debian-unofficial/form.html @@ -0,0 +1,359 @@ +
+ +

Submit your parameters (working email address is required) to generate your very own Debian Live system.

+ +
+
+ +
+ +
+ +Options + + + + + + +
+ + + Standard options (click to collapse) +
+
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
+ + + Advanced bootstrap options (click to expand) +
+
+ + + + + Advanced chroot options (click to expand) +
+
+ + + + + Advanced binary options (click to expand) +
+
+ + + + + Advanced source options (click to expand) +
+
+ + + + + Unofficial options (click to expand) +
+
+ + + +
+ +
+ + +  + + +
diff --git a/templates/cgi/debian-unofficial/header.html b/templates/cgi/debian-unofficial/header.html new file mode 100644 index 0000000..d52efa6 --- /dev/null +++ b/templates/cgi/debian-unofficial/header.html @@ -0,0 +1,43 @@ + + + + Debian Live Webhelper + + + + + + + + + + + + + + +
+

This is webhelper of the Debian Live project.

+
diff --git a/templates/cgi/debian-unofficial/mail.txt b/templates/cgi/debian-unofficial/mail.txt new file mode 100644 index 0000000..f0e8222 --- /dev/null +++ b/templates/cgi/debian-unofficial/mail.txt @@ -0,0 +1,16 @@ +Subject: Debian Live Webhelper - Build BUILD +From: Debian Live Webhelper +To: EMAIL + +Hi, + +This is webhelper of the Debian Live project . + +Your build BUILD was started DATE_START and ended DATE_END with status 'STATUS'. + +You can see the log file and download the images from . + +Note that builds are removed after 24 hours. + +Have fun, +The Debian Live Team -- cgit v1.0