diff options
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-x | ezjail-admin | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/ezjail-admin b/ezjail-admin index 94cba9e..fef82cc 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -83,7 +83,22 @@ attach_images () { | |||
83 | esac | 83 | esac |
84 | } | 84 | } |
85 | 85 | ||
86 | # define detach strategy for image jails | 86 | # generic mount routine for image jails |
87 | mount_images () { | ||
88 | rm -f "${ezjail_devicelink}" | ||
89 | |||
90 | # Attach images by type | ||
91 | attach_images | ||
92 | |||
93 | # Clean image | ||
94 | fsck -t ffs -p "/dev/${ezjail_device}" | ||
95 | |||
96 | mount "/dev/${ezjail_device}" "${ezjail_rootdir}" || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}." | ||
97 | # relink image device | ||
98 | ln -s "/dev/${ezjail_device}" "${ezjail_devicelink}" | ||
99 | } | ||
100 | |||
101 | # generic detach routine for image jails | ||
87 | detach_images () { | 102 | detach_images () { |
88 | # Avoid ending up inside mount point | 103 | # Avoid ending up inside mount point |
89 | cd / | 104 | cd / |
@@ -857,8 +872,8 @@ archive) | |||
857 | echo " Use ezjail-admin config -i attach ${ezjail_name} to attach it first." | 872 | echo " Use ezjail-admin config -i attach ${ezjail_name} to attach it first." |
858 | continue | 873 | continue |
859 | fi | 874 | fi |
860 | $0 config -i attach ${ezjail_name} || exerr "Error: Can not attach ${ezjail_image} for ${ezjail_name}" | 875 | mount_images |
861 | ezjail_imagesize=-`stat -f %z ${ezjail_image}` | 876 | ezjail_imagesize=-`stat -Lf %z ${ezjail_image}` |
862 | fi | 877 | fi |
863 | 878 | ||
864 | # This one goes into archive to identify jail by name and restore date | 879 | # This one goes into archive to identify jail by name and restore date |
@@ -901,7 +916,7 @@ archive) | |||
901 | ezjail_paxresult=$? | 916 | ezjail_paxresult=$? |
902 | 917 | ||
903 | # Detach previously attached jail | 918 | # Detach previously attached jail |
904 | [ "${ezjail_imagesize}" ] && cd / && $0 config -i detach ${ezjail_name} | 919 | [ "${ezjail_imagesize}" ] && detach_images keep |
905 | 920 | ||
906 | # An error on a jail not running is bad | 921 | # An error on a jail not running is bad |
907 | [ ${ezjail_paxresult} -eq 0 -o "${ezjail_force}" ] || exerr "Error: Archiving jail failed. You might want to check ${ezjail_archive}." | 922 | [ ${ezjail_paxresult} -eq 0 -o "${ezjail_force}" ] || exerr "Error: Archiving jail failed. You might want to check ${ezjail_archive}." |
@@ -1134,18 +1149,9 @@ config) | |||
1134 | attach) | 1149 | attach) |
1135 | # Check, if image already attached | 1150 | # Check, if image already attached |
1136 | [ "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." | 1151 | [ "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." |
1137 | rm -f "${ezjail_devicelink}" | ||
1138 | |||
1139 | # Attach images by type | ||
1140 | attach_images | ||
1141 | |||
1142 | # Clean image | ||
1143 | fsck -t ufs -p -B "/dev/${ezjail_device}" | ||
1144 | |||
1145 | mount "/dev/${ezjail_device}" "${ezjail_rootdir}" || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}." | ||
1146 | # relink image device | ||
1147 | ln -s "/dev/${ezjail_device}" "${ezjail_devicelink}" | ||
1148 | 1152 | ||
1153 | # Actually, just "attaching" is not enough, we need to mount | ||
1154 | mount_images | ||
1149 | ;; | 1155 | ;; |
1150 | detach) | 1156 | detach) |
1151 | # Check, if image really attached or running | 1157 | # Check, if image really attached or running |