Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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