Merge pull request #9 from Culsu/dev

Some convenience functions
This commit is contained in:
T.v.Dein
2020-11-30 16:13:31 +01:00
committed by GitHub
2 changed files with 13 additions and 4 deletions

View File

@@ -52,12 +52,12 @@ Refer to [jail(8)](https://www.freebsd.org/cgi/man.cgi?query=jail&sektion=8) for
Next add the following lines to your `/etc/rc.conf`:
```
ifconfig_em0_alias0="inet 144.76.67.168/32"
ifconfig_em0_alias0="inet 172.16.1.1/32"
jail_enable="YES"
```
You may need to replace the interface name `em0` with the one in use on your system.
You might need to restart the interface to apply the alias: `/etc/rc.d/netif restart`.
### Create the jail
```
@@ -197,7 +197,7 @@ fcgiwrap is running as pid 37682.
### Login into the running jail for administration
```
# jaildk jlogin myjail
# jaildk login myjail
```
You can use this to login into a database or execute commands inside the jail.

9
jaildk Normal file → Executable file
View File

@@ -751,6 +751,7 @@ jaildk_clone() {
echo
else
. $j/etc/$src/jail.conf
jail=$new
bold "To mount the build chroot of the new jail, execute:"
echo "jaildk build $new start $base $newversion"
fi
@@ -763,6 +764,9 @@ Create a new jail from template."
jaildk_create() {
jail=$1
# $jail gets overwritten in jaildk_clone or some subcall to .template :-( ...
newjail=$jail
src=.template
if test -z "$jail"; then
@@ -776,6 +780,11 @@ jaildk_create() {
mkdir -p $j/etc/$jail
jaildk_clone -s $src -d $jail -o $srcversion -n $newversion
# some perl magic to extract the hostname (if any) from /etc/jail.conf - and write it into the jails rc.conf
jailhostname=$(cat /etc/jail.conf | tr -d '\t\r\n ' | perl -ne '$_ =~ /.*'"$newjail"'(\{(?:\{.*\}|[^{])*\})|\w+/; print $1;' | grep -oE 'hostname=[^;]+' | cut -d= -f2)
[ -n "$jailhostname" ] && sed -iE 's/^hostname.*$/hostname="'"$jailhostname"'"/' $j/etc/$newjail/local-etc-$newversion/rc.conf
}
remove() {