Annotation of /alx-src/branches/alxconf-060/plugins/rdesktop/plugin.sh
Parent Directory | Revision Log
Revision 5890 -
(hide annotations)
(download)
(as text)
Fri Nov 28 12:12:48 2014 UTC (9 years, 6 months ago) by niro
File MIME type: application/x-sh
File size: 4266 byte(s)
Fri Nov 28 12:12:48 2014 UTC (9 years, 6 months ago) by niro
File MIME type: application/x-sh
File size: 4266 byte(s)
-added alsa-lib to plugin_packages
1 | niro | 3391 | # this script gets included by config_sessions |
2 | |||
3 | PLUGIN_NAME="rdesktop" | ||
4 | niro | 3523 | PLUGIN_MENUITEM_NAME="${PLUGIN_NAME}" |
5 | PLUGIN_MENUITEM_EXEC="${PLUGIN_NAME}" | ||
6 | niro | 3391 | PLUGIN_MENUITEM_PARAM="" |
7 | PLUGIN_MENUITEM_WORKDIR="" | ||
8 | PLUGIN_MENUITEM_ICON="" | ||
9 | |||
10 | niro | 3503 | PLUGIN_AUTOSTART=0 |
11 | niro | 5890 | PLUGIN_PACKAGES="openssl alsa-lib rdesktop" |
12 | niro | 3523 | PLUGIN_CONFIG="/etc/alxconfig-ng/plugin-${PLUGIN_NAME}.conf" |
13 | niro | 3391 | |
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 | [ -f ${PLUGIN_CONFIG} ] && rm ${PLUGIN_CONFIG} | ||
28 | exit 1 | ||
29 | } | ||
30 | |||
31 | niro | 3391 | install_plugin() |
32 | { | ||
33 | local i | ||
34 | for i in ${PLUGIN_PACKAGES} | ||
35 | do | ||
36 | if [[ -z $(magequery -n ${i}) ]] | ||
37 | then | ||
38 | MAGE_BOOTSTRAP=true mage install ${i} | ||
39 | mage clean | ||
40 | fi | ||
41 | done | ||
42 | } | ||
43 | |||
44 | setup_plugin() | ||
45 | { | ||
46 | niro | 3523 | local CONFIG |
47 | local opts | ||
48 | |||
49 | evaluate_table plugin_rdesktop | ||
50 | # sanitize variables | ||
51 | opts="" | ||
52 | if [[ -z ${plugin_rdesktop_session_name} ]] | ||
53 | niro | 3492 | then |
54 | niro | 3523 | die "session_name variable is missing" |
55 | niro | 3492 | fi |
56 | niro | 3523 | if [[ -z ${plugin_rdesktop_server} ]] |
57 | then | ||
58 | die "server variable is missing" | ||
59 | fi | ||
60 | if [[ -z ${plugin_rdesktop_username} ]] | ||
61 | then | ||
62 | plugin_rdesktop_username="" | ||
63 | else | ||
64 | opts+=" -u '${plugin_rdesktop_username}'" | ||
65 | fi | ||
66 | if [[ -z ${plugin_rdesktop_password} ]] | ||
67 | then | ||
68 | plugin_rdesktop_password="" | ||
69 | else | ||
70 | opts+=" -p '${plugin_rdesktop_password}'" | ||
71 | fi | ||
72 | if [[ -z ${plugin_rdesktop_domain} ]] | ||
73 | then | ||
74 | plugin_rdesktop_domain="" | ||
75 | else | ||
76 | opts+=" -d '${plugin_rdesktop_domain}'" | ||
77 | fi | ||
78 | if [[ -z ${plugin_rdesktop_resolution} ]] | ||
79 | then | ||
80 | die "resolution is missing" | ||
81 | else | ||
82 | case ${plugin_rdesktop_resolution} in | ||
83 | fullscreen) opts+=" -f" ;; | ||
84 | seamless) opts+=" -A" ;; | ||
85 | *) opts+=" -g '${plugin_rdesktop_resolution}'" ;; | ||
86 | esac | ||
87 | fi | ||
88 | if [[ -z ${plugin_rdesktop_keyboard} ]] | ||
89 | then | ||
90 | plugin_rdesktop_keyboard="" | ||
91 | else | ||
92 | opts+=" -k '${plugin_rdesktop_keyboard}'" | ||
93 | fi | ||
94 | if [[ -z ${plugin_rdesktop_shell} ]] | ||
95 | then | ||
96 | plugin_rdesktop_shell="" | ||
97 | else | ||
98 | opts+=" -s '${plugin_rdesktop_shell}'" | ||
99 | fi | ||
100 | if [[ -z ${plugin_rdesktop_runpath} ]] | ||
101 | then | ||
102 | plugin_rdesktop_runpath="" | ||
103 | else | ||
104 | opts+=" -c '${plugin_rdesktop_runpath}'" | ||
105 | fi | ||
106 | niro | 3492 | |
107 | niro | 3523 | CONFIG="${PLUGIN_CONFIG}" |
108 | clearconfig | ||
109 | addconfig "PLUGIN_CONFIG_SESSION_NAME=\"${plugin_rdesktop_session_name}\"" | ||
110 | addconfig "PLUGIN_CONFIG_SERVER=\"${plugin_rdesktop_server}\"" | ||
111 | addconfig "PLUGIN_CONFIG_PARAM=\"${opts}\"" | ||
112 | niro | 3391 | } |
113 | |||
114 | # create desktop buttons | ||
115 | create_menuitem() | ||
116 | { | ||
117 | niro | 3523 | if [ -f ${PLUGIN_CONFIG} ] |
118 | niro | 3492 | then |
119 | niro | 3523 | source ${PLUGIN_CONFIG} |
120 | niro | 3492 | fi |
121 | [[ -z ${PLUGIN_CONFIG_PARAM} ]] && PLUGIN_CONFIG_PARAM="" | ||
122 | [[ -z ${PLUGIN_CONFIG_SERVER} ]] && PLUGIN_CONFIG_SERVER="" | ||
123 | |||
124 | niro | 3523 | # no menuentries if egk_scm plugin is installed, this one will be used instead then |
125 | if [ -f ${SETTINGSPATH}/plugins/egk_scm ] | ||
126 | then | ||
127 | PLUGIN_MENUITEM_NAME="" | ||
128 | PLUGIN_MENUITEM_EXEC="" | ||
129 | PLUGIN_MENUITEM_PARAM="" | ||
130 | PLUGIN_MENUITEM_WORKDIR="" | ||
131 | PLUGIN_MENUITEM_ICON="" | ||
132 | else | ||
133 | if [[ ! -z ${PLUGIN_CONFIG_SESSION_NAME} ]] | ||
134 | then | ||
135 | PLUGIN_MENUITEM_NAME="${PLUGIN_CONFIG_SESSION_NAME}" | ||
136 | fi | ||
137 | fi | ||
138 | |||
139 | niro | 3391 | # don't touch these echo, define variables above |
140 | echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\"" | ||
141 | echo "PLUGIN_MENUITEM_EXEC=\"${PLUGIN_MENUITEM_EXEC}\"" | ||
142 | niro | 3492 | echo "PLUGIN_MENUITEM_PARAM=\"${PLUGIN_CONFIG_PARAM} ${PLUGIN_MENUITEM_PARAM} ${PLUGIN_CONFIG_SERVER}\"" |
143 | niro | 3391 | echo "PLUGIN_MENUITEM_WORKDIR=\"${PLUGIN_MENUITEM_WORKDIR}\"" |
144 | echo "PLUGIN_MENUITEM_ICON=\"${PLUGIN_MENUITEM_ICON}\"" | ||
145 | } | ||
146 | |||
147 | niro | 3503 | autostart_plugin() |
148 | { | ||
149 | niro | 3523 | # only autostart if plugin config was found |
150 | if [ -f ${PLUGIN_CONFIG} ] | ||
151 | then | ||
152 | evaluate_table plugin_rdesktop | ||
153 | fi | ||
154 | # sanitize variables | ||
155 | [[ -z ${plugin_rdesktop_autostart} ]] && plugin_rdesktop_autostart=0 | ||
156 | |||
157 | echo "PLUGIN_AUTOSTART=\"${plugin_rdesktop_autostart}\"" | ||
158 | niro | 3504 | echo "PLUGIN_MENUITEM_NAME=\"${PLUGIN_MENUITEM_NAME}\"" |
159 | niro | 3503 | } |
160 | |||
161 | niro | 3391 | uninstall_plugin() |
162 | { | ||
163 | niro | 3523 | [ -f ${PLUGIN_CONFIG} ] && rm ${PLUGIN_CONFIG} |
164 | |||
165 | niro | 3391 | local i |
166 | for i in ${PLUGIN_PACKAGES} | ||
167 | do | ||
168 | if [[ -n $(magequery -n ${i}) ]] | ||
169 | then | ||
170 | MAGE_BOOTSTRAP=true mage uninstall ${i} | ||
171 | mage clean | ||
172 | fi | ||
173 | done | ||
174 | |||
175 | mage clean | ||
176 | } | ||
177 | |||
178 | case $1 in | ||
179 | install) install_plugin ;; | ||
180 | setup) setup_plugin ;; | ||
181 | menuitem) create_menuitem ;; | ||
182 | uninstall) uninstall_plugin ;; | ||
183 | niro | 3503 | autostart) autostart_plugin ;; |
184 | niro | 3391 | *) echo "PLUGIN '${PLUGIN_NAME}': unkown operation '$1'" ;; |
185 | esac |