Cappy
December 19th, 2007, 07:26 PM
I need like to get the mirror a user uses.
Currently I have
if [ -f "/etc/apt/sources.list" ]; then
mirror=`grep -m 1 "^deb" /etc/apt/sources.list | cut -f2 -d ' '`
elif [ -f "/etc/apt/sources.lst" ]; then
mirror=`grep -m 1 "^deb" /etc/apt/sources.lst | cut -f2 -d ' '`
else
echo "no /etc/apt/sources.list or /etc/apt/sources.lst"
mirror="http://mirrors.kernel.org/ubuntu/"
fi
echo "Using mirror $mirror"
but this seems prone to error because something like medibuntu could have the first place in the /etc/apt/sources.list file.
Does anyone know a better way to achieve this?
Currently I have
if [ -f "/etc/apt/sources.list" ]; then
mirror=`grep -m 1 "^deb" /etc/apt/sources.list | cut -f2 -d ' '`
elif [ -f "/etc/apt/sources.lst" ]; then
mirror=`grep -m 1 "^deb" /etc/apt/sources.lst | cut -f2 -d ' '`
else
echo "no /etc/apt/sources.list or /etc/apt/sources.lst"
mirror="http://mirrors.kernel.org/ubuntu/"
fi
echo "Using mirror $mirror"
but this seems prone to error because something like medibuntu could have the first place in the /etc/apt/sources.list file.
Does anyone know a better way to achieve this?