HEADS UP: introduced fsck feature, untested.
This commit is contained in:
parent
a98c4c8e29
commit
e46d467c52
70
ezjail-admin
70
ezjail-admin
@ -48,6 +48,34 @@ ezjail_usage_list="Usage: ${ezjail_admin} list"
|
|||||||
# define our bail out shortcut
|
# define our bail out shortcut
|
||||||
exerr () { echo -e "$*" >&2 ; exit 1; }
|
exerr () { echo -e "$*" >&2 ; exit 1; }
|
||||||
|
|
||||||
|
# generic attach routine for image jails
|
||||||
|
attach_images () {
|
||||||
|
# Create a memory disc from jail image
|
||||||
|
ezjail_imagedevice=`mdconfig -a -t vnode -f ${ezjail_image}` || exerr "Error: Could not attach memory disc."
|
||||||
|
|
||||||
|
# If this is a crypto jail, try to mount it, remind user, which jail
|
||||||
|
# this is. In this case, the device to mount is
|
||||||
|
case ${ezjail_imagetype} in
|
||||||
|
crypto|bde)
|
||||||
|
echo "Attaching bde device for image jail ${ezjail}..."
|
||||||
|
echo gbde attach /dev/${ezjail_imagedevice} ${ezjail_attachparams} | /bin/sh
|
||||||
|
[ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching bde device failed."
|
||||||
|
# Device to mount is not md anymore
|
||||||
|
ezjail_device=${ezjail_imagedevice}.bde
|
||||||
|
;;
|
||||||
|
eli)
|
||||||
|
echo "Attaching eli device for image jail ${ezjail}..."
|
||||||
|
echo geli attach ${ezjail_attachparams} /dev/${ezjail_imagedevice} | /bin/sh
|
||||||
|
[ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching eli device failed."
|
||||||
|
# Device to mount is not md anymore
|
||||||
|
ezjail_device=${ezjail_imagedevice}.eli
|
||||||
|
;;
|
||||||
|
simple)
|
||||||
|
ezjail_device=${ezjail_imagedevice}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# define detach strategy for image jails
|
# define detach strategy for image jails
|
||||||
detach_images () {
|
detach_images () {
|
||||||
# unmount and detach memory disc
|
# unmount and detach memory disc
|
||||||
@ -735,30 +763,8 @@ config)
|
|||||||
[ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}."
|
[ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}."
|
||||||
rm -f ${ezjail_rootdir}.device
|
rm -f ${ezjail_rootdir}.device
|
||||||
|
|
||||||
# Create a memory disc from jail image
|
# Attach images by type
|
||||||
ezjail_imagedevice=`mdconfig -a -t vnode -f ${ezjail_image}` || exerr "Error: Could not attach memory disc."
|
attach_images
|
||||||
|
|
||||||
# If this is a crypto jail, try to mount it, remind user, which jail
|
|
||||||
# this is. In this case, the device to mount is
|
|
||||||
case ${ezjail_imagetype} in
|
|
||||||
crypto|bde)
|
|
||||||
echo "Attaching bde device for image jail ${ezjail}..."
|
|
||||||
echo gbde attach /dev/${ezjail_imagedevice} ${ezjail_attachparams} | /bin/sh
|
|
||||||
[ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching bde device failed."
|
|
||||||
# Device to mount is not md anymore
|
|
||||||
ezjail_device=${ezjail_imagedevice}.bde
|
|
||||||
;;
|
|
||||||
eli)
|
|
||||||
echo "Attaching eli device for image jail ${ezjail}..."
|
|
||||||
echo geli attach ${ezjail_attachparams} /dev/${ezjail_imagedevice} | /bin/sh
|
|
||||||
[ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching eli device failed."
|
|
||||||
# Device to mount is not md anymore
|
|
||||||
ezjail_device=${ezjail_imagedevice}.eli
|
|
||||||
;;
|
|
||||||
simple)
|
|
||||||
ezjail_device=${ezjail_imagedevice}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
mount /dev/${ezjail_device} ${ezjail_rootdir} || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}."
|
mount /dev/${ezjail_device} ${ezjail_rootdir} || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}."
|
||||||
# relink image device
|
# relink image device
|
||||||
@ -781,6 +787,22 @@ config)
|
|||||||
# Unmount/detach everything
|
# Unmount/detach everything
|
||||||
detach_images keep
|
detach_images keep
|
||||||
|
|
||||||
|
# Remove soft link (which acts as a lock)
|
||||||
|
[ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device
|
||||||
|
;;
|
||||||
|
fsck)
|
||||||
|
# Check, if image already attached
|
||||||
|
[ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}."
|
||||||
|
rm -f ${ezjail_rootdir}.device
|
||||||
|
|
||||||
|
# Attach images by type
|
||||||
|
attach_images
|
||||||
|
|
||||||
|
fsck_ufs /dev/${ezjail_device}
|
||||||
|
|
||||||
|
# Detach images by type
|
||||||
|
detach_images keep
|
||||||
|
|
||||||
# Remove soft link (which acts as a lock)
|
# Remove soft link (which acts as a lock)
|
||||||
[ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device
|
[ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device
|
||||||
;;
|
;;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user