diff options
| author | dautor <karlo98.m@gmail.com> | 2024-11-15 13:47:50 +0100 |
|---|---|---|
| committer | dautor <karlo98.m@gmail.com> | 2024-11-16 14:25:00 +0100 |
| commit | bdd2396d19f5465ecaac3195deeceef29a867d52 (patch) | |
| tree | 2dbe4c83c833ef8b8bfe1473fda3a028136b4299 | |
Create example structure and add 2 examples
| -rw-r--r-- | cgit/description | 8 | ||||
| -rw-r--r-- | cgit/host/conf | 23 | ||||
| -rw-r--r-- | cgit/host/root/etc/rc.conf | 6 | ||||
| -rw-r--r-- | cgit/host/root/etc/resolv.conf | 1 | ||||
| -rw-r--r-- | cgit/host/root/usr/local/etc/cgitrc | 10 | ||||
| -rw-r--r-- | cgit/host/root/usr/local/etc/nginx/nginx.conf | 31 | ||||
| -rwxr-xr-x | cgit/start.sh | 11 | ||||
| -rwxr-xr-x | cgit/stop.sh | 7 | ||||
| -rw-r--r-- | layer-recipes/cgit.recipe | 6 | ||||
| -rw-r--r-- | layer-recipes/dns.recipe | 6 | ||||
| -rw-r--r-- | layer-recipes/host-resolv.conf/etc/resolv.conf | 4 | ||||
| -rw-r--r-- | layer-recipes/machine.recipe | 5 | ||||
| -rwxr-xr-x | layer-recipes/util.sh | 9 | ||||
| -rw-r--r-- | simple/0/conf | 20 | ||||
| -rw-r--r-- | simple/0/root/etc/rc.conf | 6 | ||||
| -rw-r--r-- | simple/0/root/etc/resolv.conf | 1 | ||||
| -rw-r--r-- | simple/1/conf | 19 | ||||
| -rw-r--r-- | simple/1/root/etc/rc.conf | 5 | ||||
| -rw-r--r-- | simple/1/root/etc/resolv.conf | 1 | ||||
| -rwxr-xr-x | simple/start.sh | 16 | ||||
| -rwxr-xr-x | simple/stop.sh | 9 | ||||
| -rw-r--r-- | todo.org | 7 |
22 files changed, 211 insertions, 0 deletions
diff --git a/cgit/description b/cgit/description new file mode 100644 index 0000000..bf08df4 --- /dev/null +++ b/cgit/description @@ -0,0 +1,8 @@ + +cgit_net 10.2.0.1/24 <-> cgit_host 10.2.0.2/24 + +cgit_host: + Running nginx, fcgiwrap and cgit. + cgit is serving /git directory. + Host's /lab/git is mounted to /git. + Working dataset is at /tmp/cgit_host. diff --git a/cgit/host/conf b/cgit/host/conf new file mode 100644 index 0000000..1471d6f --- /dev/null +++ b/cgit/host/conf @@ -0,0 +1,23 @@ +{ + module: sf.jail + configuration: { + interfaces: { + eth0 { type: eiface } + } + filesystem: { + layers: [ + cgit/host/root + /tmp/lamina.cgit + /tmp/lamina.machine + /lab/jail/base/14.1-RELEASE + ] + temporary: /tmp/cgit_host + volumes: [ + { source: "/lab/git", target: "/git" } + ] + devfs: 0 + } + init: [ sh, /etc/rc ] + shutdown: [ sh, /etc/rc.shutdown ] + } +} diff --git a/cgit/host/root/etc/rc.conf b/cgit/host/root/etc/rc.conf new file mode 100644 index 0000000..9d1ff9d --- /dev/null +++ b/cgit/host/root/etc/rc.conf @@ -0,0 +1,6 @@ +hostname="cgit" +ifconfig_eth0="inet 10.2.0.2/24 up" +defaultrouter="10.2.0.1" + +fcgiwrap_enable="YES" +nginx_enable="YES" diff --git a/cgit/host/root/etc/resolv.conf b/cgit/host/root/etc/resolv.conf new file mode 100644 index 0000000..35fb6f9 --- /dev/null +++ b/cgit/host/root/etc/resolv.conf @@ -0,0 +1 @@ +nameserver 1.0.0.1 diff --git a/cgit/host/root/usr/local/etc/cgitrc b/cgit/host/root/usr/local/etc/cgitrc new file mode 100644 index 0000000..5622531 --- /dev/null +++ b/cgit/host/root/usr/local/etc/cgitrc @@ -0,0 +1,10 @@ +css=/cgit.css +logo=/cgit.png + +virtual-root=/ +clone-prefix=http://10.2.0.2 +root-title=git server +root-desc= +readme=master:README.md + +scan-path=/git diff --git a/cgit/host/root/usr/local/etc/nginx/nginx.conf b/cgit/host/root/usr/local/etc/nginx/nginx.conf new file mode 100644 index 0000000..f779a68 --- /dev/null +++ b/cgit/host/root/usr/local/etc/nginx/nginx.conf @@ -0,0 +1,31 @@ + +user nobody; +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + gzip on; + + server { + listen 80 default_server; + + root /usr/local/www/cgit; + try_files $uri @cgit; + + location @cgit { + fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/www/cgit/cgit.cgi; + fastcgi_param PATH_INFO $uri; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + } + } +} diff --git a/cgit/start.sh b/cgit/start.sh new file mode 100755 index 0000000..ea3b4f0 --- /dev/null +++ b/cgit/start.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -e +. layer-recipes/util.sh +require-layer machine +require-layer cgit + +export SF_PATH=run + +sf.base node start cgit_net '{ module: sf.eiface, configuration: { inet: "10.2.0.1/24" } }' +sf.base node start cgit_host "$(cat cgit/host/conf)" +sf.base link start cgit_net_link cgit_net '' cgit_host eth0 diff --git a/cgit/stop.sh b/cgit/stop.sh new file mode 100755 index 0000000..5039de1 --- /dev/null +++ b/cgit/stop.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +export SF_PATH=run + +sf.base node stop cgit_host +sf.base node stop cgit_net diff --git a/layer-recipes/cgit.recipe b/layer-recipes/cgit.recipe new file mode 100644 index 0000000..85687ed --- /dev/null +++ b/layer-recipes/cgit.recipe @@ -0,0 +1,6 @@ +LAYER layer-recipes/host-resolv.conf +LAYER /tmp/lamina.machine +LAYER /lab/jail/base/14.1-RELEASE +DEVFS /dev + +RUN pkg install -y cgit fcgiwrap nginx diff --git a/layer-recipes/dns.recipe b/layer-recipes/dns.recipe new file mode 100644 index 0000000..70cb8a9 --- /dev/null +++ b/layer-recipes/dns.recipe @@ -0,0 +1,6 @@ +LAYER layer-recipes/host-resolv.conf +LAYER /tmp/lamina.machine +LAYER /lab/jail/base/14.1-RELEASE +DEVFS /dev + +RUN pkg install -y bind920 diff --git a/layer-recipes/host-resolv.conf/etc/resolv.conf b/layer-recipes/host-resolv.conf/etc/resolv.conf new file mode 100644 index 0000000..7b70a07 --- /dev/null +++ b/layer-recipes/host-resolv.conf/etc/resolv.conf @@ -0,0 +1,4 @@ +nameserver 1.0.0.1 +nameserver 1.1.1.1 +nameserver 9.9.9.9 + diff --git a/layer-recipes/machine.recipe b/layer-recipes/machine.recipe new file mode 100644 index 0000000..6b56165 --- /dev/null +++ b/layer-recipes/machine.recipe @@ -0,0 +1,5 @@ +LAYER layer-recipes/host-resolv.conf +LAYER /lab/jail/base/14.1-RELEASE +DEVFS /dev + +RUN pkg install -y tmux htop fish nano iperf3 diff --git a/layer-recipes/util.sh b/layer-recipes/util.sh new file mode 100755 index 0000000..f19230d --- /dev/null +++ b/layer-recipes/util.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +require-layer() { + if [ $# -ne 1 ]; then + echo "require-layer requires exactly 1 argument" + exit 1 + fi + test -e "/tmp/lamina.$1" || sf.lamina "layer-recipes/$1.recipe" "/tmp/lamina.$1" || return 1 +} diff --git a/simple/0/conf b/simple/0/conf new file mode 100644 index 0000000..bc8c79b --- /dev/null +++ b/simple/0/conf @@ -0,0 +1,20 @@ +{ + module: sf.jail + configuration: { + interfaces: { + eth0 { type: eiface } + eth1 { type: eiface } + eth2 { type: steal, interface: re0 } + } + filesystem: { + layers: [ + simple/0/root + /tmp/lamina.dns + /tmp/lamina.machine + /lab/jail/base/14.1-RELEASE + ] + } + init: [ sh, /etc/rc ] + shutdown: [ sh, /etc/rc.shutdown ] + } +} diff --git a/simple/0/root/etc/rc.conf b/simple/0/root/etc/rc.conf new file mode 100644 index 0000000..d7ef5ce --- /dev/null +++ b/simple/0/root/etc/rc.conf @@ -0,0 +1,6 @@ +hostname="test-0" +sshd_enable="YES" +ifconfig_eth0="inet 10.1.0.2/24 up" +ifconfig_eth1="inet 10.2.0.2/24 up" +ifconfig_eth2="inet 10.0.1.2/24 up" +defaultrouter="10.0.1.1" diff --git a/simple/0/root/etc/resolv.conf b/simple/0/root/etc/resolv.conf new file mode 100644 index 0000000..35fb6f9 --- /dev/null +++ b/simple/0/root/etc/resolv.conf @@ -0,0 +1 @@ +nameserver 1.0.0.1 diff --git a/simple/1/conf b/simple/1/conf new file mode 100644 index 0000000..59baa29 --- /dev/null +++ b/simple/1/conf @@ -0,0 +1,19 @@ +{ + module: sf.jail + configuration: { + interfaces: { + eth0 { type: eiface } + eth1 { type: eiface } + } + filesystem: { + layers: [ + simple/1/root + /tmp/lamina.machine + /lab/jail/base/14.1-RELEASE + ] + devfs: 5 + } + init: [ echo, custom init command ] + shutdown: [ echo, custom shutdown command ] + } +} diff --git a/simple/1/root/etc/rc.conf b/simple/1/root/etc/rc.conf new file mode 100644 index 0000000..6dedadd --- /dev/null +++ b/simple/1/root/etc/rc.conf @@ -0,0 +1,5 @@ +hostname="test-1" +sshd_enable="YES" +ifconfig_eth0="inet 10.1.0.3/24 up" +ifconfig_eth1="inet 10.2.0.3/24 up" +defaultrouter="10.2.0.1" diff --git a/simple/1/root/etc/resolv.conf b/simple/1/root/etc/resolv.conf new file mode 100644 index 0000000..35fb6f9 --- /dev/null +++ b/simple/1/root/etc/resolv.conf @@ -0,0 +1 @@ +nameserver 1.0.0.1 diff --git a/simple/start.sh b/simple/start.sh new file mode 100755 index 0000000..535c005 --- /dev/null +++ b/simple/start.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -e +. layer-recipes/util.sh +require-layer machine +require-layer dns + +export SF_PATH=run + +sf.base node start bridge0 '{ module: sf.bridge, configuration: {} }' +sf.base node start sf_net '{ module: sf.eiface, configuration: { inet: "10.2.0.1/24" } }' +sf.base link start l0 sf_net '' bridge0 link0 +sf.base node start j0 "$(cat simple/0/conf)" +sf.base node start j1 "$(cat simple/1/conf)" +sf.base link start l1 j0 eth0 j1 eth0 +sf.base link start l2 j0 eth1 bridge0 link1 +sf.base link start l3 j1 eth1 bridge0 link2 diff --git a/simple/stop.sh b/simple/stop.sh new file mode 100755 index 0000000..4d6c435 --- /dev/null +++ b/simple/stop.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +export SF_PATH=run + +sf.base node stop j0 +sf.base node stop j1 +sf.base node stop sf_net +sf.base node stop bridge0 diff --git a/todo.org b/todo.org new file mode 100644 index 0000000..63ac63b --- /dev/null +++ b/todo.org @@ -0,0 +1,7 @@ + +- [-] topologies + - [X] simple + - is not that interesting - it is just showcasing different nodes + - [X] cgit + - serves host's /lab/git directory on http://10.2.0.2/ + - [ ] dhcp + dns |
