summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Daehn <[email protected]>2019-06-19 05:25:15 (GMT)
committer Dominik Daehn <[email protected]>2019-06-19 05:25:15 (GMT)
commit8e8cf27f7f1c165b57fee464cda73a2773cf7b2d (patch)
treea3ebce0a7ad02568fa3b449ef6f12ff8acd3a954
parent84560e2d5cff68d4f99dbbd9b6541ce3b1933c8f (diff)
save and restore previous custom dir
-rw-r--r--OPSI/postinst16
-rw-r--r--OPSI/preinst24
2 files changed, 40 insertions, 0 deletions
diff --git a/OPSI/postinst b/OPSI/postinst
index a8e33fc..b55179e 100644
--- a/OPSI/postinst
+++ b/OPSI/postinst
@@ -7,3 +7,19 @@
# PRODUCT_ID: id of the current product
# CLIENT_DATA_DIR: directory which contains the installed client data
#
+
+TMP_DIR=${CLIENT_DATA_DIR}/../${PRODUCT_ID}.tmp
+
+if [ -d $TMP_DIR ]; then
+ echo 'Restoring previous directories...'
+
+ echo 'Restoring previous custom dir...'
+ if [ -d $TMP_DIR/custom ]; then
+ test -e $CLIENT_DATA_DIR/custom && rm -rf $CLIENT_DATA_DIR/custom
+ echo " moving $TMP_DIR/custom to $CLIENT_DATA_DIR/"
+ mv $TMP_DIR/custom $CLIENT_DATA_DIR/ || exit 1
+ fi
+fi
+
+echo "Removing temporary files..."
+rm -rf $TMP_DIR
diff --git a/OPSI/preinst b/OPSI/preinst
index 15a5320..34674a6 100644
--- a/OPSI/preinst
+++ b/OPSI/preinst
@@ -7,3 +7,27 @@
# PRODUCT_ID: id of the current product
# CLIENT_DATA_DIR: directory where client data will be installed
#
+
+TMP_DIR=${CLIENT_DATA_DIR}/../${PRODUCT_ID}.tmp
+
+if [ -d $TMP_DIR ]; then
+ echo "Temporary directory $TMP_DIR already exist, aborting!" 1>&2
+ exit 1
+fi
+
+[ ! -d $CLIENT_DATA_DIR ] && mkdir $CLIENT_DATA_DIR
+mkdir $TMP_DIR
+
+if [ -d $CLIENT_DATA_DIR ]; then
+ echo "Saving previous directories..."
+ for dirname in custom ; do
+ for path in $CLIENT_DATA_DIR/$dirname; do
+ if [ -e $path ]; then
+ echo " moving $path to $TMP_DIR"
+ mv $path $TMP_DIR/ || exit 1
+ fi
+ done
+ done
+fi
+
+exit 0

Powered by Domaintechnik.at | Hosting - Domain - Webspace