Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2779 - (show annotations) (download) (as text)
Fri Aug 26 11:51:09 2011 UTC (12 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 1828 byte(s)
-added plugin setup functionality to honor any settings change of a plugin via the webfrontend on every boot
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 # install only if not already installed
37 if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] &&
38 [[ ! -f ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} ]]
39 then
40 echo " Installing plugin '${cfg_plugins_plugin} ..."
41 ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh install
42 touch ${SETTINGSPATH}/plugins/${cfg_plugins_plugin}
43 fi
44
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 echo " Setting up plugin '${cfg_plugins_plugin} ..."
49 ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh setup
50 fi
51 done
52
53 # uninstall
54 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 echo " Uninstalling plugin '${plugin} ..."
76 ${ALX_PLUGINS}/${plugin}/plugin.sh uninstall
77 rm -f ${SETTINGSPATH}/plugins/${plugin}
78 fi
79 done
80 fi
81 }