forked from ahurac/dotfiles
34 lines
469 B
Text
34 lines
469 B
Text
|
#!/bin/bash
|
||
|
|
||
|
# Variables
|
||
|
declare -a vncctl
|
||
|
systemctl=systemctl
|
||
|
systemd_unit=vncserver
|
||
|
verb="${1:-status}"; shift
|
||
|
display="${1:-1}" ; shift
|
||
|
|
||
|
# Prepending sudo if necessary
|
||
|
case "$verb" in
|
||
|
start|restart|stop)
|
||
|
sudo=sudo
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
# Command building
|
||
|
[[ -n $sudo ]] && vncctl+=("$sudo")
|
||
|
vncctl+=(
|
||
|
"$systemctl"
|
||
|
"$@"
|
||
|
"$verb"
|
||
|
"${systemd_unit}@:${display}"
|
||
|
)
|
||
|
|
||
|
# Debug
|
||
|
#echo "${vncctl[@]}"
|
||
|
#exit 0
|
||
|
|
||
|
# Command execution
|
||
|
set -xe
|
||
|
"${vncctl[@]}"
|
||
|
|