#!/bin/sh # Some values REPREPRO_DIR="/net/mirror" # This value is used to create logs on /tmp DATE_LOG=$(date +%Y-%m-%d--%k:%M | sed -e "s% %%g") _usage() { echo "USAGE: $0 [update|upgrade]" exit 1 } update_distro() { echo "Trabajando en $REPREPRO_DIR contra la distro $DISTRO" echo "Trabajando contra $DATE_LOG" reprepro -v -b "$REPREPRO_DIR/$DISTRO/" --noskipold update | logger -s -t "[lliurex-mirror]" reprepro -v -b "$REPREPRO_DIR/$DISTRO/" retrack | logger -s -t "[lliurex-mirror]" reprepro -v -b "$REPREPRO_DIR/$DISTRO/" export | logger -s -t "[lliurex-mirror]" exit 0 } upgrade_server() { apt-get update rc=0 apt-get dist-upgrade --simulate | logger -t "[lliurex-mirror]" || rc=1 if [ $rc -eq 1 ]; then echo "Server UPGRADE FAIL see /tmp/lliurex-mirror-server-upgrade."$DATE_LOG" for more details" | logger -s -t "[lliurex-mirror]" exit 1 else apt-get dist-upgrade | logger -s -t "[lliurex-mirror]" fi } # Main if [ $# -eq 0 ] ; then _usage fi case $1 in update) shift # Possible change of value DISTRO="llx1206" update_distro ;; upgrade) shift DISTRO="$1" update_distro upgrade_server ;; *) ;; esac exit 0