Commits

M0E-lnx  committed be99f1b

Inprove deployment script

  • Participants
  • Parent commits f035f3b

Comments (0)

Files changed (1)

File deploy_slave.sh

 	fi
 }
 
-function make_chroots {
-git pull
-
-## Bring in the slavehost.conf to the local dir
-cp slave/etc/vlbuildslave/slavehost.conf .
-
-conf=$CWD/slavehost.conf
+# Currently VECTOR 7.0 and 7.1 32 and 64-bit
+VLVERSIONS="32c7p0 64c7p0 32c7p1 64c7p1"
 
-## Update the header lines in the config file
-slavesdef="SLAVES_ROOT=\"$SLAVES_HOME\""
-chrootsdef="JAILS=\"$CHROOTS_HOME\""
-sed -i "s|^SLAVES_ROOT=.*|$slavesdef|g" $conf
-sed -i "s|^JAILS=.*|$chrootsdef|g" $conf
 
-# Currently VECTOR 7.0 and 7.1 32 and 64-bit
-VLVERSIONS="32c7p1 64c7p1"
+function download_isos {
 
 ISO[32c7p0]="http://vectorlinux.osuosl.org/veclinux-7.0/iso-release/VL7.0-STD-GOLD.iso"
 ISO[64c7p0]="http://vectorlinux.osuosl.org/VL64-7.0/iso-release/VL64-7.0-STD-FINAL.iso"
 MD5[64c7p0]="c3b5a842759aac992f68fd8a25512e5b"
 MD5[64c7p1]="2474eee36c6bfb5af9daab09acf9492c"
 
-## create the slaves root and jails home
-mkdir -p $SLAVES_HOME
 mkdir -p $CHROOTS_HOME
-
-## Download the ISOS
 cd $CHROOTS_HOME
-## mkdir -p vectorlinux-7.{0,1} # ??
+for rel in $VLVERSIONS; do
+	link=$(echo ${ISO[$rel]})
+	let fieldn=$(echo $link|grep -o "/" | wc -l |sed s/\ //g)
+	let fieldn=$((fieldn+1))
+	isoname=$(echo $link|cut -f $fieldn -d "/")
+
+	if [ "x$link" != "x" ]; then
+		wget -c --no-check-certificate $link
+		echo ""
+		printf "Testing md5sum on $isoname ... "
+		isohash=$(md5sum $isoname | xargs |cut -f 1 -d ' ')
+		if [ "$isohash" != ${MD5[$rel]} ]; then
+			echo "MD5sum check failed on $isoname" >&2
+			printf "FAIL"
+		else
+			printf "PASS"
+		fi
+		echo ""
+	fi
+done
+}
+function make_chroots {
 
+## Bring in the slavehost.conf to the local dir
+cp slave/etc/vlbuildslave/slavehost.conf .
+
+conf=${conf:-"$CWD/slavehost.conf"}
+
+## Update the header lines in the config file
+slavesdef="SLAVES_ROOT=\"$SLAVES_HOME\""
+chrootsdef="JAILS=\"$CHROOTS_HOME\""
+sed -i "s|^SLAVES_ROOT=.*|$slavesdef|g" $conf
+sed -i "s|^JAILS=.*|$chrootsdef|g" $conf
+
+## create the slaves root and jails home
+mkdir -p $SLAVES_HOME
 
-echo " + Downloading ISO images"
+# make chroots:
 for rel in $VLVERSIONS; do
-    link=$(echo ${ISO[$rel]})
-    if [ "x$link" != "x" ]; then
-    echo "Downloading ${link}"
-    vldotrel=$(echo $rel | cut -f 2 -d c|sed 's/p/./'g)
-    isoarch=$(echo $rel | cut -f 1 -d c)
-    let fieldn=$(echo $link|grep -o "/" | wc -l | sed s/\ //g)
-    let fieldn=$(($fieldn+1))
-    isoname=$(echo $link|cut -f $fieldn -d "/")
-    jailname=$(basename $isoname .iso)
-    echo "iso name: $isoname"
-    echo "jail name: $jailname"
-   
-    ## Update the conf to match the path to the jail
-    chrootdef="CHROOTS[$rel]=\"\${JAILS}/$jailname\""
-
-    sed -i "s|CHROOTS\[${rel}\].*|$chrootdef|g" $conf
-    if [ "$isoarch" == "32" ]; then
-	chrootarch="i586"
-    elif [ "$isoarch" == "64" ]; then
-	chrootarch="x86_64"
-    else
-	echo "Unknown ISO architecture"
-	exit 1
-    fi
-    ## create the jail dir
-    mkdir -p $CHROOTS_HOME/$jailname
-    cd $CHROOTS_HOME/$jailname
-    wget -c --no-check-certificate $link
-    # Check the iso md5sum
-    isohash=$(md5sum $isoname | cut -f 1 -d " ")
-    if [ "$isohash" != "${MD5[$rel]}" ]; then
-	echo "md5sum check failed for downloaded $isoname"
-	exit 1
-    fi
-    if [ -d CHROOT-RO ]; then
-	    echo "Removing old $jailname CHROOT-RO"
-	    rm -rf CHROOT-RO
-    fi
-    ## make the chroot
-    $CWD/slave/sbin/mkchrootSB $isoname $chrootarch $vldotrel
-    
-    ## Customize the chroot
-    mkdir CHROOT-RO/home/slackbuilds
-    cp /etc/resolv.conf $CHROOTS_HOME/$jailname/CHROOT-RO/etc/resolv.conf
-    mv $CHROOTS_HOME/$jailname/CHROOT-RO/usr/bin/requiredbuilder $CHROOTS_HOME/$jailname/CHROOT-RO/usr/bin/requiredbuilder.real
-    cp $CWD/chroot/usr/bin/requiredbuilder $CHROOTS_HOME/$jailname/CHROOT-RO/usr/bin/
-    if [ "$chrootarch" == "i586" ]; then
-	# replace the uname binary
-	echo "Replacing uname binary on 32-bit chroot $jailname"
-	mv $CHROOTS_HOME/$jailname/CHROOT-RO/bin/uname $CHROOTS_HOME/$jailname/CHROOT-RO/bin/uname.bin
-	cp $CWD/chroot/x86/bin/uname $CHROOTS_HOME/$jailname/CHROOT-RO/bin/uname
-    fi
-
-    ## handle the slapt-getrc changes
-    cat $CWD/slapt-getrc.$rel > $CHROOTS_HOME/$jailname/CHROOT-RO/etc/slapt-get/slapt-getrc
-    fi
-    
+	vldotrel=$(echo $rel | cut -f 2 -d c|sed 's/p/./'g)
+	isoarch=$(echo $rel | cut -f 1 -d c)
+	link=$(echo ${ISO[$rel]})
+	let fieldn=$(echo $link|grep -o "/" | wc -l |sed s/\ //g)
+	let fieldn=$(($fieldn+1))
+	isoname=$(echo $link |cut -f $fieldn -d "/")
+	jailname=$(basename $isoname .iso)
+
+	# Update the .conf to match the path to the jail
+	chrootdef="CHROOTS[$rel]=\"\${JAILS}/$jailname\""
+	sed -i "s|CHROOTS\[${rel}\].*|$chrootdef|g" $conf
+	if [ "$isoarch" == "32" ]; then
+		chrootarch="i586"
+	elif [ "$isoarch" == "64" ]; then
+		chrootarch="x86_64"
+	fi
+	# Create the chroot jail
+	mkdir -p $CHROOTS_HOME/$jailname
+	cd $CHROOTS_HOME/$jailname
+	if [ -d CHROOT-RO ]; then
+		printf "Found old $jailname CHROOT-RO... Remove it re-create it? [y/N] "
+		read force
+		if [ "$force" = "y" ]; then
+			rm -rf CHROOT-RO
+		else
+			continue
+		fi
+	fi
+
+	$CWD/slave/sbin/mkchrootSB $CHROOTS_HOME/$isoname $chrootarch $vldotrel
+
+	#customize the chroot
+	mkdir CHROOT-RO/home/slackbuilds
+	# Use opendns on all slave chroots
+	echo "nameserver 208.67.222.222" > CHROOT-RO/etc/resolv.conf
+	mv CHROOT-RO/usr/bin/requiredbuilder CHROOT-RO/usr/bin/requiredbuilder.real
+	cp $CWD/chroot/usr/bin/requiredbuilder CHROOT-RO/usr/bin/requiredbuilder
+	chmod +x CHROOT-RO/usr/bin/requiredbuilder
+	if [ "$chrootarch" == "i586" ]; then
+		#replace uname binary
+		mv CHROOT-RO/bin/uname CHROOT-RO/bin/uname.bin
+		cp $CWD/chroot/x86/bin/uname CHROOT-RO/bin/uname
+		chmod +x CHROOT-RO/bin/uname
+	fi
+	cat $CWD/slapt-getrc.$rel > CHROOT-RO/etc/slapt-get/slapt-getrc
 done
+
 }
 
 function install_host_config {
 
 function setup_wizard {
     warn
+    download_isos
     make_chroots
     install_slave
     install_host_config
 function update_jails {
 	source /etc/vlbuildslave/slavehost.conf || exit 1
 	export CHROOTS_HOME=$JAILS
+	export conf=/etc/vlbuildslave/slavehost.conf
 	warn
 	echo ""
 	echo "Updating chroot jails in $CHROOTS_HOME"
+	download_isos
 	make_chroots
 	exit 0
 }
 	;;
 esac
 
-#setup_wizard
+