#!/bin/sh # # $Id: mirror-slackware-current.sh,v 1.6 2005/09/11 09:49:07 root Exp root $ # # Mirror Slackware-current to our local machine # # ========================================================================== # # - Check at our master rsync site if the ChangeLog.txt has been altered # - If no changes, then no further actions are needed (abort script) # - If ChangeLog.txt has changed since our last mirror, do the following: # - Mirror the slackware-current tree # - Create a set of 2 ISO's (bootable INSTALL plus kde/extra/testing) # or a single bootable DVD from the current tree, # (guidelines are in the ./isolinux/README.TXT) # # # Good mirrors are: # # rsync://rsync.scarlet.be::slackware/slackware-current/ # rsync://rsync.slackware.at::slackware/slackware-current/ # rsync://slackware.mirrors.tds.net::slackware/slackware-current/ # rsync://mirrors.tuxq.com::slackware/slackware-current/ # rsync://mirror.vbfx.com::slackware/slackware-current/ # # Author: Eric Hameleers # # ========================================================================== # DATE=`date +"%d_%b_%Y"` # Make DVD="yes" if you want a single DVD instead of two CD ISO's DVD="no" # Your name/email: BUILDER="Me " # We prevent the mirror from running more than one instance: PIDFILE=/var/tmp/`basename $0 .sh`.pid # Make sure the PID file is removed when we kill the process trap 'rm $PIDFILE; return 1' TERM INT if [ "$1" == "-v" ]; then echo "Enabling verbose output...." DEBUG=1 VERBOSE="-v" VERBOSE2="-nv" elif [ "$1" == "-q" ]; then # No output at all if we are already in sync DEBUG=0 VERBOSE="-q" VERBOSE2="-q" else # Somwhat moderate output in all cases DEBUG=1 VERBOSE="-q" VERBOSE2="-q" fi SLACKROOTDIR="~/slackware" SLACKCURRENT="slackware-current" #RSYNCURL="rsync.scarlet.be::slackware/${SLACKCURRENT}" #RSYNCURL="rsync.slackware.at::slackware/${SLACKCURRENT}" #RSYNCURL="rsync.osuosl.org::slackware/${SLACKCURRENT}" #RSYNCURL="slackware.mirrors.tds.net::slackware/${SLACKCURRENT}" #RSYNCURL="mirrors.tuxq.com::slackware/${SLACKCURRENT}" RSYNCURL="mirror.vbfx.com::slackware/${SLACKCURRENT}" if [ ! -d ${SLACKROOTDIR}/${SLACKCURRENT} ]; then echo "`date` [$$]: Cannot find ${SLACKCURRENT} directory (${SLACKROOTDIR}/${SLACKCURRENT})! Aborting..." exit 1 fi if [ ! -d ${SLACKROOTDIR}/${SLACKCURRENT}-iso ]; then echo "`date` [$$]: Cannot find iso directory (${SLACKROOTDIR}/${SLACKCURRENT}-iso)! Aborting..." exit 1 fi if [ -e $PIDFILE ]; then echo "Another instance (`cat $PIDFILE`) still running? Aborting..." exit 1 else echo $$ > $PIDFILE # First get the ChangeLog.txt (no further action needed, # when there are no changes in this file) if [ $DEBUG == 1 ]; then echo "`date` [$$]: Getting ChangeLog.txt..." fi cd /tmp rm -f SlackCurrent_ChangeLog.txt rsync -az ${VERBOSE} ${RSYNCURL}/ChangeLog.txt SlackCurrent_ChangeLog.txt if [ ! -s /tmp/SlackCurrent_ChangeLog.txt ]; then echo "`date` [$$]: Could not retrieve ChangeLog.txt! Aborting..." rm $PIDFILE exit 1 fi # If the ChangeLog.txt on our local mirror does not exist, it might mean that # this is a first-time mirror. To prevent the script from aborting, we # create an empty ChangeLog.txt file... if [ ! -e ${SLACKROOTDIR}/${SLACKCURRENT}/ChangeLog.txt ]; then touch ${SLACKROOTDIR}/${SLACKCURRENT}/ChangeLog.txt fi diff -b ${SLACKROOTDIR}/${SLACKCURRENT}/ChangeLog.txt /tmp/SlackCurrent_ChangeLog.txt STATUS="$?" if [ "$STATUS" == "2" ]; then echo "`date` [$$]: Trouble when running diff, aborting..." rm -f /tmp/SlackCurrent_ChangeLog.txt rm $PIDFILE exit 1 elif [ "$STATUS" == 0 ]; then if [ $DEBUG == 1 ]; then echo "`date` [$$]: No difference found, the end..." fi rm -f /tmp/SlackCurrent_ChangeLog.txt rm $PIDFILE exit 0 else echo "`date` [$$]: ChangeLog.txt has been updated, starting mirror of ${SLACKCURRENT}." echo " --- Using ${RSYNCURL}" rm -f /tmp/SlackCurrent_ChangeLog.txt fi cd ${SLACKROOTDIR}/${SLACKCURRENT} umask 022 # USe '-rlptD' instead of '-a' so that we don't preserve file ownership - # so that we can switch mirrors and still all files will be owned root:root. /usr/bin/rsync --delete -z -rlptD $VERBOSE \ --exclude "pasture/*" \ ${RSYNCURL}/ . # Actually, run rsync again, since it happens that we hit the master server # while it is still sync-ing itself. /usr/bin/rsync --delete -z -rlptD $VERBOSE \ --exclude "pasture/*" \ ${RSYNCURL}/ . echo "`date` [$$]: Done mirroring ${SLACKCURRENT} (exit code $?)." # # Now create a bootable ISO install images # (log the used command line for reference purposes) # if [ $DVD == "no" ]; then cat <<_EOT_ > ${SLACKROOTDIR}/${SLACKCURRENT}-iso/readme.mkisofs # # Slackware installation uses 2 CD's. # In 'menu' or 'expert' mode, packages from CD2 can be selected. # In 'full install' mode, additional CD's will be asked for. # # CD1: bootable INSTALL CD # CD2: k, kde, kernels, extra, testing # # Command used to create the ISO's for CD1 and CD2: # (see also /isolinux/README.TXT on the CDROM you'll burn from the ISO) # CD1 mkisofs -o ${SLACKCURRENT}-install1.iso \\ -R -J -V "Slackware Install" \\ -x ./bootdisks \\ -x ./extra \\ -x ./slackware/k \\ -x ./slackware/kde \\ -x ./slackware/kdei \\ -x ./pasture \\ -x ./patches \\ -x ./rootdisks \\ -x ./source \\ -x ./testing \\ -x ./zipslack \\ -hide-rr-moved \\ -v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table \\ -sort isolinux/iso.sort \\ -b isolinux/isolinux.bin \\ -c isolinux/isolinux.boot \\ -p "Slackware-current build by ${BUILDER}" \\ -P "Slackware-current build by ${BUILDER}" \\ -A "Slackware-current Install CD1 - build $DATE" . #CD2 mkisofs -o ${SLACKCURRENT}-install2.iso \\ -R -J -V "Slackware Install2" \\ -hide-rr-moved \\ -v -d -N \\ -p "Slackware-current build by ${BUILDER}" \\ -P "Slackware-current build by ${BUILDER}" \\ -A "Slackware-current Install CD2 - build $DATE" \\ -x ./extra/source \\ -x ./testing/source \\ -graft-points \\ -sort isolinux/iso.sort \\ /kernels/=./kernels \\ /slackware/k/=./slackware/k \\ /slackware/kde/=./slackware/kde \\ /slackware/kdei/=./slackware/kdei \\ /extra/=./extra \\ /testing/=./testing _EOT_ echo "`date` [$$]: Creating ISO images for ${SLACKCURRENT}..." mkisofs -o ${SLACKROOTDIR}/${SLACKCURRENT}-iso/.building-slackware-install1.iso \ -R -J -V "Slackware Install" \ -x ./bootdisks \ -x ./extra \ -x ./slackware/k \ -x ./slackware/kde \ -x ./slackware/kdei \ -x ./pasture \ -x ./patches \ -x ./rootdisks \ -x ./source \ -x ./testing \ -x ./zipslack \ -hide-rr-moved \ -v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table \ -sort isolinux/iso.sort \ -b isolinux/isolinux.bin \ -c isolinux/isolinux.boot \ -p "Slackware-current build by ${BUILDER}" \ -P "Slackware-current build by ${BUILDER}" \ -A "Slackware-current Install CD1 - build $DATE" . \ > ${SLACKROOTDIR}/${SLACKCURRENT}-iso/mkisofs1.log 2>&1 MKISOERR=$? echo "`date` [$$]: First ISO created (exit code ${MKISOERR}) - one to go ..." # Wait as long as possible deleting the previous ISO rm -f ${SLACKROOTDIR}/${SLACKCURRENT}-iso/${SLACKCURRENT}-install1.iso ### If you want, keep a copy of the previous ISO... #rm -f previous*install1.iso #touch LATEST_ADDITION_TO_CURRENT #mv ${SLACKCURRENT}-install1.iso \ # previous-`cat LATEST_ADDITION_TO_CURRENT`-install1.iso ### # Make the new ISO "visible" mv ${SLACKROOTDIR}/${SLACKCURRENT}-iso/.building-slackware-install1.iso \ ${SLACKROOTDIR}/${SLACKCURRENT}-iso/${SLACKCURRENT}-install1.iso # # Now the second CD (10.0 and later supports multiple install CD's # in menu or expert mode) # mkisofs -o ${SLACKROOTDIR}/${SLACKCURRENT}-iso/.building-slackware-install2.iso \ -R -J -V "Slackware Install2" \ -hide-rr-moved \ -v -d -N \ -p "Slackware-current build by ${BUILDER}" \ -P "Slackware-current build by ${BUILDER}" \ -A "Slackware-current Install CD2 - build $DATE" \ -x ./extra/source \ -x ./testing/source \ -graft-points \ /kernels/=./kernels \ /slackware/k/=./slackware/k \ /slackware/kde/=./slackware/kde \ /extra/=./extra \ /testing/=./testing \ > ${SLACKROOTDIR}/${SLACKCURRENT}-iso/mkisofs2.log 2>&1 MKISOERR=$(($MKISOERR + $?)) # Wait as long as possible deleting the previous ISO rm -f ${SLACKROOTDIR}/${SLACKCURRENT}-iso/${SLACKCURRENT}-install2.iso ### If you want, keep a copy of the previous ISO... #rm -f previous*install2.iso #touch LATEST_ADDITION_TO_CURRENT #mv ${SLACKCURRENT}-install2.iso \ # previous-`cat LATEST_ADDITION_TO_CURRENT`-install2.iso ### # Make the new ISO visible mv ${SLACKROOTDIR}/${SLACKCURRENT}-iso/.building-slackware-install2.iso \ ${SLACKROOTDIR}/${SLACKCURRENT}-iso/${SLACKCURRENT}-install2.iso echo "`date` [$$]: ISO's created of ${SLACKCURRENT}." echo "`date` [$$]: The combined exit code for ISO creation is '${MKISOERR}'. A a non-zero number means: something goofed." ## end of [ $DVD == "no" ] else ## [ $DVD == "yes" ] cat <<_EOT_ > ${SLACKROOTDIR}/${SLACKCURRENT}-iso/readme.mkisofs # # Slackware installation as DVD. # # Contains: bootable INSTALL DVD (including /extra and /testing) # # Command used to create the ISO's for this DVD: # (see also /isolinux/README.TXT on the DVD you'll burn from the ISO) # DVD mkisofs -o ${SLACKCURRENT}-install-dvd.iso \\ -R -J -V "Slackware-current DVD" \\ -hide-rr-moved \\ -v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table \\ -sort isolinux/iso.sort \\ -b isolinux/isolinux.bin \\ -c isolinux/isolinux.boot \\ -p "Slackware-current build by ${BUILDER}" \\ -P "Slackware-current build by ${BUILDER}" \\ -A "Slackware-current DVD - build $DATE" . _EOT_ echo "`date` [$$]: Creating ISO image for ${SLACKCURRENT}..." mkisofs -o ${SLACKROOTDIR}/${SLACKCURRENT}-iso/.building-slackware-install-dvd.iso \ -R -J -V "Slackware-current DVD" \ -hide-rr-moved \ -v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table \ -sort isolinux/iso.sort \ -b isolinux/isolinux.bin \ -c isolinux/isolinux.boot \ -p "Slackware-current build by ${BUILDER}" \ -P "Slackware-current build by ${BUILDER}" \ -A "Slackware-current DVD - build $DATE" . \ > ${SLACKROOTDIR}/${SLACKCURRENT}-iso/mkisofs-dvd.log 2>&1 MKISOERR=$? echo "`date` [$$]: DVD ISO created (exit code ${MKISOERR}) ..." # Wait as long as possible deleting the previous ISO rm -f ${SLACKROOTDIR}/${SLACKCURRENT}-iso/${SLACKCURRENT}-install-dvd.iso # Make the new ISO "visible" mv ${SLACKROOTDIR}/${SLACKCURRENT}-iso/.building-slackware-install-dvd.iso \ ${SLACKROOTDIR}/${SLACKCURRENT}-iso/${SLACKCURRENT}-install-dvd.iso fi ## end of [ $DVD == "yes" ] # Compute MD5 checksums for the downloaders echo "`date` [$$]: Computing MD5 checksums of the ISO's (time consuming)." cd ${SLACKROOTDIR}/${SLACKCURRENT}-iso md5sum *install*.iso > MD5SUM LATEST_ADD=`date --date="\`head -n 40 ${SLACKROOTDIR}/${SLACKCURRENT}/ChangeLog.txt|grep -Ei "(mon|tue|wed|thu|fri|sat|sun)"|head -n 1\`" +%Y%b%d-%Hh%M-%Z` echo ${LATEST_ADD} > LATEST_ADDITION_TO_CURRENT echo "`date` [$$]: Resulting ISO files:" ls -l ${SLACKROOTDIR}/${SLACKCURRENT}-iso/*install*.iso echo "`date` [$$]: Done!" rm $PIDFILE fi