forked from hifiberry/hifiberry-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-pi
executable file
·35 lines (27 loc) · 895 Bytes
/
update-pi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
cd `dirname $0`
VERSION=$1
HOST=$2
if [ "$HOST" == "" ]; then
echo $0 hostname
echo e.g. $0 piversion 10.0.1.23 will push the current release to the Pi with the IP address 10.0.1.23
exit 1
fi
PORT=$3
if [ "$PORT" == "" ]; then
PORT=22
fi
if [ "$PASSWORD" == "" ]; then
PASSWORD=hifiberry
fi
REMOTEVERSION=`sshpass -p "$PASSWORD" ssh -p $PORT root@$HOST cat /etc/piversion`
if [ "$REMOTEVERSION" == "" -o "$REMOTEVERSION" == "$VERSION" ]; then
echo "Packaging Pi$VERSION release"
./create-updater $VERSION
IMG=`ls images/ | grep updater | grep pi$VERSION | tail -1`
echo "Updating $HOST with $IMG"
sshpass -p "$PASSWORD" scp -P $PORT images/$IMG root@$HOST:/data/updater.tar.gz;
sshpass -p "$PASSWORD" ssh -p $PORT root@$HOST /opt/hifiberry/bin/extract-update --reboot
else
echo "Raspberry Pi version do not match: local $VERSION != remote $REMOTEVERSION"
fi