-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttyjs
executable file
·81 lines (59 loc) · 1.85 KB
/
ttyjs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/local/bin/cbsd
#v10.1.0
MYARG="jname mode"
MYOPTARG="user password"
MYDESC="Launch tty.js in the jail"
ADDHELP="user= set auth user name\n\
password= set auth password name\n"
. ${subr}
. ${system}
. ${tools}
. ${strings}
init $*
. ${jrcconf}
[ $? -eq 1 ] && err 1 "${MAGENTA}No such jail: ${GREEN}${jname}${NORMAL}"
[ ${jid} -eq 0 ] && err 1 "${MAGENTA}Not running: ${GREEN}${jname}${NORMAL}"
my_module_dir="${moduledir}/ttyjs.d/root"
. ${workdir}/imghelper.subr
readconf helpers.conf
# todo
# reload only when changed
run()
{
local _srcjail_dir
[ $baserw -eq 1 ] && path="${data}"
[ -z "${path}" ] && err 1 "No path variable"
[ ! -f ${moduledir}/ttyjs.d/root/node_modules/tty.js/index.js ] && err 1 "No such ${moduledir}/ttyjs.d/root/node_modules/tty.js/index.js"
_jaildata="${jaildatadir}/ttyjs1-${jaildatapref}/usr/local"
[ ! -f "${_jaildata}/bin/node" ] && err 1 "No such node in ${_jaildata}/bin"
[ ! -d "${path}/tmp/ttyjs" ] && /bin/mkdir -p ${path}/tmp/ttyjs
[ ! -d "${_jaildata}/root" ] && /bin/mkdir -p ${_jaildata}/root
if ! is_mounted ${path}/tmp/ttyjs; then
/sbin/mount -t nullfs -o ro ${_jaildata} ${path}/tmp/ttyjs
[ $? -ne 0 ] && err 1 "Error mount ${_jaildata} to /tmp/ttyjs inside jail"
fi
[ ! -d "${_jaildata}/root" ] && /bin/mkdir -p ${_jaildata}/root
if ! is_mounted ${path}/tmp/ttyjs/root; then
/sbin/mount -t nullfs -o ro ${moduledir}/ttyjs.d/root ${path}/tmp/ttyjs/root
if [ $? -ne 0 ]; then
/sbin/umount ${path}/tmp/ttyjs > /dev/null 2>&1
err 1 "Error mount ${moduledir}/ttyjs.d/ttyjs/root to /tmp/ttyjs inside jail"
fi
fi
${ECHO} "${MAGENTA}ttyjs in progress: ${GREEN}jexec for /tmp/ttyjs${NORMAL}"
# echo "jexec jname=${jname} /tmp/ttyjs/etc/ttyjs/ttyjscbsd /tmp/${helpername}.pp"
jexec jname=${jname} /tmp/ttyjs/root/run
}
stop()
{
}
case "${mode}" in
run)
run
;;
stop)
stop
;;
*)
;;
esac