mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-06-25 04:01:30 +02:00
Easy start script: refactor and correct option processing
This commit is contained in:
parent
26cc3845b0
commit
892c285963
@ -8,6 +8,8 @@ cert_group=ssl-cert
|
|||||||
xstartup_script=~/.vnc/xstartup
|
xstartup_script=~/.vnc/xstartup
|
||||||
de_was_selected_file="$HOME/.vnc/.kasmvncserver-easy-start-de-was-selected"
|
de_was_selected_file="$HOME/.vnc/.kasmvncserver-easy-start-de-was-selected"
|
||||||
|
|
||||||
|
action=start
|
||||||
|
|
||||||
manual_xstartup_choice="Manually edit xstartup"
|
manual_xstartup_choice="Manually edit xstartup"
|
||||||
declare -A all_desktop_environments=(
|
declare -A all_desktop_environments=(
|
||||||
[Cinnamon]=cinnamon-session
|
[Cinnamon]=cinnamon-session
|
||||||
@ -122,25 +124,47 @@ SCRIPT
|
|||||||
chmod +x "$xstartup_script"
|
chmod +x "$xstartup_script"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$1" = "--help" ]]; then
|
enable_debug() {
|
||||||
cat >&2 <<-USAGE
|
|
||||||
Usage: `basename $0` [options]
|
|
||||||
-d Debug output
|
|
||||||
-kill Kill vncserver
|
|
||||||
--help show this help
|
|
||||||
USAGE
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$1" = "-d" ]]; then
|
|
||||||
debug=1
|
debug=1
|
||||||
log_option="-log *:stderr:100"
|
log_option="-log *:stderr:100"
|
||||||
fi
|
}
|
||||||
|
|
||||||
action=start
|
kill_vnc_server() {
|
||||||
if [[ "$1" = "-kill" ]]; then
|
vncserver -kill $display
|
||||||
action=kill
|
}
|
||||||
fi
|
|
||||||
|
process_cli_options() {
|
||||||
|
for option in "$@"; do
|
||||||
|
case "$option" in
|
||||||
|
--help)
|
||||||
|
show_help
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-d)
|
||||||
|
enable_debug
|
||||||
|
;;
|
||||||
|
-kill)
|
||||||
|
kill_vnc_server
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-select-de)
|
||||||
|
action=select-de-and-start
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
cat >&2 <<-USAGE
|
||||||
|
Usage: `basename $0` [options]
|
||||||
|
-d Debug output
|
||||||
|
-kill Kill vncserver
|
||||||
|
-select-de Select desktop environent to run
|
||||||
|
--help show this help
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
process_cli_options "$@"
|
||||||
|
|
||||||
if groups | grep -qvw ssl-cert; then
|
if groups | grep -qvw ssl-cert; then
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
@ -150,11 +174,6 @@ EOF
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$action" = "kill" ]]; then
|
|
||||||
vncserver -kill $display
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! de_was_selected; then
|
if ! de_was_selected; then
|
||||||
detect_desktop_environments
|
detect_desktop_environments
|
||||||
ask_user_to_choose_de
|
ask_user_to_choose_de
|
||||||
|
Loading…
x
Reference in New Issue
Block a user