aboutsummaryrefslogtreecommitdiff
path: root/postfixadmin-dl
blob: 7c4b2745b7498e9d9fa2410275dc272778ba05c7 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#
# Postfixadmin software upgrader.
#

# Config parameters
BASENAME="`basename $0`"
OLD_VERSION="$1"
VERSION="$2"

# Syntax check
if [ -z "$2" ]; then
  echo "usage: $BASENAME <old-version> <new-version>"
  exit 1
fi

# Check installed versions
if [ ! -d "postfixadmin-$OLD_VERSION" ]; then
  echo "error: postfixadmin-$OLD_VERSION is not installed, aborting."
  exit 1
elif [ -d "postfixadmin-$VERSION" ]; then
  echo "error: postfixadmin-$VERSION already installed, aborting."
  exit 1
fi

# Download package
wget -c https://downloads.sourceforge.net/project/postfixadmin/postfixadmin-3.3.8/PostfixAdmin%20$VERSION.tar.gz \
     -O postfixadmin-$VERSION.tar.gz
#wget -c http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-$VERSION/postfixadmin-$VERSION.tar.gz

# Download signature
#wget -c http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-$VERSION/postfixadmin-$VERSION.tar.gz.asc
wget -c https://downloads.sourceforge.net/project/postfixadmin/postfixadmin-3.3.8/PostfixAdmin%20$VERSION.tar.gz.asc \
     -O postfixadmin-$VERSION.tar.gz.asc

# Check signature
#gpg --verify postfixadmin-$VERSION.tar.gz.asc postfixadmin-$VERSION.tar.gz || exit 1

# Decompress
(
  mkdir tmp
  cd tmp
  tar xvf ../postfixadmin-$VERSION.tar.gz
  mv postfixadmin-$VERSION ../postfixadmin-$VERSION
  cd ..
  rmdir tmp
)

# Remove package
rm postfixadmin-$VERSION.tar.gz
rm postfixadmin-$VERSION.tar.gz.asc

# Sync configuration
chown -R root. postfixadmin-$VERSION
cp postfixadmin-$VERSION/config.inc.php postfixadmin-$VERSION/config.inc.php.dist
cp -a postfixadmin-$OLD_VERSION/config.inc.php postfixadmin-$VERSION/config.inc.php

# Pivot
rm postfixadmin && ln -s postfixadmin-$VERSION postfixadmin

# Audit
echo "Audit:" && \
du -hs postfixadmin-$OLD_VERSION && \
du -hs postfixadmin-$VERSION