75 lines (61 with data), 2.1 kB
#!/bin/bash
### DNFD
## repos.conf - configurador de repositorios para dnfd
## por niky45
## variables
interfaz=$1
debug=$2
## /variables
## funciones
source functions start
## /funciones
if [ $debug == Y ] ;then
PRINT rc_bdbg;read BD
if [ $BD == y ]; then set -x ; set -v ;fi
FN dy
PRINT rc_start
read C ; if [ $C == y ];then
SOURCES="sources.test"
CONF="aptconf.test"
fi
else
DBG() { $@ ;}
SOURCES="/etc/apt/sources.list"
CONF="/etc/apt/apt.conf"
fi
## copiamos el sources.list por si acaso
DBG mv $SOURCES $SOURCES.bak-$(date +%d.%m.%y)
#creamos un nuevo sources
touch $SOURCES
echo -e "### repositorios debian \n ### fichero creado por dnfd - repos.conf \n \n " >> $SOURCES
## aniadimos el cdrom, security y volatile
echo -e "### cd, security & volatile ------------" >> $SOURCES
cat $SOURCES.bak-$(date +%d.%m.%y) | grep -v "#" | grep cdrom >> $SOURCES
cat $SOURCES.bak-$(date +%d.%m.%y) | grep -v "#" | grep security >> $SOURCES
cat $SOURCES.bak-$(date +%d.%m.%y) | grep -v "#" | grep volatile >> $SOURCES
## preguntamos el codigo del pais y la rama
PRINT repos
listarepos=$(cat listamirrors | grep -v "#" | awk '{print $1}')
select MIR in $listarepos; do
MIR=$(cat listamirrors | grep $MIR | awk '{print $2}')
break
done
PRINT rama
select BR in "stable" "testing" "unstable"; do
break
done
## codigo del pais y rama como datos de entrada
### creamos todas las ramas, definimos el comportamiento en el apt.conf
echo -e "### oficiales ---------------------------- \n " >> $SOURCES
for RAMA in stable testing unstable experimental ;do
echo -e "### $RAMA ###" >> $SOURCES
echo "deb http://$MIR $RAMA main non-free contrib" >> $SOURCES
echo "deb-src http://$MIR $RAMA main non-free contrib" >> $SOURCES
echo -e "\n " >> $SOURCES
done
## creamos el apt.conf con la rama elegida
mv $CONF $CONF.bak-$(date +%d.%m.%y)
DBG touch $CONF
DBG echo apt::default-release \"$BR\" \; >> $CONF
DBG echo $(cat $CONF.bak-$(date +%d.%m.%y) |grep -v "#" |grep -v " apt::default-release") >> $CONF
## implementar codigos de errores