aboutsummaryrefslogtreecommitdiff
path: root/postfixadmin-dl
blob: d71eb96265d90588de1f6c49f713be2a48810337 (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
#!/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 postfixadmin-$VERSION
tar xvf postfixadmin-$VERSION.tar.gz -C postfixadmin-$VERSION --strip-components=1

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

# Sync configuration
chown -R root: postfixadmin-$VERSION
cp -a postfixadmin-$OLD_VERSION/config.local.php postfixadmin-$VERSION/config.local.php
cp -a postfixadmin-$OLD_VERSION/templates_c postfixadmin-$VERSION/templates_c

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

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