diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/chroot-installation.sh | 21 | ||||
-rwxr-xr-x | bin/chroot-run.sh | 24 | ||||
-rwxr-xr-x | bin/common-functions.sh | 61 | ||||
-rwxr-xr-x | bin/d-i_build.sh | 13 | ||||
-rwxr-xr-x | bin/d-i_check_jobs.sh | 11 | ||||
-rwxr-xr-x | bin/d-i_manual.sh | 13 | ||||
-rwxr-xr-x | bin/d-i_parse_logs.sh | 18 | ||||
-rwxr-xr-x | bin/g-i-installation.sh | 13 | ||||
-rwxr-xr-x | bin/housekeeping.sh | 10 | ||||
-rwxr-xr-x | bin/schroot-create.sh | 29 | ||||
-rwxr-xr-x | bin/webcheck_url.sh | 18 |
11 files changed, 100 insertions, 131 deletions
diff --git a/bin/chroot-installation.sh b/bin/chroot-installation.sh index 921a9315..ce161477 100755 --- a/bin/chroot-installation.sh +++ b/bin/chroot-installation.sh @@ -1,8 +1,11 @@ #!/bin/bash -# Copyright 2012,2013 Holger Levsen <holger@layer-acht.org> +# Copyright 2012-2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 +. /srv/jenkins/bin/common-functions.sh +common_init "$@" + # $1 = base distro # $2 = extra component # $3 = upgrade distro @@ -19,22 +22,6 @@ SLEEP=$(shuf -i 1-10 -n 1) echo "Sleeping $SLEEP seconds to randomize start times and parallel runs." sleep $SLEEP -# -# default settings -# -set -x -set -e -export LC_ALL=C -export MIRROR=http://ftp.de.debian.org/debian -export http_proxy="http://localhost:3128" - -export SCRIPT_HEADER="#!/bin/bash -set -x -set -e -export DEBIAN_FRONTEND=noninteractive -export LC_ALL=C -export http_proxy=$http_proxy" - export CHROOT_TARGET=$(mktemp -d -p /chroots/ chroot-installation-$1.XXXXXXXXX) export TMPFILE=$(mktemp -u) export CTMPFILE=$CHROOT_TARGET/$TMPFILE diff --git a/bin/chroot-run.sh b/bin/chroot-run.sh index 4d3555bb..05df628b 100755 --- a/bin/chroot-run.sh +++ b/bin/chroot-run.sh @@ -4,23 +4,12 @@ # Copyright 2013 Antonio Terceiro <terceiro@debian.org> # released under the GPLv=2 +. /srv/jenkins/bin/common-functions.sh +common_init "$@" + # $1 = base distro # $2 $3 ... = command to run inside a clean chroot running the distro in $1 -set -e -export LC_ALL=C - -# Defaults for the jenkins.debian.net environment -if [ -z "$MIRROR" ]; then - export MIRROR=http://ftp.de.debian.org/debian -fi -if [ -z "$http_proxy" ]; then - export http_proxy="http://localhost:3128" -fi -if [ -z "$CHROOT_BASE" ]; then - export CHROOT_BASE=/chroots -fi - if [ $# -lt 2 ]; then echo "usage: $0 DISTRO [backports] CMD [ARG1 ARG2 ...]" exit 1 @@ -48,13 +37,6 @@ fi export CURDIR=$(pwd) -export SCRIPT_HEADER="#!/bin/bash -set -x -set -e -export DEBIAN_FRONTEND=noninteractive -export LC_ALL=C -export http_proxy=$http_proxy" - bootstrap() { mkdir -p "$CHROOT_TARGET/etc/dpkg/dpkg.cfg.d" echo force-unsafe-io > "$CHROOT_TARGET/etc/dpkg/dpkg.cfg.d/02dpkg-unsafe-io" diff --git a/bin/common-functions.sh b/bin/common-functions.sh new file mode 100755 index 00000000..327cdff7 --- /dev/null +++ b/bin/common-functions.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Copyright 2014 Holger Levsen <holger@layer-acht.org> +# released under the GPLv=2 + +common_cleanup(){ + echo "Cleaned up $TTT, finished running $0" + rm -f $TTT +} + +common_init() { +# check whether this script has been started from /tmp already +if [ "${0:0:5}" != "/tmp/" ] ; then + # mktemp some place for us... + TTT=$(mktemp --tmpdir=/tmp) + # prepare cleanup + trap common_cleanup INT TERM EXIT + # cp $0 to /tmp and run it from there + cp $0 $TTT + chmod +x $TTT + # run ourself with the same parameter as we are running + # but run a copy from /tmp so that the source can be updated + # (Running shell scripts fail weirdly when overwritten when running, + # this hack makes it possible to overwrite long running scripts + # anytime...) + echo "Start running \"$0\" as \"$TTT\" with arguments \"$@\"" + $TTT "$@" + exit 0 # auto cleanup on trap +else + # default settings used for the jenkins.debian.net environment + if [ -z "$LC_ALL" ]; then + export LC_ALL=C + fi + if [ -z "$MIRROR" ]; then + export MIRROR=http://ftp.de.debian.org/debian + fi + if [ -z "$http_proxy" ]; then + export http_proxy="http://localhost:3128" + fi + if [ -z "$CHROOT_BASE" ]; then + export CHROOT_BASE=/chroots + fi + if [ -z "$SCHROOT_BASE" ]; then + export SCHROOT_BASE=/schroots + fi + # use these settings in the scripts in the (s)chroots too + export SCRIPT_HEADER="#!/bin/bash + set -e + set -x + export DEBIAN_FRONTEND=noninteractive + export LC_ALL=$LC_ALL + export http_proxy=$http_proxy + export MIRROR=$MIRROR" + # be more verbose + export + set -e + set -x + +fi +} + diff --git a/bin/d-i_build.sh b/bin/d-i_build.sh index 0b43edca..8685f8f5 100755 --- a/bin/d-i_build.sh +++ b/bin/d-i_build.sh @@ -1,17 +1,10 @@ #!/bin/bash -# Copyright 2012-2013 Holger Levsen <holger@layer-acht.org> +# Copyright 2012-2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 -# -# default settings -# -set -x -set -e -export LC_ALL=C -export MIRROR=http://ftp.de.debian.org/debian -export http_proxy="http://localhost:3128" -export +. /srv/jenkins/bin/common-functions.sh +common_init "$@" init_workspace() { # diff --git a/bin/d-i_check_jobs.sh b/bin/d-i_check_jobs.sh index 524943b5..dad4f95b 100755 --- a/bin/d-i_check_jobs.sh +++ b/bin/d-i_check_jobs.sh @@ -1,15 +1,10 @@ #!/bin/bash -# Copyright 2012 Holger Levsen <holger@layer-acht.org> +# Copyright 2012,2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 -# -# default settings -# -#set -x -set -e -export LC_ALL=C -export http_proxy="http://localhost:3128" +. /srv/jenkins/bin/common-functions.sh +common_init "$@" # # define some variables diff --git a/bin/d-i_manual.sh b/bin/d-i_manual.sh index 7a0eaf0b..47680f85 100755 --- a/bin/d-i_manual.sh +++ b/bin/d-i_manual.sh @@ -1,17 +1,10 @@ #!/bin/bash -# Copyright 2012 Holger Levsen <holger@layer-acht.org> +# Copyright 2012,2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 -# -# default settings -# -set -x -set -e -export LC_ALL=C -export MIRROR=http://ftp.de.debian.org/debian -export http_proxy="http://localhost:3128" -export +. /srv/jenkins/bin/common-functions.sh +common_init "$@" init_workspace() { # diff --git a/bin/d-i_parse_logs.sh b/bin/d-i_parse_logs.sh index 2fae7370..a3eaa3de 100755 --- a/bin/d-i_parse_logs.sh +++ b/bin/d-i_parse_logs.sh @@ -1,27 +1,19 @@ #!/bin/bash -# Copyright 2012, 2013 Holger Levsen <holger@layer-acht.org> +# Copyright 2012-2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 +. /srv/jenkins/bin/common-functions.sh +common_init "$@" + +# convert param to variables if [ "$1" == "" ] ; then echo "need at least one URL to act on" echo '# $1 = URL' exit 1 fi - -# -# convert params to variables -# URL=$1 -# -# default settings -# -#set -x -set -e -export LC_ALL=C -export http_proxy="http://localhost:3128" - TMPFILE=$(mktemp) curl $URL > $TMPFILE if [ $(grep -c failed $TMPFILE 2>/dev/null ) -gt 1 ] ; then diff --git a/bin/g-i-installation.sh b/bin/g-i-installation.sh index 7cbded62..817e0c31 100755 --- a/bin/g-i-installation.sh +++ b/bin/g-i-installation.sh @@ -3,6 +3,9 @@ # Copyright 2012-2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 +. /srv/jenkins/bin/common-functions.sh +common_init "$@" + # $1 = vnc-display, each job should have a unique one, so jobs can run in parallel # $2 = name # $3 = disksize in GB @@ -20,16 +23,6 @@ if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ] || [ "$4" = "" ] ; then fi # -# default settings -# -set -x -set -e -export LC_ALL=C -export MIRROR=http://ftp.de.debian.org/debian -export http_proxy="http://localhost:3128" -export - -# # init # DISPLAY=localhost:$1 diff --git a/bin/housekeeping.sh b/bin/housekeeping.sh index 3d93a717..f322fec7 100755 --- a/bin/housekeeping.sh +++ b/bin/housekeeping.sh @@ -1,13 +1,10 @@ #!/bin/bash -# Copyright 2012-2013 Holger Levsen <holger@layer-acht.org> +# Copyright 2012-2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 -# -# default settings -# -export LC_ALL=C -set -e +. /srv/jenkins/bin/common-functions.sh +common_init "$@" check_for_mounted_chroots() { CHROOT_PATTERN="/chroots/${1}-*" @@ -47,7 +44,6 @@ report_filetype_usage() { rm $OUTPUT } - report_squid_usage() { REPORT=/var/www/calamaris/calamaris.txt if [ -z $1 ] ; then diff --git a/bin/schroot-create.sh b/bin/schroot-create.sh index 76a7f389..d39502e9 100755 --- a/bin/schroot-create.sh +++ b/bin/schroot-create.sh @@ -2,37 +2,22 @@ # Copyright 2012-2014 Holger Levsen <holger@layer-acht.org> # Copyright 2013 Antonio Terceiro <terceiro@debian.org> +# Copyright 2014 Joachim Breitner <nomeata@debian.org> # released under the GPLv=2 -# $2 = schroot name -# $1 = base distro -# $2 $3 ... = extra packages to install +. /srv/jenkins/bin/common-functions.sh +common_init "$@" # bootstraps a new chroot for schroot, and then moves it into the right location -set -e -export LC_ALL=C - -# Defaults for the jenkins.debian.net environment -if [ -z "$MIRROR" ]; then - export MIRROR=http://ftp.de.debian.org/debian -fi -if [ -z "$http_proxy" ]; then - # export http_proxy="http://localhost:3128" - : -fi -if [ -z "$CHROOT_BASE" ]; then - export CHROOT_BASE=/chroots -fi -if [ -z "$SCHROOT_BASE" ]; then - export SCHROOT_BASE=/schroots -fi +# $1 = schroot name +# $2 = base distro +# $3 $4 ... = extra packages to install if [ $# -lt 2 ]; then - echo "usage: $0 DISTRO [backports] CMD [ARG1 ARG2 ...]" + echo "usage: $0 TARGET DISTRO [backports] CMD [ARG1 ARG2 ...]" exit 1 fi - TARGET="$1" shift DISTRO="$1" diff --git a/bin/webcheck_url.sh b/bin/webcheck_url.sh index bd500658..582d4aa6 100755 --- a/bin/webcheck_url.sh +++ b/bin/webcheck_url.sh @@ -1,29 +1,21 @@ #!/bin/bash -# Copyright 2012 Holger Levsen <holger@layer-acht.org> +# Copyright 2012,2014 Holger Levsen <holger@layer-acht.org> # released under the GPLv=2 +. /srv/jenkins/bin/common-functions.sh +common_init "$@" + +# convert params to variables if [ "$1" == "" ] ; then echo "need at least one URL to act on" echo '# $1 = URL' exit 1 fi - -# -# convert params to variables -# URL=$1 PATTERNS=$2 # -# default settings -# -#set -x -set -e -export LC_ALL=C -export http_proxy="http://localhost:3128" - -# # Don't use --continue on first run # if [ ! -e webcheck.dat ] ; then |