File get_sources.sh of Package moodle3_4

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


VERSION="3.4"
FORCE="no"
SHOW="no"
MOODLE="no"
VERSIONNAME=$(echo ${VERSION/./_})

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${VERSIONNAME}.spec ]; then
	MOODLEVERSION=`grep ^Version: moodle${VERSIONNAME}.spec  | awk '" " { print $2 }'`
	MOODLEDIR=${MOODLEVERSION/./}
else 
	echo "Couldn't find moodle${VERSIONNAME}.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

MOODLEDIR=16
for i in `grep Source1[0-9][0-9] moodle${VERSIONNAME}.spec | awk '" " { print $2 }'`; do
    if [ "$FORCE" = yes ]; then
	rm $i
    fi
    # https://download.moodle.org/langpack/3.4/
    wget -4 --no-clobber --continue https://download.moodle.org/langpack/${VERSION}/${i}
done


if [ "$MOODLE" == "yes" ]; then
    MOODLEDIR=${VERSION/./}
    wget -4 --no-clobber --continue http://download.moodle.org/stable${MOODLEDIR}/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