Magellan Linux

Contents of /alx-src/branches/alxconf-060/functions/config_plugins.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3495 - (show annotations) (download) (as text)
Mon Apr 16 15:13:08 2012 UTC (12 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 1863 byte(s)
-print a nice message while configuring plugins
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 rc_mecho "Configuring plugins ..."
29
30 # get all ids
31 all_ids=$(mysqldo "select id from cfg_plugins where serial='${ALX_SERIAL}'")
32
33 # install
34 for i in ${all_ids}
35 do
36 evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
37
38 # install only if not already installed
39 if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] &&
40 [[ ! -f ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} ]]
41 then
42 rc_echo " Installing plugin '${cfg_plugins_plugin}' ..."
43 ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh install
44 touch ${SETTINGSPATH}/plugins/${cfg_plugins_plugin}
45 fi
46
47 # always run plugin setup on every boot to honor any changes
48 if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]]
49 then
50 rc_echo " Setting up plugin '${cfg_plugins_plugin}' ..."
51 ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh setup
52 fi
53 done
54
55 # uninstall
56 if [ -d ${SETTINGSPATH}/plugins ]
57 then
58 installed_plugins=$(find ${SETTINGSPATH}/plugins -mindepth 1 -maxdepth 1 -type f -printf '%f\n')
59
60 for plugin in ${installed_plugins}
61 do
62 keep=0
63 for i in ${all_ids}
64 do
65 evaluate_table cfg_plugins "where serial='${ALX_SERIAL}' and id='${i}'"
66
67 if [[ ${plugin} = ${cfg_plugins_plugin} ]]
68 then
69 keep=1
70 # found, break here
71 break
72 fi
73 done
74
75 if [[ ${keep} = 0 ]]
76 then
77 rc_echo " Uninstalling plugin '${plugin}' ..."
78 ${ALX_PLUGINS}/${plugin}/plugin.sh uninstall
79 rm -f ${SETTINGSPATH}/plugins/${plugin}
80 fi
81 done
82 fi
83 }