source: npl/remoteinstall @ c403a2d

perl-5.22
Last change on this file since c403a2d was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/bin/bash
2NAMES=$1
3shift
4
5
6
7for A in $*; do
8    if [ $A == "rebuild" ]; then
9        BUILDCHECK=1
10    elif [ $A == "reboot" ] ; then
11        REBOOT=1
12    else
13        TARGETS="$TARGETS $A"
14    fi
15done
16
17if ! [ "$NAMES" ]; then
18        echo "Usage: ./remoteinstall '<pkgname pkgname ...>' <root@targethost1> <root@targethost2...> [rebuild] [reboot]"
19        echo "If rebuild is specified, the packages will be rebuild-checked."
20        echo "If reboot is specified, the box will be rebooted after installing. usefull for kernels"
21        echo
22        echo "To specify ssh/scp options such as a different port:"
23        echo 'OPTS="-o port=10022" ./remoteinstall <pkgname> <root@targethost>'
24        echo
25        echo "Specify multiple targets this way in an easy way:"
26        echo "./remoteinstall packagename 192.168.0.{123,5,21,43}"
27        exit 1
28fi
29
30for TARGET in $TARGETS; do
31        ./sshkeyfix $TARGET
32done
33
34for NAME in $NAMES; do
35       
36        if [ "$BUILDCHECK" ]; then
37                echo "* Build check:"
38                ./rebuildcheck $NAME '|' $* || exit 1
39        fi
40       
41        echo -n "* Package $NAME zoeken:"
42        PKG=`./findpkg "$NAME"` || exit 1
43        BASE=`basename "$PKG"` || exit 1
44        echo $PKG;
45       
46        export OPTS
47        echo "* install:"
48
49        for TARGET in $TARGETS; do
50                (
51                echo "Uploading and installing"
52                if scp $OPTS $PKG $TARGET:/tmp/$BASE &&
53                        ssh $OPTS $TARGET "cd / && syn3-update /tmp/$BASE && rm /tmp/$BASE && postinst.sh"; then
54                        echo "Install on $TARGET OK"
55                        if [ "$REBOOT" ]; then
56                        echo "Rebooting box!"
57                        ssh $OPTS $TARGET "reboot"
58                        fi
59                else
60                        echo "######################## INSTALL ON $TARGET FAILED! ######## "
61                fi
62                ) | sed -u "s/^/$TARGET: /" &
63        done
64       
65        wait
66done
67
68echo "All installs done"
Note: See TracBrowser for help on using the repository browser.