File get_sources.sh of Package moodle

#!/bin/bash
#
# get_sources.sh - update the *.zip files


FORCE="no"
SHOW="no"
MOODLE="no"

function usage (){
    echo
    echo "Usage: $0 [options]"
    echo "       -f : force update"
    echo "       -m : try to update the moodle package"
    echo "       -s : show only current sources in specfile"
    echo
    exit 0
}

while getopts 'hmfs'  OPTION ; do
    case $OPTION in
	f) FORCE="yes"
	;;
    h) usage
    ;;
	m) MOODLE="yes"
	;;
	s) SHOW="yes"
	;;
    esac
done
shift $(( OPTIND - 1 ))


if [ -f moodle.spec ]; then
	MOODLEVERSION=`grep Version: moodle.spec  | awk '" " { print $2 }'`
	MOODLEDIR=${MOODLEVERSION/./}
else 
	echo "Couldn't find moodle.spec"
	exit 1
fi

if [ "$SHOW" == "yes" ] ; then
  z=10;
  for i in `ls *.zip `; do
    echo "Source1${z}:      `basename $i`";
    z=$((z+1));
  done
  exit
fi

# grrr. language packs are still in the old directory
MOODLEDIR=16
for i in `grep Source1[0-9][0-9] moodle.spec | awk '" " { print $2 }'`; do
    if [ "$FORCE" = yes ]; then
	rm $i
    fi
    wget --no-clobber --continue http://download.moodle.org/lang$MOODLEDIR/${i}
done


if [ "$MOODLE" == "yes" ]; then
    MOODLEDIR=${MOODLEVERSION/./}
    wget --no-clobber --continue http://download.moodle.org/stable19/moodle-$MOODLEVERSION.tgz
    if [ -d moodle ] ; then
        echo "Warning: directory moodle exists - exiting"
        exit 1
    fi
    tar -xzf moodle-$MOODLEVERSION.tgz
    tar -cjf moodle-$MOODLEVERSION.tar.bz2 moodle
    rm -r moodle
    rm moodle-$MOODLEVERSION.tgz
fi

openSUSE Build Service is sponsored by