summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin68
1 files changed, 47 insertions, 21 deletions
diff --git a/ezjail-admin b/ezjail-admin
index d5dffc7..86787dd 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -18,7 +18,7 @@ ezjail_jailcfgs="${ezjail_etc}/ezjail"
18: ${ezjail_jailbase="${ezjail_jaildir}/basejail"} 18: ${ezjail_jailbase="${ezjail_jaildir}/basejail"}
19: ${ezjail_jailfull="${ezjail_jaildir}/fulljail"} 19: ${ezjail_jailfull="${ezjail_jaildir}/fulljail"}
20: ${ezjail_jailtemp="${ezjail_jaildir}/ezjailtemp"} 20: ${ezjail_jailtemp="${ezjail_jaildir}/ezjailtemp"}
21: ${ezjail_flavours="${ezjail_jaildir}/flavours"} 21: ${ezjail_flavours_dir="${ezjail_jaildir}/flavours"}
22: ${ezjail_portscvsroot="freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs"} 22: ${ezjail_portscvsroot="freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs"}
23: ${ezjail_sourcetree="/usr/src"} 23: ${ezjail_sourcetree="/usr/src"}
24: ${ezjail_uglyperlhack="YES"} 24: ${ezjail_uglyperlhack="YES"}
@@ -269,7 +269,7 @@ ezjail_splitworld() {
269 fi 269 fi
270 270
271 # If the default flavour example has not yet been copied, do it now 271 # If the default flavour example has not yet been copied, do it now
272 [ -d "${ezjail_flavours}/example" ] || mkdir -p "${ezjail_flavours}" && cp -p -R "${ezjail_examples}/example" "${ezjail_flavours}" 272 [ -d "${ezjail_flavours_dir}/example" ] || mkdir -p "${ezjail_flavours_dir}" && cp -p -R "${ezjail_examples}/example" "${ezjail_flavours_dir}"
273 273
274 # no /usr/ports? link to /basejail/usr/ports 274 # no /usr/ports? link to /basejail/usr/ports
275 [ -e "${ezjail_jailtemplate}/usr/ports" ] || ln -s /basejail/usr/ports "${ezjail_jailtemplate}/usr/ports" 275 [ -e "${ezjail_jailtemplate}/usr/ports" ] || ln -s /basejail/usr/ports "${ezjail_jailtemplate}/usr/ports"
@@ -399,7 +399,7 @@ check_for_zfs_exist () {
399 399
400############################# 400#############################
401# End of function definitions 401# End of function definitions
402# 402# "
403 403
404# check for command 404# check for command
405[ $# -gt 0 ] || exerr ${ezjail_usage_ezjailadmin} 405[ $# -gt 0 ] || exerr ${ezjail_usage_ezjailadmin}
@@ -408,11 +408,11 @@ case "$1" in
408######################## ezjail-admin CREATE ######################## 408######################## ezjail-admin CREATE ########################
409create) 409create)
410 # Clean variables, prevent polution 410 # Clean variables, prevent polution
411 unset ezjail_rootdir ezjail_flavour ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_device ezjail_devicelink ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive ezjail_fromarchive_config 411 unset ezjail_rootdir ezjail_flavours ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_device ezjail_devicelink ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive ezjail_fromarchive_config
412 shift; while getopts :f:r:s:xbic:C:a:A: arg; do case ${arg} in 412 shift; while getopts :f:r:s:xbic:C:a:A: arg; do case ${arg} in
413 x) ezjail_exists="YES";; 413 x) ezjail_exists="YES";;
414 r) ezjail_rootdir=${OPTARG};; 414 r) ezjail_rootdir=${OPTARG};;
415 f) ezjail_flavour=${OPTARG};; 415 f) ezjail_flavours=${OPTARG};;
416 a) ezjail_fromarchive=${OPTARG};; 416 a) ezjail_fromarchive=${OPTARG};;
417 A) ezjail_fromarchive_config=${OPTARG};; 417 A) ezjail_fromarchive_config=${OPTARG};;
418 c) ezjail_imagetype=${OPTARG};; 418 c) ezjail_imagetype=${OPTARG};;
@@ -490,10 +490,12 @@ create)
490 fi 490 fi
491 491
492 # if no flavour specified on command line, use default flavour 492 # if no flavour specified on command line, use default flavour
493 : ${ezjail_flavour=${ezjail_default_flavour}} 493 : ${ezjail_flavours=${ezjail_default_flavour}}
494 494
495 # do some sanity checks on the selected flavour (if any) 495 # do some sanity checks on the selected flavour (if any)
496 [ "${ezjail_flavour}" -a ! -d "${ezjail_flavours}/${ezjail_flavour}" ] && exerr "Error: Flavour config directory ${ezjail_flavours}/${ezjail_flavour} not found.\n Refer to ${ezjail_admin}s man page for details on flavours." 496 for ezjail_flavour in ${ezjail_flavours}; do
497 [-d "${ezjail_flavours_dir}/${ezjail_flavour}" ] || exerr "Error: Flavour config directory ${ezjail_flavours_dir}/${ezjail_flavour} not found.\n Refer to ${ezjail_admin}s man page for details on flavours."
498 done
497 499
498 # check for restore circumstances, normally this is invoked by the restore command 500 # check for restore circumstances, normally this is invoked by the restore command
499 [ "${ezjail_fromarchive}" -a "${ezjail_exists}" ] && exerr "Error: You can not restore an archive over an existing jail.\n '${ezjail_admin} delete -w ${ezjail_name}' the old version first." 501 [ "${ezjail_fromarchive}" -a "${ezjail_exists}" ] && exerr "Error: You can not restore an archive over an existing jail.\n '${ezjail_admin} delete -w ${ezjail_name}' the old version first."
@@ -637,20 +639,44 @@ create)
637 writejailinfo "${ezjail_config}" "${ezjail_fromarchive_config}" 639 writejailinfo "${ezjail_config}" "${ezjail_fromarchive_config}"
638 640
639 # Final steps for flavour installation 641 # Final steps for flavour installation
640 if [ -z "${ezjail_exists}" -a "${ezjail_flavour}" ]; then 642 if [ -z "${ezjail_exists}" ]; then
641 # install files and config to new jail 643 _installed_flavours=0
642 cd "${ezjail_flavours}/${ezjail_flavour}" && find . | cpio -p -u -v "${ezjail_rootdir}" > /dev/null 644 for ezjail_flavour in ${ezjail_flavours}; do
643 [ $? -eq 0 ] || echo "Warning: Could not fully install flavour." 645 # install files and config to new jail
644 646 cd "${ezjail_flavours_dir}/${ezjail_flavour}" && find . | cpio -p -u -v "${ezjail_rootdir}" > /dev/null
645 # if the packages are links and not files we have to copy them now 647 [ $? -eq 0 ] || echo "Warning: Could not fully install flavour ${ezjail_flavour}."
646 find "${ezjail_rootdir}/pkg/" -type l -exec cp -r -f {} {}.ezjail \; -exec mv {}.ezjail {} \; 648
647 649 # if the packages are links and not files we have to copy them now
648 # If a config is found, make it auto run on jails startup 650 find "${ezjail_rootdir}/pkg/" -type l -exec cp -r -f {} {}.ezjail \; -exec mv {}.ezjail {} \;
649 if [ -f "${ezjail_rootdir}/ezjail.flavour" ]; then 651
650 ln -s /ezjail.flavour "${ezjail_rootdir}/etc/rc.d/ezjail-config" 652 # If a config is found, make it auto run on jails startup
651 chmod 0700 "${ezjail_rootdir}/ezjail.flavour" 653 if [ -f "${ezjail_rootdir}/ezjail.flavour" ]; then
652 echo "Note: Shell scripts installed, flavourizing on jails first startup." 654 chmod 0755 "${ezjail_rootdir}/ezjail.flavour"
653 fi 655 mv "${ezjail_rootdir}/ezjail.flavour" "${ezjail_rootdir}/ezjail.flavour".`printf %04d ${_installed_flavours}`
656 echo "Note: Shell scripts for flavour ${ezjail_flavour} installed, flavourizing on jails first startup."
657 fi
658
659 echo << "EOF"
660#!/bin/sh
661#
662# BEFORE: DAEMON
663# PROVIDES: ezjail-config
664#
665case "$1" in
666 start)
667 rm -f "${0}"
668 for ezjail_flavour in /ezjail.flavour*; do
669 [ -x "${ezjail_flavour}" ] && "${ezjail_flavour}"
670 rm -f "${ezjail_flavour}"
671 done
672 ;;
673 *)
674 ;;
675esac
676
677EOF
678 > "${ezjail_rootdir}/etc/rc.d/ezjail-config"
679 done
654 fi 680 fi
655 681
656 # Detach (crypto and) memory discs 682 # Detach (crypto and) memory discs