This repository has been archived by the owner on Jun 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jailfile
67 lines (56 loc) · 1.54 KB
/
Jailfile
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
set -e
# Install the dependencies.
install_jim_tcl_build_deps() {
ASSUME_ALWAYS_YES=yes pkg install git pkgconf sqlite3
}
# Compile Jim Tcl with SQLite support and install it.
install_jim_tcl() {
cd "$TEMP"
git clone https://github.com/msteveb/jimtcl.git
cd jimtcl
git checkout --detach 0.77
./configure \
--with-ext="oo tree binary sqlite3" \
--enable-utf8 \
--ipv6 \
--disable-docs
make
make install
}
# Create a service that runs the jimhttp example.
make_rc_file() {
rc_file="$1"
jimhttp_file="$2"
filename="$(basename "$rc_file")"
mkdir -p "$(dirname "$rc_file")"
cat > "$rc_file" <<END
#! /bin/sh
# PROVIDE: $filename
# REQUIRE: NETWORKING
# KEYWORD: shutdown
. /etc/rc.subr
name="$filename"
rcvar="${filename}_enable"
procname=daemon
pidfile="/var/run/${filename}_pid"
command="/usr/local/bin/jimsh"
command_args="-e 'cd [file dirname {$jimhttp_file}]; source {$jimhttp_file}' -p '$PORT'"
start_cmd="/usr/sbin/daemon -r -u app -P '\$pidfile' \$command \$command_args 2>&1 >> /var/log/${filename}.log"
load_rc_config \$name
run_rc_command "\$1"
END
chmod +x "$rc_file"
}
main() {
install_jim_tcl_build_deps
install_jim_tcl
make_rc_file /usr/local/etc/rc.d/jimhttp_example /app/vendor/jimhttp/example.tcl
echo 'jimhttp_example_enable="YES"' >> /etc/rc.conf
pw user add app
chown -R app:app /app/
service jimhttp_example start
}
if [ "$(echo "$IMPORT_ONLY" | tr YES yes)" != "yes" ] && [ "$IMPORT_ONLY" != 1 ]
then
main
fi