Commit e4813ea8 authored by Richard Nelson's avatar Richard Nelson
Browse files

Initial commit to provide biuld status on l-b-cgi frontend.

parent 3e94a680
......@@ -2,6 +2,7 @@
install:
install -D -m 0755 live-build-cgi $(DESTDIR)/usr/lib/cgi-bin/live-build
install -D -m 0755 live-build-status-cgi $(DESTDIR)/usr/lib/cgi-bin/live-build-status
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
......@@ -13,6 +14,7 @@ install:
uninstall:
rm -f $(DESTDIR)/usr/lib/cgi-bin/live-build
rm -f $(DESTDIR)/usr/lib/cgi-bin/live-build-status
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
......
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2015 Daniel Baumann <mail@daniel-baumann.ch>
## Copyright (C) 2015 Richard Nelson <unixabg@gmail.com>
##
## 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
# Sending html header
cat "${_TEMPLATES}"/header.html
# CGI
if [ -z "${QUERY_STRING}" ]
then
# Sending html form
echo "<h2><div style='color: red;'>Error: No cgi build specified.</div></h2>"
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'
# Standard options
_CGI_BUILD=$(echo "${QUERY_STRING}" | grep -oE '(^|[?&])cgi_build=[0-9.]+' | cut -f 2 -d '=' | head -n1)
#echo ${_CGI_BUILD}
#echo ${QUERY_STRING}
# FIXME: filter invalid options
unset QUERY_STRING
if [ -z "${_CGI_BUILD}" ]
then
echo "<h2><div style='color: red;'>Error: No cgi build specified.</div></h2>"
sed -e "s/VERSION/${VERSION}/" "${_TEMPLATES}"/footer.html
_CGI_BUILD="BAD"
fi
# Getting number of builds pending.
_QUEUENUM=$(ls "${_TEMPDIR}"/*.build | wc -l)
# Find the build if exists and populate status html else respond no build.
#echo "${QUERY_STRING}"
if [ -f "${_TEMPDIR}"/"${_CGI_BUILD}".build ]
then
# If build file exists in the tempdir folder then the build is pending.
_STATUS="PENDING"
. "${_TEMPDIR}"/"${_CGI_BUILD}".build
elif [ -f "${_TEMPDIR}"/"${_CGI_BUILD}"/"${_CGI_BUILD}".build ]
then
# If build file exists the tempdir/build folder the build is running.
_STATUS="RUNNING"
. "${_TEMPDIR}"/"${_CGI_BUILD}"/"${_CGI_BUILD}".build
elif [ -f "${_DESTDIR}"/"${_CGI_BUILD}"/build ]
then
# If build file exists the tempdir/build folder the build is running.
_STATUS="COMPLETED"
. "${_DESTDIR}"/"${_CGI_BUILD}"/build
else
_STATUS="Bad or malformed"
fi
# Test whether to send out information
if [ "${_STATUS}" != "Bad or malformed" ]
then
# Send out the html
# Note: On each string remember to use a delimeter that is not in the string.
sed -e "s/BUILD/${_CGI_BUILD}/g" \
-e "s/EMAIL/${_EMAIL}/" \
-e "s/STATUS/${_STATUS}/" \
-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_APT_INDICES/${LB_APT_INDICES}/" \
-e "s/LB_APT/${LB_APT}/" \
-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_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}"/status.html
else
echo "Your request of ${_CGI_BUILD}, resulted in a malformed request or build number not found. All requests are logged."
fi
echo "$(date +%b\ %d\ %H:%M:%S) ${_HOSTNAME} live-build-status: ${_STATUS} build status requested for (${_CGI_BUILD}) from ${REMOTE_ADDR}." >> /var/log/live/live-build-status
fi
sed -e "s/VERSION/${VERSION}/" "${_TEMPLATES}"/footer.html
<br />
<h3>Your build 'BUILD' was recorded and will be processed soon. Depending on the options you have selected, a build attempt generally takes between 5 and 20 minutes to complete. Currently there are 'QUEUENUM' pending build(s) to be processed ahead of your request. You will be notified by email when the attempt has completed.</h3>
<h3>Your build 'BUILD' was recorded and will be processed soon. Depending on the options you have selected, a build attempt generally takes between 5 and 60 minutes to complete. Currently there are 'QUEUENUM' pending build(s) to be processed ahead of your request. You will be notified by email when the attempt has completed.</h3>
<h3>Your build will be available at: <a href="SERVER/BUILD/">SERVER/BUILD/</a>.</h3>
<h3>Your build build status is available at: <a href="SERVER/../cgi-bin/live-build-status?cgi_build=BUILD">SERVER/../cgi-bin/live-build-status?cgi_build=BUILD</a>.</h3>
<h3>Your build upon completion will be available at: <a href="SERVER/BUILD/">SERVER/BUILD/</a>.</h3>
<fieldset>
......
<br />
<h3>Build 'BUILD' shows a status of <b>STATUS</b>. Depending on the options you have selected, upon build showing a status of running it generally takes between 5 and 60 minutes to complete. Currently there are 'QUEUENUM' pending build(s) request waiting to be processed on the server. You will be notified by email when the attempt has completed.</h3>
<h3>Your build when completed will be available at: <a href="SERVER/BUILD/">SERVER/BUILD/</a>.</h3>
<fieldset>
<legend><b>Options</b></legend>
<b>Standard options</b>
<table>
<tr><td>Email: </td><td>EMAIL</td></tr>
<tr><td>--binary-image: </td><td>LB_BINARY_IMAGES</td></tr>
<tr><td>--distribution: </td><td>LB_DISTRIBUTION</td></tr>
<tr><td>--config: </td><td>_LB_CONFIG</td></tr>
<tr><td>--apt: </td><td>LB_APT</td></tr>
<tr><td>cgipackages.list.chroot: </td><td>_LB_CGIPACKAGES</td><tr>
</table>
<b>Advanced bootstrap options</b>
<table>
<tr><td>--architectures: </td><td>LB_ARCHITECTURES</td></tr>
<tr><td>--archive-areas: </td><td>LB_ARCHIVE_AREAS</td></tr>
</table>
<b>Advanced chroot options</b>
<table>
<tr><td>--chroot-fileystem: </td><td>LB_CHROOT_FILESYSTEM</td></tr>
<tr><td>--linux-flavours: </td><td>LB_LINUX_FLAVOURS</td></tr>
<tr><td>--security: </td><td>LB_SECURITY</td></tr>
</table>
<b>Advanced binary options</b>
<table>
<tr><td>--apt-indices: </td><td>LB_APT_INDICES</td></tr>
<tr><td>--bootappend-live: </td><td>LB_BOOTAPPEND_LIVE</td></tr>
<tr><td>--bootloader: </td><td>LB_BOOTLOADER</td></tr>
<tr><td>--debian-installer: </td><td>LB_DEBIAN_INSTALLER</td></tr>
<tr><td>--bootappend-install: </td><td>LB_BOOTAPPEND_INSTALL</td></tr>
<tr><td>--iso-application: </td><td>LB_ISO_APPLICATION</td></tr>
<tr><td>--iso-preparer: </td><td>LB_ISO_PREPARER</td></tr>
<tr><td>--iso-publisher: </td><td>LB_ISO_PUBLISHER</td></tr>
<tr><td>--iso-volume: </td><td>LB_ISO_VOLUME</td></tr>
<tr><td>--memtest: </td><td>LB_MEMTEST</td></tr>
<tr><td>--net-path: </td><td>LB_NET_ROOT_PATH</td></tr>
<tr><td>--net-server: </td><td>LB_NET_ROOT_SERVER</td></tr>
</table>
<b>Advanced source options</b>
<table>
<tr><td>--source: </td><td>LB_SOURCE</td></tr>
<tr><td>--source-images: </td><td>LB_SOURCE_IMAGES</td></tr>
</table>
</fieldset>
<br />
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment