#!/bin/bash NAMES=$1 shift for A in $*; do if [ $A == "rebuild" ]; then BUILDCHECK=1 elif [ $A == "reboot" ] ; then REBOOT=1 else TARGETS="$TARGETS $A" fi done if ! [ "$NAMES" ]; then echo "Usage: ./remoteinstall '' [rebuild] [reboot]" echo "If rebuild is specified, the packages will be rebuild-checked." echo "If reboot is specified, the box will be rebooted after installing. usefull for kernels" echo echo "To specify ssh/scp options such as a different port:" echo 'OPTS="-o port=10022" ./remoteinstall ' echo echo "Specify multiple targets this way in an easy way:" echo "./remoteinstall packagename 192.168.0.{123,5,21,43}" exit 1 fi for TARGET in $TARGETS; do ./sshkeyfix $TARGET done for NAME in $NAMES; do if [ "$BUILDCHECK" ]; then echo "* Build check:" ./rebuildcheck $NAME '|' $* || exit 1 fi echo -n "* Package $NAME zoeken:" PKG=`./findpkg "$NAME"` || exit 1 BASE=`basename "$PKG"` || exit 1 echo $PKG; export OPTS echo "* install:" for TARGET in $TARGETS; do ( echo "Uploading and installing" if scp $OPTS $PKG $TARGET:/tmp/$BASE && ssh $OPTS $TARGET "cd / && syn3-update /tmp/$BASE && rm /tmp/$BASE && postinst.sh"; then echo "Install on $TARGET OK" if [ "$REBOOT" ]; then echo "Rebooting box!" ssh $OPTS $TARGET "reboot" fi else echo "######################## INSTALL ON $TARGET FAILED! ######## " fi ) | sed -u "s/^/$TARGET: /" & done wait done echo "All installs done"