mirror of
https://codeberg.org/scip/jaildk.git
synced 2025-12-18 13:11:02 +01:00
Added support to automagically set the hostname in the jails rc.conf based on the hostname in /etc/jail.conf
This commit is contained in:
9
jaildk
9
jaildk
@@ -751,6 +751,7 @@ jaildk_clone() {
|
|||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
. $j/etc/$src/jail.conf
|
. $j/etc/$src/jail.conf
|
||||||
|
jail=$new
|
||||||
bold "To mount the build chroot of the new jail, execute:"
|
bold "To mount the build chroot of the new jail, execute:"
|
||||||
echo "jaildk build $new start $base $newversion"
|
echo "jaildk build $new start $base $newversion"
|
||||||
fi
|
fi
|
||||||
@@ -763,6 +764,9 @@ Create a new jail from template."
|
|||||||
|
|
||||||
jaildk_create() {
|
jaildk_create() {
|
||||||
jail=$1
|
jail=$1
|
||||||
|
# $jail gets overwritten in jaildk_clone or some subcall to .template :-( ...
|
||||||
|
newjail=$jail
|
||||||
|
|
||||||
src=.template
|
src=.template
|
||||||
|
|
||||||
if test -z "$jail"; then
|
if test -z "$jail"; then
|
||||||
@@ -776,6 +780,11 @@ jaildk_create() {
|
|||||||
mkdir -p $j/etc/$jail
|
mkdir -p $j/etc/$jail
|
||||||
|
|
||||||
jaildk_clone -s $src -d $jail -o $srcversion -n $newversion
|
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)
|
||||||
|
sed -iE 's/^hostname.*$/hostname="'"$jailhostname"'"/' $j/etc/$newjail/local-etc-$newversion/rc.conf
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
|
|||||||
Reference in New Issue
Block a user