Contents of /alx-src/trunk/alxconfig-ng/functions/config_plugins.sh
Parent Directory | Revision Log
Revision 2776 -
(show annotations)
(download)
(as text)
Fri Aug 26 11:02:15 2011 UTC (13 years, 1 month ago) by niro
Original Path: alx-src/branches/alxconf-060/functions/config_plugins.sh
File MIME type: application/x-sh
File size: 1566 byte(s)
Fri Aug 26 11:02:15 2011 UTC (13 years, 1 month ago) by niro
Original Path: alx-src/branches/alxconf-060/functions/config_plugins.sh
File MIME type: application/x-sh
File size: 1566 byte(s)
-fixed plugin uninstall routine
1 | # $Id$ |
2 | # install plugins |
3 | |
4 | is_installed() |
5 | { |
6 | local i |
7 | local item="$1" |
8 | |
9 | for i in ${SETTINGSPATH}/plugins/* |
10 | do |
11 | [[ $(basename ${i}) = ${item} ]] && return 1 |
12 | done |
13 | |
14 | return 0 |
15 | } |
16 | |
17 | config_plugins() |
18 | { |
19 | local all_ids |
20 | local installed_plugins |
21 | local i |
22 | local plugin |
23 | local keep |
24 | |
25 | # install needed directories |
26 | [[ ! -d ${SETTINGSPATH}/plugins ]] && install -d ${SETTINGSPATH}/plugins |
27 | |
28 | # get all ids |
29 | all_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'") |
30 | |
31 | # install |
32 | for i in ${all_ids} |
33 | do |
34 | evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" |
35 | |
36 | # already installed ? |
37 | [[ -f ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} ]] && continue |
38 | |
39 | if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] |
40 | then |
41 | echo " Installing plugin '${cfg_plugins_plugin} ..." |
42 | ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh install |
43 | touch ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} |
44 | fi |
45 | done |
46 | |
47 | # uninstall |
48 | if [ -d ${SETTINGSPATH}/plugins ] |
49 | then |
50 | installed_plugins=$(find ${SETTINGSPATH}/plugins -mindepth 1 -maxdepth 1 -type f -printf '%f\n') |
51 | |
52 | for plugin in ${installed_plugins} |
53 | do |
54 | keep=0 |
55 | for i in ${all_ids} |
56 | do |
57 | evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" |
58 | |
59 | if [[ ${plugin} = ${cfg_plugins_plugin} ]] |
60 | then |
61 | keep=1 |
62 | # found, break here |
63 | break |
64 | fi |
65 | done |
66 | |
67 | if [[ ${keep} = 0 ]] |
68 | then |
69 | echo " Uninstalling plugin '${plugin} ..." |
70 | ${ALX_PLUGINS}/${plugin}/plugin.sh uninstall |
71 | rm -f ${SETTINGSPATH}/plugins/${plugin} |
72 | fi |
73 | done |
74 | fi |
75 | } |