Repositório Local usando Yum

Publicado por Alexandre de Abreu 05/01/2005

[ Hits: 6.805 ]

Download yum_repository.sh




Este script cria/mantém um repositório local de arquivos RPM em um servidor FTP/HTTP, disponibilizando pacotes para clientes Linux manterem distribuições através do progtama "yum".

É compatível com os programas "yum-arch" e "createrepo", responsáveis pela construção da estrutura de diretório do repositório. Contém exemplos de configuração para repositórios RedHat/Fedora e suporte à utilização de servidor proxy.

Em breve será disponibilizado um tutorial de utilização neste site.

  



Esconder código-fonte

-- snipped --
while [ ${MIRROR_URL[count]} ]; do
        # Some checking
        [ -d ${MIRROR_DIR[count]} ] || {
                /bin/echo "[*] Try creating localdir ${MIRROR_DIR[count]}"
                /bin/echo "[*] Exiting.."
                exit 1
        }
 
        [ -w ${MIRROR_DIR[count]} ] || {
                /bin/echo "[*] Check write permissions on localdir ${MIRROR_DIR[count]}"
                /bin/echo "[*] Exiting.."
                exit 1
        }
         
        cd ${MIRROR_DIR[count]}
         
        CUT_DIRS=$(/bin/echo "${MIRROR_URL[count]}" | /bin/egrep -o "\/" | /usr/bin/wc -l)
        CUT_DIRS=$((CUT_DIRS-3))
 
        /bin/echo -e "[*] Writing logs to $LOG_FILE"
        /bin/echo -e "[*] Getting files from ${MIRROR_URL[count]}"
        /bin/echo -n "[*] Download started: " >> $LOG_FILE
        /bin/date >> $LOG_FILE
 
        # Capture some intersting signals
        trap "{
                /bin/echo \"[*] Removing PID file..\"
                /bin/rm -f $PID_FILE
                [ 1$PROXY_FLAG -ne 1 ] && {
                        /bin/echo \"[*] Unseting http_proxy var..\"
                        unset http_proxy
                }
                /bin/echo -e \"[*] Exiting..\"
                exit 1
        }" 2 3 15 19
 
        [ -n "$IGNORE_DIRS" ] && {
                for i in $IGNORE_DIRS; do
                        WGET_ARGS="$WGET_ARGS -X /"`echo "${MIRROR_URL[count]}" | cut -d/ -f4-`"$i"
                done
        }
                                                                                                                                            
        eval $WGET $WGET_ARGS --cut-dirs $CUT_DIRS ${MIRROR_URL[count]}
        /bin/echo -e "[*] Download complete for ${MIRROR_URL[count]}\n" >> $LOG_FILE
        /bin/echo -e "[*] Download complete for ${MIRROR_URL[count]}\n"
                                                                                                                                            
        # md5 and gpg signature check
        # any package that fails this check will be renamed with extension .BAD
        [ 1$GPGCHECK -eq 11 ] && {
                for rpm in `find ${MIRROR_DIR[count]} -name "*.rpm"`; do
                        $RPM -K $rpm >> $LOG_FILE || {
                                /bin/echo "[*] Bad RPM found: $rpm"
                                /bin/echo "[*] Moving to $rpm.BAD"
                                /bin/echo -e "\n[*] BAD package found: $rpm\n" >> $LOG_FILE
                                /bin/mv -f $rpm $rpm.BAD
                        }
                done
        }
                                                                                                                                            
        for PROG in $YUMARCH $CREATEREPO;do
                # create repository dirs
                /bin/echo -e "[*] Executing $PROG on ${MIRROR_DIR[count]}"
                /bin/echo -n "[*] Time started: " >> $LOG_FILE
                /bin/date >> $LOG_FILE
                eval $PROG ${MIRROR_DIR[count]} >> $LOG_FILE 2>&1
        done
        /bin/echo -e "[*] Repository creation complete for ${MIRROR_DIR[count]}\n" >> $LOG_FILE
        /bin/echo -e "[*] Repository creation complete for ${MIRROR_DIR[count]}\n"
        /bin/echo -e "[*] Done.\n\n"
                                                                                                                                            
        count=$((count+1))
done
-- snipped --

Scripts recomendados

Find em arquivos compactados (grep em arquivos tgz)

Configurador de interface de rede.

Monitorando espaço em disco com IP dinâmico.

PDC Samba + LDAP no Debian Lenny

UNIX - Alerta de espaço em disco via e-mail


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts