source: npl/remoteinstall @ 67ad486

gcc484perl-5.22
Last change on this file since 67ad486 was f49e71c, checked in by Edwin Eefting <edwin@datux.nl>, 7 years ago

run postinstall after installing all packages

  • Property mode set to 100755
File size: 1.8 KB
RevLine 
[c5c522c]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 &&
[f49e71c]53                        ssh $OPTS $TARGET "cd / && syn3-update /tmp/$BASE && rm /tmp/$BASE"; then
[c5c522c]54                        echo "Install on $TARGET OK"
55                else
56                        echo "######################## INSTALL ON $TARGET FAILED! ######## "
57                fi
58                ) | sed -u "s/^/$TARGET: /" &
59        done
60       
61        wait
62done
63
[f49e71c]64#run postinstallers
65for TARGET in $TARGETS; do
66        (
67                if ssh $OPTS $TARGET "cd /; postinst.sh"; then
68                        echo "Install on $TARGET OK"
69                        if [ "$REBOOT" ]; then
70                                echo "Rebooting box!"
71                                ssh $OPTS $TARGET "reboot"
72                        fi
73                else
74                        echo "######################## INSTALL ON $TARGET FAILED! ######## "
75                fi
76        ) | sed -u "s/^/$TARGET: /" &
77done
78
79wait
80
81
[c5c522c]82echo "All installs done"
Note: See TracBrowser for help on using the repository browser.