#!/bin/bash # # priority: 1200 # # Update node package repository metadata and sign packages # # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # # $Id$ # # Source function library and configuration . /etc/plc.d/functions . /etc/planetlab/plc_config # Be verbose set -x case "$1" in start) if [ "$PLC_BOOT_ENABLED" != "1" ] ; then exit 0 fi MESSAGE=$"Signing and indexing node packages" dialog "$MESSAGE" shopt -s nullglob shift if [[ -z "$@" ]] ; then # use all subdirs in install-rpms by default repositories=/var/www/html/install-rpms/* else # else use argv repositories=$@ fi for repository in $repositories ; do packages= stamps= yum_arch=0 createrepo=0 # Create a stamp once the package gets signed mkdir $repository/signed-stamps for package in $repository/*.rpm ; do stamp=$repository/signed-stamps/$(basename $package).signed # If package is newer than signature stamp if [ $package -nt $stamp ] ; then packages="$packages $package" stamps="$stamps $stamp" fi # Or yum-arch headers if [ $package -nt $repository/headers/header.info ] ; then yum_arch=1 fi # Or createrepo database if [ $package -nt $repository/repodata/repomd.xml ] ; then createrepo=1 fi done if [ -n "$packages" ] ; then # Sign RPMS. setsid detaches rpm from the terminal, # allowing the (hopefully blank) GPG password to be # entered from stdin instead of /dev/tty. echo | setsid rpm \ --define "_signature gpg" \ --define "_gpg_path /etc/planetlab" \ --define "_gpg_name $PLC_MAIL_SUPPORT_ADDRESS" \ --resign $packages && touch $stamps check fi # Update yum metadata. yum-arch createrepo sometimes leaves behind # .oldheaders and .olddata directories accidentally. rm -rf $repository/{.oldheaders,.olddata} # Old command is yum-arch if [ $yum_arch -eq 1 ] ; then yum-arch $repository check fi # New command is createrepo if [ $createrepo -eq 1 ] ; then if [ -f $repository/yumgroups.xml ] ; then createrepo -g yumgroups.xml $repository else createrepo $repository fi check fi done result "$MESSAGE" ;; clean) shift if [[ -z "$@" ]] ; then # use all subdirs in install-rpms by default repositories=/var/www/html/install-rpms/* else # else use argv repositories=$@ fi for repository in $repositories ; do rm -rf $repository/signed-stamps rm -rf $repository/repodata rm -rf $repository/headers done ;; *) echo "Usage: $0 start|clean [repo ..]" ;; esac exit $ERRORS