Annotation of /alx-src/branches/alxconf-060/functions/config_plugins.sh
Parent Directory | Revision Log
Revision 3489 -
(hide annotations)
(download)
(as text)
Mon Apr 16 09:01:30 2012 UTC (12 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 1826 byte(s)
Mon Apr 16 09:01:30 2012 UTC (12 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 1826 byte(s)
-fixed messages
1 | niro | 2747 | # $Id$ |
2 | # install plugins | ||
3 | |||
4 | is_installed() | ||
5 | { | ||
6 | niro | 3487 | local i |
7 | local item="$1" | ||
8 | niro | 2747 | |
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 | niro | 2776 | local i |
22 | local plugin | ||
23 | local keep | ||
24 | niro | 2747 | |
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 | niro | 2779 | # install only if not already installed |
37 | if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] && | ||
38 | [[ ! -f ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} ]] | ||
39 | niro | 2747 | then |
40 | niro | 3489 | rc_echo " Installing plugin '${cfg_plugins_plugin}' ..." |
41 | niro | 2747 | ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh install |
42 | touch ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} | ||
43 | fi | ||
44 | niro | 2779 | |
45 | # always run plugin setup on every boot to honor any changes | ||
46 | if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] | ||
47 | then | ||
48 | niro | 3489 | rc_echo " Setting up plugin '${cfg_plugins_plugin}' ..." |
49 | niro | 2779 | ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh setup |
50 | fi | ||
51 | niro | 2747 | done |
52 | |||
53 | # uninstall | ||
54 | niro | 2776 | if [ -d ${SETTINGSPATH}/plugins ] |
55 | then | ||
56 | installed_plugins=$(find ${SETTINGSPATH}/plugins -mindepth 1 -maxdepth 1 -type f -printf '%f\n') | ||
57 | |||
58 | for plugin in ${installed_plugins} | ||
59 | do | ||
60 | keep=0 | ||
61 | for i in ${all_ids} | ||
62 | do | ||
63 | evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'" | ||
64 | |||
65 | if [[ ${plugin} = ${cfg_plugins_plugin} ]] | ||
66 | then | ||
67 | keep=1 | ||
68 | # found, break here | ||
69 | break | ||
70 | fi | ||
71 | done | ||
72 | |||
73 | if [[ ${keep} = 0 ]] | ||
74 | then | ||
75 | niro | 3489 | rc_echo " Uninstalling plugin '${plugin}' ..." |
76 | niro | 2776 | ${ALX_PLUGINS}/${plugin}/plugin.sh uninstall |
77 | rm -f ${SETTINGSPATH}/plugins/${plugin} | ||
78 | fi | ||
79 | done | ||
80 | fi | ||
81 | niro | 2747 | } |