aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpostfixadmin-dl60
1 files changed, 60 insertions, 0 deletions
diff --git a/postfixadmin-dl b/postfixadmin-dl
new file mode 100755
index 0000000..6a36cf9
--- /dev/null
+++ b/postfixadmin-dl
@@ -0,0 +1,60 @@
+#!/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 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
+
+# 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