[Debian-live-changes] r1963 - dists/trunk/live-webhelper/scripts
rjent-guest at alioth.debian.org
rjent-guest at alioth.debian.org
Mon Jun 4 03:57:08 UTC 2007
Author: rjent-guest
Date: 2007-06-04 03:57:08 +0000 (Mon, 04 Jun 2007)
New Revision: 1963
Modified:
dists/trunk/live-webhelper/scripts/cgi
Log:
cgi sed cleanup, not perfect yet, but closer.
Modified: dists/trunk/live-webhelper/scripts/cgi
===================================================================
--- dists/trunk/live-webhelper/scripts/cgi 2007-06-03 21:34:02 UTC (rev 1962)
+++ dists/trunk/live-webhelper/scripts/cgi 2007-06-04 03:57:08 UTC (rev 1963)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash -x
# live-webhelper - web interface to live-helper
# Copyright (C) 2007 Richard Nelson <rjent at rjent.pair.com>
@@ -52,55 +52,62 @@
-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/%2F/\//g"
+ # 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'
- # Filtering url parameters
- EMAIL="`echo ${QUERY_STRING} | grep -oE '(^|[?&])email=[0-9,a-z,A-Z,.,%,-]+' | sed 's/%40/@/g' | cut -f 2 -d '=' | head -n1`"
+ # 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
- BINARY_IMAGES="`echo ${QUERY_STRING} | grep -oE '(^|[?&])binary_images=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- DISTRIBUTION="`echo ${QUERY_STRING} | grep -oE '(^|[?&])distribution=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- PACKAGES_LISTS="`echo ${QUERY_STRING} | grep -oE '(^|[?&])packages_lists=[a-z,-]+' | cut -f 2 -d '=' | head -n1`"
- PACKAGES="`echo ${QUERY_STRING} | grep -oE '(^|[?&])packages=[0-9,a-z,A-Z,.,_,+,-]+' | sed 's/+/ /g' | cut -f 2 -d '=' | head -n1`"
+ BINARY_IMAGES=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])binary_images=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ DISTRIBUTION=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])distribution=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ PACKAGES_LISTS=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])packages_lists=[a-z,-]+' | cut -f 2 -d '=' | head -n1)
+ PACKAGES=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])packages=[0-9,a-z,A-Z,., ,_,-]+' | cut -f 2 -d '=' | head -n1)
# Advanced bootstrap options
- ARCHITECTURE="`echo ${QUERY_STRING} | grep -oE '(^|[?&])architecture=[0-9,a-z]+' | cut -f 2 -d '=' | head -n1`"
- BOOTSTRAP_FLAVOUR="`echo ${QUERY_STRING} | grep -oE '(^|[?&])bootstrap_flavour=[a-z]+' | cut -f 2 -d '=' | head -n1`"
+ ARCHITECTURE=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])architecture=[0-9,a-z]+' | cut -f 2 -d '=' | head -n1)
+ BOOTSTRAP_FLAVOUR=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])bootstrap_flavour=[a-z]+' | cut -f 2 -d '=' | head -n1)
#MIRROR_BOOTSTRAP
#MIRROR_BOOTSTRAP_SECURITY
#MIRROR_BINARY
#MIRROR_BINARY_SECURITY
- SECTIONS="`echo ${QUERY_STRING} | grep -oE '(^|[?&])sections=[a-z]+' | sed 's/+/ /g' | cut -f 2 -d '=' | head -n1`"
+ SECTIONS=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])sections=[a-z]+' | cut -f 2 -d '=' | head -n1)
# Advanced chroot options
- CHROOT_FILESYSTEM="`echo ${QUERY_STRING} | grep -oE '(^|[?&])chroot_filesystem=[0-9,a-z]+' | cut -f 2 -d '=' | head -n1`"
- LINUX_FLAVOURS="`echo ${QUERY_STRING} | grep -oE '(^|[?&])linux_flavours=[0-9,a-z,-]+' | cut -f 2 -d '=' | head -n1`"
- SECURITY="`echo ${QUERY_STRING} | grep -oE '(^|[?&])security=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- SYMLINKS="`echo ${QUERY_STRING} | grep -oE '(^|[?&])symlinks=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- SYSVINIT="`echo ${QUERY_STRING} | grep -oE '(^|[?&])sysvinit=[a-z]+' | cut -f 2 -d '=' | head -n1`"
+ CHROOT_FILESYSTEM=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])chroot_filesystem=[0-9,a-z]+' | cut -f 2 -d '=' | head -n1)
+ LINUX_FLAVOURS=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])linux_flavours=[0-9,a-z,-]+' | cut -f 2 -d '=' | head -n1)
+ SECURITY=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])security=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ SYMLINKS=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])symlinks=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ SYSVINIT=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])sysvinit=[a-z]+' | cut -f 2 -d '=' | head -n1)
# Advanced binary options
- BINARY_INDICES="`echo ${QUERY_STRING} | grep -oE '(^|[?&])binary_indices=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- BOOTAPPEND="`echo ${QUERY_STRING} | grep -oE '(^|[?&])bootappend=[0-9,a-z,A-Z,.,_,+,-]+' | cut -f 2 -d '=' | head -n1`"
- BOOTLOADER="`echo ${QUERY_STRING} | grep -oE '(^|[?&])bootloader=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- DEBIAN_INSTALLER="`echo ${QUERY_STRING} | grep -oE '(^|[?&])debian_installer=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- ENCRYPTION="`echo ${QUERY_STRING} | grep -oE '(^|[?&])encryption=[0-9,a-z,A-Z]+' | cut -f 2 -d '=' | head -n1`"
- HOSTNAME="`echo ${QUERY_STRING} | grep -oE '(^|[?&])hostname=[0-9,a-z,A-Z,.,-]+' | cut -f 2 -d '=' | head -n1`"
- ISO_APPLICATION="`echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_application=[0-9,a-z,A-Z,.,_,+,-]+' | sed 's/+/ /g' | cut -f 2 -d '=' | head -n1`"
- ISO_PREPARER="`echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_preparer=[0-9,a-z,A-Z,.,_,+,-]+' | sed 's/+/ /g' | cut -f 2 -d '=' | head -n1`"
- ISO_PUBLISHER="`echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_publisher=[0-9,a-z,A-Z,.,_,+,-]+' | sed 's/+/ /g' | cut -f 2 -d '=' | head -n1`"
- ISO_VOLUME="`echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_volume=[0-9,a-z,A-Z,.,_,+,-]+' | sed 's/+/ /g' | cut -f 2 -d '=' | head -n1`"
- MEMTEST="`echo ${QUERY_STRING} | grep -oE '(^|[?&])memtest=[0-9,a-z,A-Z,.,_,+,-]+' | cut -f 2 -d '=' | head -n1`"
- NET_PATH="`echo ${QUERY_STRING} | grep -oE '(^|[?&])net_path=[0-9,a-z,A-Z,.,_,+,-]+' | cut -f 2 -d '=' | head -n1`"
- NET_SERVER="`echo ${QUERY_STRING} | grep -oE '(^|[?&])net_server=[0-9,a-z,A-Z,.,_,+,-]+' | cut -f 2 -d '=' | head -n1`"
- USERNAME="`echo ${QUERY_STRING} | grep -oE '(^|[?&])username=[0-9,a-z,A-Z,.,-]+' | cut -f 2 -d '=' | head -n1`"
+ BINARY_INDICES=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])binary_indices=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ BOOTAPPEND=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])bootappend=[0-9,a-z,A-Z,., ,_,+,-]+' | cut -f 2 -d '=' | head -n1)
+ BOOTLOADER=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])bootloader=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ DEBIAN_INSTALLER=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])debian_installer=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ ENCRYPTION=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])encryption=[0-9,a-z,A-Z]+' | cut -f 2 -d '=' | head -n1)
+ HOSTNAME=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])hostname=[0-9,a-z,A-Z,.,-]+' | cut -f 2 -d '=' | head -n1)
+ ISO_APPLICATION=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_application=[0-9,a-z,A-Z,., ,~,;,/,_,-]+' | cut -f 2 -d '=' | head -n1)
+ ISO_PREPARER=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_preparer=[0-9,a-z,A-Z,., ,~,;,/,_,-]+' | cut -f 2 -d '=' | head -n1)
+ ISO_PUBLISHER=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_publisher=[0-9,a-z,A-Z,., ,~,;,/,_,/,-]+' | cut -f 2 -d '=' | head -n1)
+ ISO_VOLUME=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])iso_volume=[0-9,a-z,A-Z,., ,~,;,/,_,-]+' | cut -f 2 -d '=' | head -n1)
+ MEMTEST=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])memtest=[0-9,a-z,A-Z,.,_,-]+' | cut -f 2 -d '=' | head -n1)
+ NET_PATH=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])net_path=[0-9,a-z,A-Z,.,_,/,-]+' | cut -f 2 -d '=' | head -n1)
+ NET_SERVER=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])net_server=[0-9,a-z,A-Z,.,_,-]+' | cut -f 2 -d '=' | head -n1)
+ USERNAME=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])username=[0-9,a-z,A-Z,.,-]+' | cut -f 2 -d '=' | head -n1)
# Advanced source options
- SOURCE="`echo ${QUERY_STRING} | grep -oE '(^|[?&])source=[a-z]+' | cut -f 2 -d '=' | head -n1`"
- SOURCE_IMAGES="`echo ${QUERY_STRING} | grep -oE '(^|[?&])source_images=[a-z]+' | cut -f 2 -d '=' | head -n1`"
+ SOURCE=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])source=[a-z]+' | cut -f 2 -d '=' | head -n1)
+ SOURCE_IMAGES=$(echo ${QUERY_STRING} | grep -oE '(^|[?&])source_images=[a-z]+' | cut -f 2 -d '=' | head -n1)
# FIXME: filter invalid options
unset QUERY_STRING
@@ -121,12 +128,11 @@
fi
# Getting build identifier
- BUILD="`date +%Y%m%d.%H%M%S.%N`"
+ BUILD=$(date +%Y%m%d.%H%M%S.%N)
# Sending html confirmation
sed -e "s/BUILD/${BUILD}/g" \
-e "s/EMAIL/${EMAIL}/" \
- -e "s#SERVER#${SERVER}#g" \
-e "s/BINARY_IMAGES/${BINARY_IMAGES}/" \
-e "s/DISTRIBUTION/${DISTRIBUTION}/" \
-e "s/PACKAGES_LISTS/${PACKAGES_LISTS}/" \
@@ -156,6 +162,7 @@
-e "s/MEMTEST/${MEMTEST}/" \
-e "s#NET_PATH#${NET_PATH}#" \
-e "s/NET_SERVER/${NET_SERVER}/" \
+ -e "s#SERVER#${SERVER}#g" \
-e "s/USERNAME/${USERNAME}/" \
-e "s/SOURCE_IMAGES/${SOURCE_IMAGES}/" \
-e "s/SOURCE/${SOURCE}/" \
@@ -214,8 +221,8 @@
SOURCE="${SOURCE}"
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 ${BINARY_IMAGES}|distribution ${DISTRIBUTION}|packages_lists ${PACKAGES_LISTS}|packages ${PACKAGES}|architecture ${ARCHITECTURE}|mirror_bootstrap_security ${MIRROR_BOOTSTRAP}|mirror_bootstrap ${MIRROR_BOOTSTRAP}|mirror_binary_security ${MIRROR_BINARY_SECURITY}|mirror_binary ${MIRROR_BINARY}|sections ${SECTIONS}|chroot_filesystem ${CHROOT_FILESYSTEM}|linux_flavours ${LINUX_FLAVOURS}|security ${SECURITY}|symlinks ${SYMLINKS}|sysvinit ${SYSVINIT}|binary_indices ${BINARY_INDICES}|bootappend ${BOOTAPPEND}|bootloader ${BOOTLOADER}|debian_installer ${DEBIAN_INSTALLER}|encryption ${ENCRYPTION}|hostname ${HOSTNAME}|iso_application ${ISO_APPLICATION}|iso_preparer ${ISO_PREPARER}|iso_publisher ${ISO_PUBLISHER}|iso_volume ${ISO_VOLUME}|memtest ${MEMTEST}|net_path ${NET_PATH}|net_server ${NET_SERVER}|username ${USERNAME}|source_images ${SOURCE_IMAGES}|source ${SOURCE}|" >> /var/log/live
+ 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 ${BINARY_IMAGES}|distribution ${DISTRIBUTION}|packages_lists ${PACKAGES_LISTS}|packages ${PACKAGES}|architecture ${ARCHITECTURE}|mirror_bootstrap_security ${MIRROR_BOOTSTRAP}|mirror_bootstrap ${MIRROR_BOOTSTRAP}|mirror_binary_security ${MIRROR_BINARY_SECURITY}|mirror_binary ${MIRROR_BINARY}|sections ${SECTIONS}|chroot_filesystem ${CHROOT_FILESYSTEM}|linux_flavours ${LINUX_FLAVOURS}|security ${SECURITY}|symlinks ${SYMLINKS}|sysvinit ${SYSVINIT}|binary_indices ${BINARY_INDICES}|bootappend ${BOOTAPPEND}|bootloader ${BOOTLOADER}|debian_installer ${DEBIAN_INSTALLER}|encryption ${ENCRYPTION}|hostname ${HOSTNAME}|iso_application ${ISO_APPLICATION}|iso_preparer ${ISO_PREPARER}|iso_publisher ${ISO_PUBLISHER}|iso_volume ${ISO_VOLUME}|memtest ${MEMTEST}|net_path ${NET_PATH}|net_server ${NET_SERVER}|username ${USERNAME}|source_images ${SOURCE_IMAGES}|source ${SOURCE}|" >> /var/log/live
fi
sed -e "s/VERSION/${VERSION}/" "${TEMPLATES}"/footer.html
More information about the Debian-live-changes
mailing list