Mercurial > trustbridge
comparison packaging/linux-installer-uninstall.inc @ 1139:1c9001db6ea2
Split up linux installer in to be able to create a uninstaller (TODO).
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 17 Sep 2014 18:53:04 +0200 |
parents | |
children | a72d59f8c3ea |
comparison
equal
deleted
inserted
replaced
1138:45de97d43e13 | 1139:1c9001db6ea2 |
---|---|
1 #-*-sh-*- | |
2 rm_empty_dirs() | |
3 { | |
4 # Args: $1 - DIRECTORY | |
5 # | |
6 # Recursively remove DIRECTORY and all it _parent_ directories as | |
7 # long as they are empty. | |
8 local directory="$1" | |
9 while [ -d "$directory" -a -z "$(ls 2>/dev/null -A "$directory")" ] ; do | |
10 getxt "Deleting empty directory '%s' ...\n" "$directory" | |
11 rmdir "$directory" | |
12 directory=`dirname "$directory"` | |
13 done | |
14 } | |
15 | |
16 rm_files() | |
17 { | |
18 for file in "$@" ; do | |
19 if [ -e "$file" ] ; then | |
20 getxt "Deleting '%s' ...\n" "$file" | |
21 rm "$file" | |
22 fi | |
23 done | |
24 } | |
25 | |
26 remove_cronjob() | |
27 { | |
28 setup_cronjob deinstall | |
29 } | |
30 | |
31 deinstall_certs() | |
32 { | |
33 local cinst="${oldinstcfg[PREFIX]}/bin/cinst" | |
34 local certlist=`ls 2>/dev/null -1 ${instdata_path}/list-installed.txt` | |
35 | |
36 getxt "Uninstalling certificates ...\n" | |
37 | |
38 if [ "$certlist" ] ; then | |
39 getxt "Using certificate list '%s'.\n" "$certlist" | |
40 if [ -x "$cinst" ] ; then | |
41 "$cinst" "list=$certlist" "choices=uninstall" | |
42 else | |
43 getxt >&2 "WARNING: can't execute %s for certificate deinstallation.\n" "$cinst" | |
44 fi | |
45 else | |
46 getxt "No certificate list found. Nothing to do.\n" | |
47 fi | |
48 } | |
49 | |
50 deinstall_etc() | |
51 { | |
52 getxt "Removing cron job ...\n" | |
53 remove_cronjob | |
54 | |
55 # FIXME: delete all files created by the application. | |
56 local tbcfg_files=( "${instcfg_path}/TrustBridge.ini" | |
57 "${instcfg_path}/trustbridge-tray-starter.cfg" | |
58 "$instcfg_file" ) | |
59 | |
60 getxt "Removing certificate lists from: %s:\n" "$instdata_path" | |
61 rm_files "$instdata_path"/list-*.txt | |
62 | |
63 getxt "Removing PID file from: %s:\n" "$instdata_path" | |
64 rm_files "$instdata_path"/*.pid | |
65 rm_empty_dirs "$instdata_path" | |
66 | |
67 getxt "Removing configuration files:\n" | |
68 rm_files "${tbcfg_files[@]}" | |
69 rm_empty_dirs "$instcfg_path" | |
70 | |
71 getxt "Removing TrustBridge from autostart\n" | |
72 rm_files "${autostart_path}/trustbridge.desktop" | |
73 update-desktop-database 2>&1 || true | |
74 | |
75 getxt "Removing TrustBridge from start menu\n" | |
76 rm_files "${startmenu_path}/trustbridge.desktop" | |
77 } | |
78 | |
79 deinstall() | |
80 { | |
81 if [ "${oldinstcfg[PREFIX]}" ] ; then | |
82 getxt "Really deinstall TrustBridge from '%s'? [y/n]\n" "${oldinstcfg[PREFIX]}" | |
83 yorn || exit 0 | |
84 deinstall_certs | |
85 local deinstdir="${oldinstcfg[PREFIX]}/bin" | |
86 getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}" | |
87 for file in $BINNAMES ; do | |
88 local path="${deinstdir}/$file" | |
89 getxt "Deleting '%s' ...\n" "$path" | |
90 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" | |
91 done | |
92 rm_empty_dirs "$deinstdir" | |
93 | |
94 # images | |
95 deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge/_images" | |
96 for file in $HELPNAMES_IMG; do | |
97 local path="${deinstdir}/$file" | |
98 if [ -f "$path" ]; then | |
99 getxt "Deleting '%s' ...\n" "$path" | |
100 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" | |
101 fi | |
102 done | |
103 rm_empty_dirs "$deinstdir" | |
104 | |
105 # Javascript sources | |
106 deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge/_sources" | |
107 for file in $HELPNAMES_SOURCES; do | |
108 local path="${deinstdir}/$file" | |
109 if [ -f "$path" ]; then | |
110 getxt "Deleting '%s' ...\n" "$path" | |
111 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" | |
112 fi | |
113 done | |
114 rm_empty_dirs "$deinstdir" | |
115 | |
116 # Static files | |
117 deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge/_static" | |
118 for file in $HELPNAMES_STATIC; do | |
119 local path="${deinstdir}/$file" | |
120 if [ -f "$path" ]; then | |
121 getxt "Deleting '%s' ...\n" "$path" | |
122 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" | |
123 fi | |
124 done | |
125 rm_empty_dirs "$deinstdir" | |
126 | |
127 # The actual html | |
128 deinstdir="${oldinstcfg[PREFIX]}/share/doc/trustbridge" | |
129 for file in $HELPNAMES; do | |
130 local path="${deinstdir}/$file" | |
131 if [ -f "$path" ]; then | |
132 getxt "Deleting '%s' ...\n" "$path" | |
133 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" | |
134 fi | |
135 done | |
136 rm_empty_dirs "$deinstdir" | |
137 deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps/trustbridge" | |
138 getxt "Deinstalling from '%s'.\n" "${oldinstcfg[PREFIX]}" | |
139 for file in $ICONNAME; do | |
140 local path="${deinstdir}/$file" | |
141 getxt "Deleting '%s' ...\n" "$path" | |
142 rm "$path" || getxt >&2 "WARNING: Could not delete: '%s'!\n" "$path" | |
143 done | |
144 deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps/trustbridge" | |
145 rm_empty_dirs "$deinstdir" | |
146 deinstdir="${oldinstcfg[PREFIX]}/share/pixmaps" | |
147 rm_empty_dirs "$deinstdir" | |
148 deinstdir="${oldinstcfg[PREFIX]}/share" | |
149 rm_empty_dirs "$deinstdir" | |
150 deinstall_etc | |
151 getxt "Deinstallation finished.\n" | |
152 else | |
153 getxt "No current installation found! No harm done.\n" | |
154 fi | |
155 } |