Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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