implement #20: added -s parameter to base command to instal scripts

This commit is contained in:
2024-09-18 10:30:55 +02:00
parent cf812919cb
commit cafc20e743
2 changed files with 59 additions and 50 deletions

View File

@@ -143,7 +143,7 @@ For an overview of the provided commands, here's the usage screen:
Usage: ./jaildk <command> <command-args>
Building Jails:
base -b <name> [-w] - build a new base
base -b <name> [-w] [-s <script>] - build a new base
build <jail> -m <mode> [-b <base>] [-v <version>] - install a build chroot of a jail
create - create a new jail from a template
clone -s <src> -d <dst> [-o <v>] [-n <v>] - clone an existing jail or jail version

View File

@@ -831,6 +831,8 @@ Build a base directory from bsd install media. Options:
build stuff. Use this if you want to use the ports
collection.
-f force mode, remove any old dist files.
-s <script> install additional scripts to /usr/bin, separate multiple
scripts with whitespace.
"
}
@@ -840,11 +842,13 @@ jaildk_base() {
base=""
force=""
rw=""
scripts=""
OPTIND=1; while getopts "b:wf" arg; do
OPTIND=1; while getopts "b:wfs:" arg; do
case $arg in
w) rw=1;;
b) base=${OPTARG};;
s) scripts="${OPTARG}";;
f) force=1;;
*) usage_base;;
esac
@@ -927,61 +931,66 @@ var/tmp"
if test -d "$basedir"; then
echo "base $basedir already exist!"
exit 1
else
ex mkdir -p $basedir
fi
if test -e /usr/freebsd-dist/MANIFEST; then
clean=''
if test -n "$force"; then
clean=1
else
echo "Found old dist files:"
ls -l /usr/freebsd-dist
echo -n "Want to remove them [nY]? "
read yesno
case $yesno in
y|Y) clean=1;;
*) clean='';;
esac
fi
ex mkdir -p $basedir
if test -n "$clean"; then
ex rm -f /usr/freebsd-dist/*
fi
fi
bsdinstall jail $basedir || exit 1
if test -z "$rw"; then
# run base
for file in $removelist; do
ex rm -rf $basedir/$file
done
if test -e /usr/freebsd-dist/MANIFEST; then
clean=''
if test -n "$force"; then
clean=1
else
# build base with ports support
ex mkdir -p $basedir/usr/ports
fi
ex mkdir $basedir/home
ex rm -rf $basedir/var/db
ex ln -s /usr/local/db $basedir/var/db
# add some symlinks from /var to /tmp to make pkg work properly
ex rm -rf $basedir/var/tmp $basedir/var/cache $basedir/var/run
ex ln -s /tmp $basedir/var/tmp
ex ln -s /tmp $basedir/var/cache
ex ln -s /tmp $basedir/var/run
if test -n "$rw"; then
echo "You have choosen to create a build base with ports support"
echo -n "Want to fetch the ports collection now [Yn]? "
echo "Found old dist files:"
ls -l /usr/freebsd-dist
echo -n "Want to remove them [nY]? "
read yesno
case $yesno in
y|Y|yes|YES)
jaildk_fetchports
;;
y|Y) clean=1;;
*) clean='';;
esac
fi
if test -n "$clean"; then
ex rm -f /usr/freebsd-dist/*
fi
fi
bsdinstall jail $basedir || exit 1
if test -z "$rw"; then
# run base
for file in $removelist; do
ex rm -rf $basedir/$file
done
else
# build base with ports support
ex mkdir -p $basedir/usr/ports
fi
ex mkdir $basedir/home
ex rm -rf $basedir/var/db
ex ln -s /usr/local/db $basedir/var/db
# add some symlinks from /var to /tmp to make pkg work properly
ex rm -rf $basedir/var/tmp $basedir/var/cache $basedir/var/run
ex ln -s /tmp $basedir/var/tmp
ex ln -s /tmp $basedir/var/cache
ex ln -s /tmp $basedir/var/run
# any scripts?
for script in $scripts; do
ex install -m 755 $script -o root -g wheel $basedir/usr/bin/$script
done
if test -n "$rw"; then
echo "You have choosen to create a build base with ports support"
echo -n "Want to fetch the ports collection now [Yn]? "
read yesno
case $yesno in
y|Y|yes|YES)
jaildk_fetchports
;;
esac
fi
}