Magellan Linux

Contents of /mcore-src/trunk/mcore-tools/src/modules/rdesktop/rdesktop-session.in

Parent Directory Parent Directory | Revision Log Revision Log


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