From 28673a22d69c7e1114eb8368d07d1f89adb51862 Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> Date: Tue, 7 Jul 2009 10:57:39 -0400 Subject: [PATCH] [#1791] Add postinst script to keep user data when migrating config/history file --- .../ubuntu/debian-sflphone-common/postinst | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tools/build-system/distributions/ubuntu/debian-sflphone-common/postinst diff --git a/tools/build-system/distributions/ubuntu/debian-sflphone-common/postinst b/tools/build-system/distributions/ubuntu/debian-sflphone-common/postinst new file mode 100644 index 0000000000..cacf45f0b9 --- /dev/null +++ b/tools/build-system/distributions/ubuntu/debian-sflphone-common/postinst @@ -0,0 +1,48 @@ +#!/bin/bash +# postinst script for sflphone-common +# +# see: dh_installdeb(1) + +# Script to copy and move, if exists, configuration file sflphonedrc and history in the XDG directory +# Freedesktop specifications: http://standards.freedesktop.org/basedir-spec/latest/ + +set -e + +INST_CONFIG="$HOME/.sflphone/sflphonedrc"; +INST_DATA="$HOME/.sflphone/history"; +INST_CACHE="$HOME/.sflphone/sfl.pid"; + +NEW_INST_CONFIG= +NEW_INST_DATA= +NEW_INST_CACHE= + +# Set the XDG CONFIG directory to the default one or to the path set in the environment variable +if [ -z $XDG_CONFIG_HOME ]; then + NEW_INST_CONFIG=$HOME"/.config/sflphone"; # This is the standard path +else + NEW_INST_CONFIG=$XDG_CONFIG_HOME; +fi; + +# Set the XDG DATA directory to the default one or to the path set in the environment variable +if [ -z $XDG_DATA_HOME ]; then + NEW_INST_DATA=$HOME"/.local/share/sflphone"; # This is the standard path +else + NEW_INST_DATA=$XDG_DATA_HOME; +fi; + +# Move the configuration file +if [ -f $INST_CONFIG ] ; then + echo "Moving the configuration file into $NEW_INST_CONFIG directory"; + mv $INST_CONFIG $NEW_INST_CONFIG; +fi + +# Move the history +if [ -f $INST_DATA ] ; then + echo "Moving the history file into $NEW_INST_DATA directory"; + mv $INST_DATA $NEW_INST_DATA; +fi + +# Remove the directory +rmdir $HOME"/.sflphone"; + +exit 0 -- GitLab