Annotation of /mcore-src/trunk/mcore-tools/src/modules/rdesktop/rdesktop-session.in
Parent Directory | Revision Log
Revision 2897 -
(hide annotations)
(download)
Mon Sep 11 09:45:25 2023 UTC (9 months ago) by niro
File size: 3755 byte(s)
Mon Sep 11 09:45:25 2023 UTC (9 months ago) by niro
File size: 3755 byte(s)
-rdesktop-session: always accept cressp certificates
1 | niro | 2726 | #!/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 | niro | 2892 | load_classes client |
14 | |||
15 | niro | 2726 | # 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 | niro | 2738 | --shell) shift; shell="$1" ;; |
27 | niro | 2726 | --autostart) shift; autostart="$1" ;; |
28 | niro | 2752 | --keymap) shift; keymap="$1" ;; |
29 | niro | 2726 | esac |
30 | shift | ||
31 | done | ||
32 | |||
33 | cmdline="" | ||
34 | [[ -n ${method} ]] || die "No method given" | ||
35 | [[ -n ${autostart} ]] || autostart=0 | ||
36 | niro | 2752 | [[ -n ${keymap} ]] || keymap="de" |
37 | niro | 2738 | [[ ${shell} = NULL ]] && shell="" |
38 | [[ ${user} = NULL ]] && user="" | ||
39 | [[ ${domain} = NULL ]] && domain="" | ||
40 | [[ ${password} = NULL ]] && password="" | ||
41 | niro | 2726 | |
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 | niro | 2752 | [[ -n ${keymap} ]] && cmdline+=" -k '${keymap}'" |
65 | niro | 2726 | |
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 | niro | 2897 | # always accept credssp certificates |
85 | addconfig "echo yes | rdesktop ${cmdline} '${server}'" | ||
86 | niro | 2726 | chmod +x "${rdesktop_starter}" |
87 | |||
88 | if is_provided fluxbox | ||
89 | then | ||
90 | # generate fluxbox menu entry | ||
91 | ${MCORE_LIBDIR}/fluxbox-menuitem --add --name "${name}" --exec "${rdesktop_starter}" && | ||
92 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu | ||
93 | # add autostart | ||
94 | if [[ ${autostart} = 1 ]] | ||
95 | then | ||
96 | ${MCORE_LIBDIR}/fluxbox-autostart --add --name "${name}" --exec "${rdesktop_starter}" && | ||
97 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart | ||
98 | fi | ||
99 | fi | ||
100 | if is_provided idesk | ||
101 | then | ||
102 | # generate idesk desktop icon | ||
103 | ${MCORE_LIBDIR}/idesk-generate-icon-info --add --name "${name}" --command "${rdesktop_starter}" --icon rdp.png && | ||
104 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons | ||
105 | fi | ||
106 | ;; | ||
107 | |||
108 | del) | ||
109 | [[ -n ${name} ]] || die "No name given" | ||
110 | if [ -f ${MROOT}/${RDESKTOP_SESSIONDIR}/"${name}".sh ] | ||
111 | then | ||
112 | rm ${MROOT}/${RDESKTOP_SESSIONDIR}/"${name}".sh | ||
113 | if is_provided fluxbox | ||
114 | then | ||
115 | ${MCORE_LIBDIR}/fluxbox-menuitem --del --name "${name}" && | ||
116 | ${MCORE_LIBDIR}/fluxbox-rebuild-menu | ||
117 | ${MCORE_LIBDIR}/fluxbox-autostart --del --name "${name}" && | ||
118 | ${MCORE_LIBDIR}/fluxbox-rebuild-autostart | ||
119 | fi | ||
120 | if is_provided idesk | ||
121 | then | ||
122 | ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" && | ||
123 | ${MCORE_LIBDIR}/idesk-generate-all-desktop-icons | ||
124 | fi | ||
125 | else | ||
126 | eecho "No configured session named '${name}' exists." | ||
127 | fi | ||
128 | ;; | ||
129 | |||
130 | print) | ||
131 | list_files_in_directory ${MROOT}/${RDESKTOP_SESSIONDIR} | sed 's:\.sh::g' | ||
132 | ;; | ||
133 | esac |