Contents of /mcore-src/trunk/mcore-tools/src/modules/rdesktop/rdesktop-session.in
Parent Directory | Revision Log
Revision 2892 -
(show annotations)
(download)
Fri Aug 14 11:44:52 2020 UTC (3 years, 8 months ago) by niro
File size: 3705 byte(s)
Fri Aug 14 11:44:52 2020 UTC (3 years, 8 months ago) by niro
File size: 3705 byte(s)
-load all provides to honor is_provided()
1 | #!/bin/bash |
2 | |
3 | MCORE_LIBDIR="@@MCORE_LIBDIR@@" |
4 | source @@SYSCONFDIR@@/mcore/mcore.conf |
5 | source ${MCORE_LIBDIR}/include/common.global.class |
6 | source ${MCORE_LIBDIR}/include/daemon.global.class |
7 | |
8 | RDESKTOP_SESSIONDIR="${MCORE_CONFIG_PATH}/rdesktop/sessions" |
9 | RDESKTOP_CONFIGDIR="${MCORE_CONFIG_PATH}/rdesktop/config.d" |
10 | |
11 | die() { echo "ERROR: $@"; exit 1; } |
12 | |
13 | load_classes client |
14 | |
15 | # very basic getops |
16 | for argv in $* |
17 | do |
18 | case $1 in |
19 | --add|--del|--print) method="${1//--}" ;; |
20 | --name) shift; name="$1" ;; |
21 | --server) shift; server="$1" ;; |
22 | --mode) shift; mode="$1" ;; |
23 | --user) shift; user="$1" ;; |
24 | --domain) shift; domain="$1" ;; |
25 | --password) shift; password="$1" ;; |
26 | --shell) shift; shell="$1" ;; |
27 | --autostart) shift; autostart="$1" ;; |
28 | --keymap) shift; keymap="$1" ;; |
29 | esac |
30 | shift |
31 | done |
32 | |
33 | cmdline="" |
34 | [[ -n ${method} ]] || die "No method given" |
35 | [[ -n ${autostart} ]] || autostart=0 |
36 | [[ -n ${keymap} ]] || keymap="de" |
37 | [[ ${shell} = NULL ]] && shell="" |
38 | [[ ${user} = NULL ]] && user="" |
39 | [[ ${domain} = NULL ]] && domain="" |
40 | [[ ${password} = NULL ]] && password="" |
41 | |
42 | [[ -d ${RDESKTOP_SESSIONDIR} ]] || install -d ${RDESKTOP_SESSIONDIR} |
43 | [[ -d ${RDESKTOP_CONFIGDIR} ]] || install -d ${RDESKTOP_CONFIGDIR} |
44 | |
45 | case "${method}" in |
46 | add) |
47 | # requires name |
48 | [[ -n ${name} ]] || die "No name given" |
49 | # and session |
50 | [[ -n ${server} ]] || die "No server given" |
51 | |
52 | # other sanity checks |
53 | case "${mode}" in |
54 | fullscreen) cmdline+=" -f" ;; |
55 | *x*) cmdline+=" -g '${mode}'" ;; |
56 | *) die "unknown mode '${mode}'" |
57 | esac |
58 | |
59 | # optional |
60 | [[ -n ${user} ]] && cmdline+=" -u '${user}'" |
61 | [[ -n ${password} ]] && cmdline+=" -p '${password}'" |
62 | [[ -n ${domain} ]] && cmdline+=" -d '${domain}'" |
63 | [[ -n ${shell} ]] && cmdline+=" -s '${shell}'" |
64 | [[ -n ${keymap} ]] && cmdline+=" -k '${keymap}'" |
65 | |
66 | # load all global_options |
67 | global_options="" |
68 | for conf in $(find ${RDESKTOP_CONFIGDIR} -name \*.conf) |
69 | do |
70 | if [[ -f ${conf} ]] |
71 | then |
72 | decho "including options from '${conf}'" |
73 | source ${conf} |
74 | fi |
75 | done |
76 | decho "global_options='${global_options}'" |
77 | [[ -n ${global_options} ]] && cmdline+=" ${global_options}" |
78 | |
79 | rdesktop_starter="${RDESKTOP_SESSIONDIR}/${name}.sh" |
80 | CONFIG="${MROOT}/${rdesktop_starter}" |
81 | clearconfig |
82 | |
83 | addconfig '#!/bin/bash' |
84 | addconfig "rdesktop ${cmdline} '${server}'" |
85 | chmod +x "${rdesktop_starter}" |
86 | |
87 | if is_provided fluxbox |
88 | then |
89 | # generate fluxbox menu entry |
90 | ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${rdesktop_starter}" && |
91 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
92 | # add autostart |
93 | if [[ ${autostart} = 1 ]] |
94 | then |
95 | ${MCORE_LIBDIR}/fluxbox-autostart --add --name "${name}" --exec "${rdesktop_starter}" && |
96 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart |
97 | fi |
98 | fi |
99 | if is_provided idesk |
100 | then |
101 | # generate idesk desktop icon |
102 | ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${rdesktop_starter}" --icon rdp.png && |
103 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
104 | fi |
105 | ;; |
106 | |
107 | del) |
108 | [[ -n ${name} ]] || die "No name given" |
109 | if [ -f ${MROOT}/${RDESKTOP_SESSIONDIR}/"${name}".sh ] |
110 | then |
111 | rm ${MROOT}/${RDESKTOP_SESSIONDIR}/"${name}".sh |
112 | if is_provided fluxbox |
113 | then |
114 | ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && |
115 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu |
116 | ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" && |
117 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart |
118 | fi |
119 | if is_provided idesk |
120 | then |
121 | ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" && |
122 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons |
123 | fi |
124 | else |
125 | eecho "No configured session named '${name}' exists." |
126 | fi |
127 | ;; |
128 | |
129 | print) |
130 | list_files_in_directory ${MROOT}/${RDESKTOP_SESSIONDIR} | sed 's:\.sh::g' |
131 | ;; |
132 | esac |