test/curl.sh
author J. Ali Harlow <ali@juiblex.co.uk>
Thu Jul 07 15:18:02 2016 +0100 (2016-07-07)
changeset 480 18c1225cfa1b
permissions -rwxr-xr-x
Release 0.6.3.100
     1 #!/bin/bash
     2 if [ $# -gt 0 ]; then
     3     razor="$1"
     4 else
     5     razor=`pwd`/../src/razor
     6 fi
     7 check_file()
     8 {
     9     $razor list-files | grep -F -x "$1" > /dev/null
    10     if [ $? -ne 0 ]; then
    11 	echo $1: Not in database >&2
    12 	$razor list-files >&2
    13 	exit 1
    14     fi
    15     if [ ! -e "$tmproot$1" ]; then 
    16 	echo $1: Not in filesystem >&2
    17 	ls -R "$tmproot" >&2
    18 	exit 1
    19     fi
    20 }
    21 tmproot=`mktemp -dt` || exit 1
    22 export RAZOR_ROOT="file:$tmproot"
    23 scratchdir=`mktemp -dt` || exit 1
    24 (cd base && ../tftpd $scratchdir/tftpd.pid $scratchdir/tftpd.port) || exit 1
    25 cd $scratchdir
    26 port=`cat tftpd.port`
    27 pid=`cat tftpd.pid`
    28 export YUM_URL="tftp://localhost:$port/"
    29 if $razor init; then
    30     :
    31 else
    32     kill $pid
    33     exit 1
    34 fi
    35 if $razor import-yum; then
    36     :
    37 else
    38     kill $pid
    39     exit 1
    40 fi
    41 if $razor install zap; then
    42     :
    43 else
    44     kill $pid
    45     exit 1
    46 fi
    47 check_file /usr/bin/zap
    48 rm -rf "$scratchdir" "$tmproot"
    49 kill $pid
    50 exit 0