Annotation of /alx-src/branches/alxconf-060/plugins/usbip/plugin.sh
Parent Directory | Revision Log
Revision 3523 -
(hide annotations)
(download)
(as text)
Mon Apr 23 07:30:59 2012 UTC (12 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 2313 byte(s)
Mon Apr 23 07:30:59 2012 UTC (12 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 2313 byte(s)
-configure plugins via sql database
1 | niro | 3392 | # this script gets included by config_sessions |
2 | |||
3 | PLUGIN_NAME="usbip" | ||
4 | PLUGIN_MENUITEM_NAME="" | ||
5 | PLUGIN_MENUITEM_EXEC="" | ||
6 | PLUGIN_MENUITEM_PARAM="" | ||
7 | PLUGIN_MENUITEM_WORKDIR="" | ||
8 | PLUGIN_MENUITEM_ICON="" | ||
9 | |||
10 | niro | 3503 | PLUGIN_AUTOSTART=0 |
11 | |||
12 | niro | 3392 | PLUGIN_PACKAGES="sysfsutils usbip" |
13 | |||
14 | niro | 3523 | # include alx functions |
15 | source /etc/alxconfig-ng/config.rc | ||
16 | source /etc/alxconfig-ng/serial | ||
17 | source ${ALX_FUNCTIONS}/common | ||
18 | source ${ALX_FUNCTIONS}/mysqlfunctions | ||
19 | # missing colors | ||
20 | COLRED="\033[1;6m\033[31m" | ||
21 | COLDEFAULT="\033[0m" | ||
22 | |||
23 | die() | ||
24 | { | ||
25 | echo "Error: $@" | ||
26 | echo -e "${COLRED}Plugin \"${PLUGIN_NAME}\" will be disabled.${COLDEFAULT}" | ||
27 | # disable services | ||
28 | rc-config del usbipd > /dev/null | ||
29 | rc-config del usbipdevd > /dev/null | ||
30 | exit 1 | ||
31 | } | ||
32 | |||
33 | niro | 3392 | install_plugin() |
34 | { | ||
35 | local i | ||
36 | for i in ${PLUGIN_PACKAGES} | ||
37 | do | ||
38 | if [[ -z $(magequery -n ${i}) ]] | ||
39 | then | ||
40 | MAGE_BOOTSTRAP=true mage install ${i} | ||
41 | mage clean | ||
42 | fi | ||
43 | done | ||
44 | } | ||
45 | |||
46 | setup_plugin() | ||
47 | { | ||
48 | niro | 3523 | evaluate_table plugin_usbip |
49 | |||
50 | # sanitize variables | ||
51 | [[ -z ${plugin_usbip_device_id} ]] && die "device_id variable is empty" | ||
52 | [[ -z ${plugin_usbip_polling_time} ]] && die "polling_time variable is empty" | ||
53 | |||
54 | [[ ! -d /etc/conf.d ]] && install /etc/conf.d | ||
55 | local CONFIG="/etc/conf.d/usbipdevd" | ||
56 | addconfig "USBIP_DEVICE_ID=\"${plugin_usbip_device_id}\"" | ||
57 | addconfig "USBIP_POLLING_TIME=\"${plugin_usbip_polling_time}\"" | ||
58 | |||
59 | # add to runlevels | ||
60 | rc-config add usbipd > /dev/null | ||
61 | rc-config add usbipdevd > /dev/null | ||
62 | niro | 3392 | } |
63 | |||
64 | # create desktop buttons | ||
65 | create_menuitem() | ||
66 | { | ||
67 | # don't touch these echo, define variables above | ||
68 | echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\"" | ||
69 | echo "PLUGIN_MENUITEM_EXEC=\"${PLUGIN_MENUITEM_EXEC}\"" | ||
70 | echo "PLUGIN_MENUITEM_PARAM=\"${PLUGIN_MENUITEM_PARAM}\"" | ||
71 | echo "PLUGIN_MENUITEM_WORKDIR=\"${PLUGIN_MENUITEM_WORKDIR}\"" | ||
72 | echo "PLUGIN_MENUITEM_ICON=\"${PLUGIN_MENUITEM_ICON}\"" | ||
73 | } | ||
74 | |||
75 | niro | 3503 | autostart_plugin() |
76 | { | ||
77 | echo "PLUGIN_AUTOSTART=\"${PLUGIN_AUTOSTART}\"" | ||
78 | niro | 3504 | echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\"" |
79 | niro | 3503 | } |
80 | |||
81 | niro | 3392 | uninstall_plugin() |
82 | { | ||
83 | local i | ||
84 | for i in ${PLUGIN_PACKAGES} | ||
85 | do | ||
86 | if [[ -n $(magequery -n ${i}) ]] | ||
87 | then | ||
88 | MAGE_BOOTSTRAP=true mage uninstall ${i} | ||
89 | mage clean | ||
90 | fi | ||
91 | done | ||
92 | |||
93 | mage clean | ||
94 | } | ||
95 | |||
96 | case $1 in | ||
97 | install) install_plugin ;; | ||
98 | setup) setup_plugin ;; | ||
99 | menuitem) create_menuitem ;; | ||
100 | niro | 3503 | autostart) autostart_plugin ;; |
101 | niro | 3392 | uninstall) uninstall_plugin ;; |
102 | *) echo "PLUGIN '${PLUGIN_NAME}': unkown operation '$1'" ;; | ||
103 | esac |