|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
3 |
| -set -e |
| 3 | +set -eo pipefail |
| 4 | +export BASHOPTS |
4 | 5 |
|
5 | 6 | PKG_NAME=@PKG_NAME@
|
6 | 7 |
|
7 |
| -if [ "$1" != install ] |
| 8 | +if [ "$1" = install ] |
8 | 9 | then
|
9 |
| - exit 0 |
| 10 | + if dpkg-query --list 'algorand*' &> /dev/null |
| 11 | + then |
| 12 | + if PKG_INFO=$(dpkg-query --show --showformat='${Package} ${Status}\n' 'algorand*' | grep "install ok installed") |
| 13 | + then |
| 14 | + # Filter out `algorand-indexer` and `algorand-devtools` packages, they are allowed to be |
| 15 | + # installed alongside other `algorand` packages. |
| 16 | + INSTALLED_PKG=$(grep -v -e algorand-indexer -e algorand-devtools <<< "$PKG_INFO" | awk '{print $1}') |
| 17 | + |
| 18 | + if [ -n "$INSTALLED_PKG" ] |
| 19 | + then |
| 20 | + echo -e "\nAlgorand does not currently support multi-distribution installations!\n\ |
| 21 | + To install this package, it is necessary to first remove the \`$INSTALLED_PKG\` package:\n\n\ |
| 22 | + sudo apt-get remove $INSTALLED_PKG\n\ |
| 23 | + sudo apt-get install $PKG_NAME\n" |
| 24 | + exit 1 |
| 25 | + fi |
| 26 | + fi |
| 27 | + fi |
10 | 28 | fi
|
11 | 29 |
|
12 |
| -if dpkg-query --list 'algorand*' &> /dev/null |
| 30 | +if [ "$1" = upgrade ] |
13 | 31 | then
|
14 |
| - if PKG_INFO=$(dpkg-query --show --showformat='${Package} ${Status}\n' 'algorand*' | grep "install ok installed") |
| 32 | + if [ -f /var/lib/algorand/genesis.json ] |
15 | 33 | then
|
16 |
| - # Filter out `algorand-indexer` and `algorand-devtools` packages, they are allowed to be |
17 |
| - # installed alongside other `algorand` packages. |
18 |
| - INSTALLED_PKG=$(grep -v -e algorand-indexer -e algorand-devtools <<< "$PKG_INFO" | awk '{print $1}') |
| 34 | + ALGO_MD5=$(md5sum /var/lib/algorand/genesis.json | awk '{print $1}') |
| 35 | + ALGO_TIMESTAMP=$(stat -c %Y /var/lib/algorand/genesis.json) |
19 | 36 |
|
20 |
| - if [ -n "$INSTALLED_PKG" ] |
| 37 | + if [ "$ALGO_MD5" = "9afc34b96a2c4a9f936870cd26ae7873" ] |
21 | 38 | then
|
22 |
| - echo -e "\nAlgorand does not currently support multi-distribution installations!\n\ |
23 |
| - To install this package, it is necessary to first remove the \`$INSTALLED_PKG\` package:\n\n\ |
24 |
| - sudo apt-get remove $INSTALLED_PKG\n\ |
25 |
| - sudo apt-get install $PKG_NAME\n" |
26 |
| - exit 1 |
| 39 | + if [[ "$ALGO_TIMESTAMP" != 1600456830 || |
| 40 | + ( "$ALGO_TIMESTAMP" = 1600456830 && ! -d /var/lib/algorand/mainnet-v1.0 ) ]] |
| 41 | + then |
| 42 | + # 2.1.5 bug fix - back up user-modified genesis.json to restore after conffiles |
| 43 | + cp -p /var/lib/algorand/genesis.json /var/lib/algorand/genesis.json-2.1.5-patch |
| 44 | + fi |
27 | 45 | fi
|
| 46 | + |
28 | 47 | fi
|
29 | 48 | fi
|
30 | 49 |
|
0 commit comments