Skip to content

Instantly share code, notes, and snippets.

@taskie
Created December 23, 2015 20:15
Show Gist options
  • Save taskie/82373abc05c17a09cd8d to your computer and use it in GitHub Desktop.
Save taskie/82373abc05c17a09cd8d to your computer and use it in GitHub Desktop.
#!/bin/bash
status () {
cd .vnc
local pidfile=$(hostname):1.pid
if [[ -f $pidfile ]]; then
local pid=$(cat $pidfile)
echo PID: $pid
if kill -0 $pid; then
echo "running"
else
echo "already killed"
exit 1
fi
else
echo "no pid file"
exit 1
fi
}
start () {
LC_ALL=ja_JP.UTF-8 TMUX='' vncserver :1 -geometry 1024x768 # -depth 16
}
stop () {
vncserver -kill :1
}
restart () {
stop
start
}
use () {
cd .vnc
local conffile=xstartup.$1
if [[ -f $conffile ]]; then
ln -sf $conffile xstartup
else
echo echo error: \'$conffile\' not found
exit 1
fi
}
help () {
echo usage: $0 status/start/stop/restart/use/help
}
case $1 in
status) status ;;
start) start ;;
stop) stop ;;
restart) restart ;;
use) use $2 ;;
help) help ;;
*) help ; exit 1 ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment