-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvncterm
executable file
·60 lines (51 loc) · 1.56 KB
/
vncterm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/local/bin/cbsd
#v12.1.1
MYARG="jname mode"
MYOPTARG="addr vm_port command password"
MYDESC="Run VNC server for jail"
ADDHELP="mode=run, stop, status\n\
addr= IP address for listen, default - nodeip\n\
vm_port= PORT for listen, default - 0 \(auto\)\n\
command= run comman on start, default: /bin/csh\n\
password= set password\n"
. ${subrdir}/nc.subr
. ${subrdir}/system.subr
. ${subrdir}/tools.subr
. ${subrdir}/strings.subr
. ${cbsdinit}
. ${subrdir}/rcconf.subr
[ $? -eq 1 ] && err 1 "${N1_COLOR}No such jail: ${N2_COLOR}${jname}${N0_COLOR}"
[ ${jid} -eq 0 ] && err 1 "${N1_COLOR}Not running${N0_COLOR}"
cbsdvnc="${distmoduledir}/vncterm.d/cbsdvnc"
[ ! -x "${cbsdvnc}" ] && err 1 "${N1_COLOR}No cbsdvnc, please do: ${N2_COLOR}make -C ${distmoduledir}/vncterm.d${N0_COLOR}"
vnc_port="${jailsysdir}/${jname}/vnc_port"
vnc_lockfile="/tmp/cbsd-vnc-${jname}.lock"
vnc_pidfile="/tmp/cbsd-vnc-${jname}.pid"
case "${mode}" in
run)
if [ -r "${vncstat}" ]; then
${ECHO} "${N1_COLOR}Already active: ${N0_COLOR}"
${CAT_CMD} ${vncstat}
exit 0
fi
;;
status)
if [ -f ${vnc_lockfile} ]; then
_pid=0
if [ -r ${vncport} ]; then
_vncport=$( ${CAT_CMD} ${vnc_port} )
else
_vncport="Unknown"
fi
[ -f ${vnc_pidfile} ] && _pid=$( ${CAT_CMD} ${vnc_pidfile} )
${ECHO} "${N1_COLOR}VNC enabled with pid: ${N2_COLOR}${_pid}${N0_COLOR}"
${ECHO} "${N1_COLOR}Port: ${N2_COLOR}${_vncport}${N0_COLOR}"
else
${ECHO} "${N1_COLOR}VNC not active${N0_COLOR}"
fi
exit 0
;;
stop)
vncterm-daemon jname=${jname} mode=stop
esac
exec daemon cbsd vncterm-daemon $*