#!/bin/bash
set -e

packages=$1
hosts="www1.static.verdnatura.es www2.static.verdnatura.es"

if [ -z "$packages" ]
then
	echo "Usage: $(basename $0) package_name..."
	exit 1
fi

# FIXME: Packages are not upgraded when config files are changed

echo "Upgrading servers."

for host in $hosts
do
    echo " * Upgrading $host"
    ssh root@$host "update-repo vn && apt-get install $packages >> /dev/null"
done