Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2779 - (hide 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: 1656 byte(s)
-added plugin setup functionality to honor any settings change of a plugin via the webfrontend on every boot
1 niro 2749 # this script gets included by config_sessions
2    
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     install_plugin()
12     {
13     if [[ -z $(magequery -n remserial) ]]
14     then
15     MAGE_BOOTSTRAP=true mage install remserial
16     mage clean
17     fi
18 niro 2779 }
19 niro 2749
20 niro 2779 setup_plugin()
21     {
22 niro 2749 # setup config
23     [[ ! -d /etc/conf.d ]] && install /etc/conf.d
24     :> /etc/conf.d/remserial
25     echo 'REMOTE_HOST="128.20.1.52"' >> /etc/conf.d/remserial
26     echo 'REMOTE_PORT="3302"' >> /etc/conf.d/remserial
27     echo 'STTY_OPTS="9600 raw"' >> /etc/conf.d/remserial
28     echo 'DEVICE="/dev/ttyS0"' >> /etc/conf.d/remserial
29     echo 'EXTRA_OPTS="-x0"' >> /etc/conf.d/remserial
30    
31     # add to runlevels
32     rc-config add remserial
33     }
34    
35     # create desktop buttons
36     create_menuitem()
37     {
38     # don't touch these echo, define variables above
39     echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\""
40     echo "PLUGIN_MENUITEM_EXEC=\"${PLUGIN_MENUITEM_EXEC}\""
41     echo "PLUGIN_MENUITEM_PARAM=\"${PLUGIN_MENUITEM_PARAM}\""
42     echo "PLUGIN_MENUITEM_WORKDIR=\"${PLUGIN_MENUITEM_WORKDIR}\""
43     echo "PLUGIN_MENUITEM_ICON=\"${PLUGIN_MENUITEM_ICON}\""
44     }
45    
46     uninstall_plugin()
47     {
48     # remove from runlevels
49     rc-config del remserial
50    
51     if [[ -n $(magequery -n remserial) ]]
52     then
53     MAGE_BOOTSTRAP=true mage uninstall remserial
54     mage clean
55     fi
56    
57     # remove config files
58     if [[ -f /etc/conf.d/remserial ]]
59     then
60     rm -f /etc/conf.d/remserial
61     fi
62     }
63    
64     case $1 in
65     install) install_plugin ;;
66 niro 2779 setup) setup_plugin ;;
67 niro 2749 menuitem) create_menuitem ;;
68     uninstall) uninstall_plugin ;;
69     *) echo "PLUGIN '${PLUGIN_NAME}': unkown operation '$1'" ;;
70     esac