7 default_url="http://localhost/mirror/"
9 all_distros="fc4 fc6 f7 f8 centos5"
11 function check_distro () {
12 local distro=$1; shift
13 if [ ! -d $DIRNAME/$distro ] ; then
14 echo "Distro $distro not supported - skipped"
21 local distro=$1; shift
22 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
23 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
24 if [ ! -d $dir ] ; then
25 [ -n "$VERBOSE" ] && echo Creating dir $dir
28 [ -n "$VERBOSE" ] && echo "Creating $repo"
29 sed -e "s,@MIRRORURL@,$URL," < $DIRNAME/$distro/building.repo.in > $repo
32 function do_display () {
33 local distro=$1; shift
34 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
36 echo "====================" Contents of $dir
37 find $dir -name '*.repo' | xargs head --verbose --lines=1000
39 echo "====================" $dir does not exist
43 function do_clear () {
44 local distro=$1; shift
45 repo=/etc/vservers/.distributions/$distro/yum.repos.d/building.repo
46 [ -n "$VERBOSE" ] && echo Removing $repo
50 function do_superclean () {
51 local distro=$1; shift
52 dir=/etc/vservers/.distributions/$distro/yum.repos.d/
53 [ -n "$VERBOSE" ] && echo Removing all repo files in $dir
58 echo "Usage $COMMAND [options] <command>"
59 echo " a help to manage the yum.repos.d template in /etc/vservers/.distributions/<distro>"
60 echo "Available commands"
61 echo " init: creates /etc/vservers/.distributions/<distro>/yum.repos.d/building.repo"
62 echo " default is to use mirror root at $default_url"
63 echo " use -u URL to specify another location"
64 echo " display: shows content"
65 echo " clean: removes building.repo"
66 echo " superclean: removes yum.repos.d altogether"
68 echo " -f <distro> : defaults to $default_distro"
69 echo " -a : runs on all distros $all_distros"
72 echo " $COMMAND -a display "
73 echo " $COMMAND -a superclean"
74 echo " $COMMAND -a -u http://mirror.one-lab.org/ init"
75 echo " $COMMAND -a display"
85 while getopts "u:f:av" opt; do
88 f) DISTROS="$DISTROS $OPTARG" ;;
89 a) DISTROS="$DISTROS $all_distros" ;;
95 shift $(($OPTIND - 1))
104 init*) action=init ;;
105 dis*) action=display ;;
106 clea*) action=clear ;;
107 super*) action=superclean ;;
114 [ -z "$URL" ] && URL=$default_url
115 [ -z "$DISTROS" ] && DISTROS="$default_distro"
117 # remove trailing slash
118 URL=$(echo $URL | sed -e 's,/$,,')
120 for distro in $DISTROS; do
121 [ -n "$VERBOSE" ] && echo ==================== Running $action for $distro
122 check_distro $distro && do_$action $distro