Magellan Linux

Annotation of /alx-src/branches/alxconf-060/plugins/remserial/plugin.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3523 - (hide annotations) (download) (as text)
Mon Apr 23 07:30:59 2012 UTC (12 years ago) by niro
File MIME type: application/x-sh
File size: 2787 byte(s)
-configure plugins via sql database
1 niro 3523 # this script gets called by config_sessions
2 niro 2749
3     PLUGIN_NAME="remserial"
4     # all empty - do not create any menuitems
5     PLUGIN_MENUITEM_NAME=""
6     PLUGIN_MENUITEM_EXEC=""
7     PLUGIN_MENUITEM_PARAM=""
8     PLUGIN_MENUITEM_WORKDIR=""
9     PLUGIN_MENUITEM_ICON=""
10    
11 niro 3503 PLUGIN_AUTOSTART=0
12    
13 niro 3523 # include alx functions
14     source /etc/alxconfig-ng/config.rc
15     source /etc/alxconfig-ng/serial
16     source ${ALX_FUNCTIONS}/common
17     source ${ALX_FUNCTIONS}/mysqlfunctions
18     # missing colors
19     COLRED="\033[1;6m\033[31m"
20     COLDEFAULT="\033[0m"
21    
22     die()
23     {
24     echo "Error: $@"
25     echo -e "${COLRED}Plugin \"${PLUGIN_NAME}\" will be disabled.${COLDEFAULT}"
26     # disable the service
27     rc-config del remserial > /dev/null
28     exit 1
29     }
30    
31 niro 2749 install_plugin()
32     {
33     if [[ -z $(magequery -n remserial) ]]
34     then
35     MAGE_BOOTSTRAP=true mage install remserial
36     mage clean
37     fi
38 niro 2779 }
39 niro 2749
40 niro 2779 setup_plugin()
41     {
42 niro 3523 local CONFIG
43    
44     # first of all get the vars
45     evaluate_table plugin_remserial
46    
47     # sanitize variables
48     [[ -z ${plugin_remserial_remote_host} ]] && die "remote_host variable is empty"
49     [[ -z ${plugin_remserial_remote_port} ]] && die "remote_port variable is empty"
50     [[ -z ${plugin_remserial_stty_opts} ]] && die "stty_opts variable is empty"
51     [[ -z ${plugin_remserial_device} ]] && die "device variable is empty"
52     # thats ok
53     [[ -z ${plugin_remserial_extra_opts} ]] && plugin_remserial_extra_opts=""
54    
55 niro 2749 # setup config
56     [[ ! -d /etc/conf.d ]] && install /etc/conf.d
57 niro 3523 CONFIG="/etc/conf.d/remserial"
58     clearconfig
59     addconfig "REMOTE_HOST=\"${plugin_remserial_remote_host}\""
60     addconfig "REMOTE_PORT=\"${plugin_remserial_remote_port}\""
61     addconfig "STTY_OPTS=\"${plugin_remserial_stty_opts}\""
62     addconfig "DEVICE=\"${plugin_remserial_device}\""
63     addconfig "EXTRA_OPTS=\"${plugin_remserial_extra_opts}\""
64 niro 2749
65     # add to runlevels
66 niro 3523 rc-config add remserial > /dev/null
67 niro 2749 }
68    
69     # create desktop buttons
70     create_menuitem()
71     {
72     # don't touch these echo, define variables above
73     echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\""
74     echo "PLUGIN_MENUITEM_EXEC=\"${PLUGIN_MENUITEM_EXEC}\""
75     echo "PLUGIN_MENUITEM_PARAM=\"${PLUGIN_MENUITEM_PARAM}\""
76     echo "PLUGIN_MENUITEM_WORKDIR=\"${PLUGIN_MENUITEM_WORKDIR}\""
77     echo "PLUGIN_MENUITEM_ICON=\"${PLUGIN_MENUITEM_ICON}\""
78     }
79    
80 niro 3503 autostart_plugin()
81     {
82     echo "PLUGIN_AUTOSTART=\"${PLUGIN_AUTOSTART}\""
83 niro 3504 echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\""
84 niro 3503 }
85    
86 niro 2749 uninstall_plugin()
87     {
88     # remove from runlevels
89     rc-config del remserial
90    
91     if [[ -n $(magequery -n remserial) ]]
92     then
93     MAGE_BOOTSTRAP=true mage uninstall remserial
94     mage clean
95     fi
96    
97     # remove config files
98     if [[ -f /etc/conf.d/remserial ]]
99     then
100     rm -f /etc/conf.d/remserial
101     fi
102     }
103    
104     case $1 in
105     install) install_plugin ;;
106 niro 2779 setup) setup_plugin ;;
107 niro 2749 menuitem) create_menuitem ;;
108     uninstall) uninstall_plugin ;;
109 niro 3503 autostart) autostart_plugin ;;
110 niro 2749 *) echo "PLUGIN '${PLUGIN_NAME}': unkown operation '$1'" ;;
111     esac