Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3495 - (hide 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 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 niro 3495 rc_mecho "Configuring plugins ..."
29    
30 niro 2747 # 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 niro 2779 # install only if not already installed
39     if [[ -x ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh ]] &&
40     [[ ! -f ${SETTINGSPATH}/plugins/${cfg_plugins_plugin} ]]
41 niro 2747 then
42 niro 3489 rc_echo " Installing plugin '${cfg_plugins_plugin}' ..."
43 niro 2747 ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh install
44     touch ${SETTINGSPATH}/plugins/${cfg_plugins_plugin}
45     fi
46 niro 2779
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 niro 3489 rc_echo " Setting up plugin '${cfg_plugins_plugin}' ..."
51 niro 2779 ${ALX_PLUGINS}/${cfg_plugins_plugin}/plugin.sh setup
52     fi
53 niro 2747 done
54    
55     # uninstall
56 niro 2776 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 niro 3489 rc_echo " Uninstalling plugin '${plugin}' ..."
78 niro 2776 ${ALX_PLUGINS}/${plugin}/plugin.sh uninstall
79     rm -f ${SETTINGSPATH}/plugins/${plugin}
80     fi
81     done
82     fi
83 niro 2747 }