diff options
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-x | ezjail-admin | 485 |
1 files changed, 264 insertions, 221 deletions
diff --git a/ezjail-admin b/ezjail-admin index 9690076..ae6f646 100755 --- a/ezjail-admin +++ b/ezjail-admin | |||
@@ -4,13 +4,13 @@ | |||
4 | # ugly: this variable is set during port install time | 4 | # ugly: this variable is set during port install time |
5 | ezjail_prefix=EZJAIL_PREFIX | 5 | ezjail_prefix=EZJAIL_PREFIX |
6 | ezjail_admin=`basename -- $0` | 6 | ezjail_admin=`basename -- $0` |
7 | ezjail_etc=${ezjail_prefix}/etc | 7 | ezjail_etc="${ezjail_prefix}/etc" |
8 | ezjail_share=${ezjail_prefix}/share/ezjail | 8 | ezjail_share="${ezjail_prefix}/share/ezjail" |
9 | ezjail_examples=${ezjail_prefix}/share/examples/ezjail | 9 | ezjail_examples="${ezjail_prefix}/share/examples/ezjail" |
10 | ezjail_jailcfgs=${ezjail_etc}/ezjail | 10 | ezjail_jailcfgs="${ezjail_etc}/ezjail" |
11 | 11 | ||
12 | # read user config | 12 | # read user config |
13 | [ -f ${ezjail_etc}/ezjail.conf ] && . ${ezjail_etc}/ezjail.conf | 13 | [ -f "${ezjail_etc}/ezjail.conf" ] && . "${ezjail_etc}/ezjail.conf" |
14 | 14 | ||
15 | # set defaults | 15 | # set defaults |
16 | ezjail_jaildir=${ezjail_jaildir:-"/usr/jails"} | 16 | ezjail_jaildir=${ezjail_jaildir:-"/usr/jails"} |
@@ -34,7 +34,7 @@ ezjail_dirlist="bin boot lib libexec rescue sbin usr/bin usr/games usr/include u | |||
34 | case `uname -p` in amd64) ezjail_dirlist="${ezjail_dirlist} usr/lib32";; esac | 34 | case `uname -p` in amd64) ezjail_dirlist="${ezjail_dirlist} usr/lib32";; esac |
35 | 35 | ||
36 | # Synopsis messages | 36 | # Synopsis messages |
37 | ezjail_usage_ezjailadmin="Usage: ${ezjail_admin} [archive|config|console|create|delete|install|list|update] {params}" | 37 | ezjail_usage_ezjailadmin="Usage: ${ezjail_admin} [archive|config|console|create|delete|install|list|restore|update] {params}" |
38 | ezjail_usage_install="Usage: ${ezjail_admin} install [-mps] [-h host] [-r release]" | 38 | ezjail_usage_install="Usage: ${ezjail_admin} install [-mps] [-h host] [-r release]" |
39 | ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli] [-C args] [-a archive] jailname jailip" | 39 | ezjail_usage_create="Usage: ${ezjail_admin} create [-xbi] [-f flavour] [-r jailroot] [-s size] [-c bde|eli] [-C args] [-a archive] jailname jailip" |
40 | ezjail_usage_delete="Usage: ${ezjail_admin} delete [-w] jailname" | 40 | ezjail_usage_delete="Usage: ${ezjail_admin} delete [-w] jailname" |
@@ -42,6 +42,7 @@ ezjail_usage_update="Usage: ${ezjail_admin} update [-s sourcetree] [-i] [-pP]" | |||
42 | ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-i attach|detach|fsck] jailname" | 42 | ezjail_usage_config="Usage: ${ezjail_admin} config [-r run|norun] [-n newname] [-i attach|detach|fsck] jailname" |
43 | ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname" | 43 | ezjail_usage_console="Usage: ${ezjail_admin} console [-f] [-e command] jailname" |
44 | ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]" | 44 | ezjail_usage_archive="Usage: ${ezjail_admin} archive [-Af] [-a archive] [-d archivedir] jailname [jailname...]" |
45 | ezjail_usage_restore="Usage: ${ezjail_admin} restore [-d archivedir] (archive|jailname)..." | ||
45 | ezjail_usage_list="Usage: ${ezjail_admin} list" | 46 | ezjail_usage_list="Usage: ${ezjail_admin} list" |
46 | 47 | ||
47 | ################################ | 48 | ################################ |
@@ -49,7 +50,7 @@ ezjail_usage_list="Usage: ${ezjail_admin} list" | |||
49 | # | 50 | # |
50 | 51 | ||
51 | # define our bail out shortcut | 52 | # define our bail out shortcut |
52 | exerr () { echo -e "$*" >&2 ; exit 1; } | 53 | exerr () { echo -e $* >&2 ; exit 1; } |
53 | 54 | ||
54 | # generic attach routine for image jails | 55 | # generic attach routine for image jails |
55 | attach_images () { | 56 | attach_images () { |
@@ -60,18 +61,18 @@ attach_images () { | |||
60 | # this is. In this case, the device to mount is | 61 | # this is. In this case, the device to mount is |
61 | case ${ezjail_imagetype} in | 62 | case ${ezjail_imagetype} in |
62 | crypto|bde) | 63 | crypto|bde) |
63 | echo "Attaching bde device for image jail ${ezjail}..." | 64 | echo Attaching bde device for image jail ${ezjail}... |
64 | echo gbde attach /dev/${ezjail_imagedevice} ${ezjail_attachparams} | /bin/sh | 65 | echo gbde attach "/dev/${ezjail_imagedevice}" ${ezjail_attachparams} | /bin/sh |
65 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching bde device failed." | 66 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching bde device failed." |
66 | # Device to mount is not md anymore | 67 | # Device to mount is not md anymore |
67 | ezjail_device=${ezjail_imagedevice}.bde | 68 | ezjail_device="${ezjail_imagedevice}.bde" |
68 | ;; | 69 | ;; |
69 | eli) | 70 | eli) |
70 | echo "Attaching eli device for image jail ${ezjail}..." | 71 | echo "Attaching eli device for image jail ${ezjail}..." |
71 | echo geli attach ${ezjail_attachparams} /dev/${ezjail_imagedevice} | /bin/sh | 72 | echo geli attach ${ezjail_attachparams} "/dev/${ezjail_imagedevice}" | /bin/sh |
72 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching eli device failed." | 73 | [ $? -eq 0 ] || detach_images keep || exerr "Error: Attaching eli device failed." |
73 | # Device to mount is not md anymore | 74 | # Device to mount is not md anymore |
74 | ezjail_device=${ezjail_imagedevice}.eli | 75 | ezjail_device="${ezjail_imagedevice}.eli" |
75 | ;; | 76 | ;; |
76 | simple) | 77 | simple) |
77 | ezjail_device=${ezjail_imagedevice} | 78 | ezjail_device=${ezjail_imagedevice} |
@@ -82,33 +83,56 @@ attach_images () { | |||
82 | # define detach strategy for image jails | 83 | # define detach strategy for image jails |
83 | detach_images () { | 84 | detach_images () { |
84 | # unmount and detach memory disc | 85 | # unmount and detach memory disc |
85 | if [ -n "${ezjail_imagedevice}" ]; then | 86 | if [ "${ezjail_imagedevice}" ]; then |
86 | umount ${ezjail_rootdir} > /dev/null 2> /dev/null | 87 | umount "${ezjail_rootdir}" > /dev/null 2> /dev/null |
87 | case ${ezjail_imagetype} in | 88 | case ${ezjail_imagetype} in |
88 | bde) gbde detach /dev/${ezjail_imagedevice} > /dev/null;; | 89 | bde) gbde detach "/dev/${ezjail_imagedevice}" > /dev/null;; |
89 | eli) geli detach /dev/${ezjail_imagedevice} > /dev/null;; | 90 | eli) geli detach "/dev/${ezjail_imagedevice}" > /dev/null;; |
90 | esac | 91 | esac |
91 | mdconfig -d -u ${ezjail_imagedevice} > /dev/null | 92 | mdconfig -d -u "${ezjail_imagedevice}" > /dev/null |
92 | [ "$1" = "keep" ] || rm -f ${ezjail_image} | 93 | [ "$1" = "keep" ] || rm -f "${ezjail_image}" |
93 | fi | 94 | fi |
95 | |||
96 | # Remove soft link (which acts as a lock) | ||
97 | [ -e "/dev/${ezjail_imagedevice}" ] || rm -f "${ezjail_devicelink}" | ||
98 | |||
94 | # This function is being called in case of error. Keep $? bad | 99 | # This function is being called in case of error. Keep $? bad |
95 | return 1 | 100 | return 1 |
96 | } | 101 | } |
97 | 102 | ||
103 | # Find and execute our rc script | ||
104 | start_stop_jail_by_script () { | ||
105 | ezjail_action=$1 | ||
106 | [ "${ezjail_action}" = "start" ] && ezjail_success_check="-n" || ezjail_success_check="-z" | ||
107 | |||
108 | # Try to locate and run ezjails rc.d script | ||
109 | if [ -x "${ezjail_prefix}/etc/rc.d/ezjail" ]; then | ||
110 | (exec "${ezjail_prefix}/etc/rc.d/ezjail" ${ezjail_action} ${ezjail_name}); | ||
111 | elif [ -x "${ezjail_prefix}/etc/rc.d/ezjail.sh" ]; then | ||
112 | (exec "${ezjail_prefix}/etc/rc.d/ezjail.sh" ${ezjail_action} ${ezjail_name}); | ||
113 | else | ||
114 | exerr "Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/. You need to ${ezjail_action} ${ezjail_name} by hand." | ||
115 | fi | ||
116 | |||
117 | # Check for success of our operation | ||
118 | fetchjailinfo ${ezjail_name} | ||
119 | [ ${ezjail_success_check} "${ezjail_id}" ] || exerr "Error: Could not ${ezjail_action} ${ezjail_name}. You need to ${ezjail_action} it by hand." | ||
120 | } | ||
121 | |||
98 | # fetch everything we need to know about an ezjail from config | 122 | # fetch everything we need to know about an ezjail from config |
99 | fetchjailinfo () { | 123 | fetchjailinfo () { |
100 | ezjail_name=$1 | 124 | ezjail_name=$1 |
101 | 125 | ||
102 | # Clean variables, prevent polution | 126 | # Clean variables, prevent polution |
103 | unset ezjail_config ezjail_running ezjail_hostname ezjail_rootdir ezjail_image ezjail_imagetype ezjail_ip ezjail_id ezjail_attached ezjail_device | 127 | unset ezjail_config ezjail_running ezjail_hostname ezjail_rootdir ezjail_image ezjail_imagetype ezjail_imagedevice ezjail_devicelink ezjail_ip ezjail_id ezjail_attached ezjail_device ezjail_device_geom |
104 | 128 | ||
105 | ezjail_safename=`echo -n "${ezjail_name}" | tr -c '[:alnum:]' _` | 129 | ezjail_safename=`echo -n "${ezjail_name}" | tr -c '[:alnum:]' _` |
106 | 130 | ||
107 | [ -e ${ezjail_jailcfgs}/${ezjail_safename} ] && ezjail_config=${ezjail_jailcfgs}/${ezjail_safename} | 131 | [ -e "${ezjail_jailcfgs}/${ezjail_safename}" ] && ezjail_config="${ezjail_jailcfgs}/${ezjail_safename}" |
108 | [ -e ${ezjail_jailcfgs}/${ezjail_safename}.norun ] && ezjail_config=${ezjail_jailcfgs}/${ezjail_safename}.norun | 132 | [ -e "${ezjail_jailcfgs}/${ezjail_safename}.norun" ] && ezjail_config="${ezjail_jailcfgs}/${ezjail_safename}.norun" |
109 | [ "${ezjail_config}" ] || return 0 | 133 | [ "${ezjail_config}" ] || return 0 |
110 | 134 | ||
111 | . ${ezjail_config} | 135 | . "${ezjail_config}" |
112 | eval ezjail_hostname=\"\$jail_${ezjail_safename}_hostname\" | 136 | eval ezjail_hostname=\"\$jail_${ezjail_safename}_hostname\" |
113 | eval ezjail_rootdir=\"\$jail_${ezjail_safename}_rootdir\" | 137 | eval ezjail_rootdir=\"\$jail_${ezjail_safename}_rootdir\" |
114 | eval ezjail_ip=\"\$jail_${ezjail_safename}_ip\" | 138 | eval ezjail_ip=\"\$jail_${ezjail_safename}_ip\" |
@@ -118,57 +142,66 @@ fetchjailinfo () { | |||
118 | eval ezjail_attachblocking=\"\$jail_${ezjail_safename}_attachblocking\" | 142 | eval ezjail_attachblocking=\"\$jail_${ezjail_safename}_attachblocking\" |
119 | eval ezjail_forceblocking=\"\$jail_${ezjail_safename}_forceblocking\" | 143 | eval ezjail_forceblocking=\"\$jail_${ezjail_safename}_forceblocking\" |
120 | 144 | ||
121 | ezjail_softlink=${ezjail_jaildir}/`basename -- ${ezjail_rootdir}` | 145 | ezjail_softlink=${ezjail_jaildir}/`basename -- "${ezjail_rootdir}"` |
146 | ezjail_devicelink="${ezjail_rootdir}.device" | ||
122 | 147 | ||
123 | if [ -n "${ezjail_image}" -a -L "${ezjail_rootdir}.device" ]; then | 148 | if [ "${ezjail_image}" -a -L "${ezjail_devicelink}" ]; then |
124 | # Fetch destination of soft link | 149 | # Fetch destination of soft link |
125 | ezjail_device=`stat -f "%Y" ${ezjail_rootdir}.device` | 150 | ezjail_device=`stat -f "%Y" ${ezjail_devicelink}` |
151 | ezjail_device_geom=${ezjail_device#/dev/} | ||
152 | |||
153 | # Add this device to the list of devices to be unmounted | ||
154 | case ${ezjail_imagetype} in | ||
155 | crypto|bde) ezjail_imagedevice=${ezjail_device_geom%.bde} ;; | ||
156 | eli) ezjail_imagedevice=${ezjail_device_geom%.eli} ;; | ||
157 | *) ezjail_imagedevice=${ezjail_device_geom} ;; | ||
158 | esac | ||
126 | 159 | ||
127 | mount -p -v | grep -q -E "^${ezjail_rootdir}.device.${ezjail_rootdir}" && ezjail_attached="YES" | 160 | mount -p -v | grep -q -E "^${ezjail_devicelink}.${ezjail_rootdir}" && ezjail_attached="YES" |
128 | mount -p -v | grep -q -E "^${ezjail_device}.${ezjail_rootdir}" && ezjail_attached="YES" | 161 | mount -p -v | grep -q -E "^${ezjail_device}.${ezjail_rootdir}" && ezjail_attached="YES" |
129 | 162 | ||
130 | # Stale device link detected. Remove and clean. | 163 | # Stale device link detected. Remove and clean. |
131 | [ -z "${ezjail_attached}" ] && unset ezjail_device && rm -f ${ezjail_rootdir}.device | 164 | [ -z "${ezjail_attached}" ] && unset ezjail_device && rm -f "${ezjail_devicelink}" |
132 | fi | 165 | fi |
133 | 166 | ||
134 | [ -f /var/run/jail_${ezjail_safename}.id ] && ezjail_id=`cat /var/run/jail_${ezjail_safename}.id` || return | 167 | [ -f "/var/run/jail_${ezjail_safename}.id" ] && ezjail_id=`cat /var/run/jail_${ezjail_safename}.id` || return |
135 | jls | grep -q -E "^ +${ezjail_id} " || unset ezjail_id | 168 | jls | grep -q -E "^ +${ezjail_id} " || unset ezjail_id |
136 | } | 169 | } |
137 | 170 | ||
138 | # fill the base jail - this function is used by install and update | 171 | # fill the base jail - this function is used by install and update |
139 | ezjail_splitworld() { | 172 | ezjail_splitworld() { |
140 | # Fill basejail from installed world | 173 | # Fill basejail from installed world |
141 | cd ${ezjail_jailfull} || exerr "Cant access temporary Jail directory." | 174 | cd "${ezjail_jailfull}" || exerr "Cant access temporary Jail directory." |
142 | 175 | ||
143 | # This mkdir is important, since cpio will create intermediate | 176 | # This mkdir is important, since cpio will create intermediate |
144 | # directories with permission 0700 which is bad | 177 | # directories with permission 0700 which is bad |
145 | mkdir -p ${ezjail_jailbase}/usr | 178 | mkdir -p "${ezjail_jailbase}/usr" |
146 | for dir in ${ezjail_dirlist}; do | 179 | for dir in ${ezjail_dirlist}; do |
147 | find ${dir} | cpio -d -p -v ${ezjail_jailbase} || exerr "Installation of ${dir} failed." | 180 | find ${dir} | cpio -d -p -v "${ezjail_jailbase}" || exerr "Installation of ${dir} failed." |
148 | chflags -R noschg ${dir}; rm -r ${dir}; ln -s /basejail/${dir} ${dir} | 181 | chflags -R noschg ${dir}; rm -r ${dir}; ln -s /basejail/${dir} ${dir} |
149 | done | 182 | done |
150 | mkdir basejail | 183 | mkdir basejail |
151 | 184 | ||
152 | # Try to remove the old template jail | 185 | # Try to remove the old template jail |
153 | [ -d ${ezjail_jailtemplate} ] && chflags -R noschg ${ezjail_jailtemplate} && rm -rf ${ezjail_jailtemplate} | 186 | [ -d "${ezjail_jailtemplate}" ] && chflags -R noschg "${ezjail_jailtemplate}" && rm -rf "${ezjail_jailtemplate}" |
154 | mv ${ezjail_jailfull} ${ezjail_jailtemplate} | 187 | mv "${ezjail_jailfull}" "${ezjail_jailtemplate}" |
155 | 188 | ||
156 | # If the default flavour example has not yet been copied, do it now | 189 | # If the default flavour example has not yet been copied, do it now |
157 | [ -d ${ezjail_flavours}/default ] || mkdir -p ${ezjail_flavours} && cp -p -R ${ezjail_examples}/default ${ezjail_flavours} | 190 | [ -d "${ezjail_flavours}/default" ] || mkdir -p "${ezjail_flavours}" && cp -p -R "${ezjail_examples}/default" "${ezjail_flavours}" |
158 | 191 | ||
159 | # no /usr/ports? link to /basejail/usr/ports | 192 | # no /usr/ports? link to /basejail/usr/ports |
160 | [ -e ${ezjail_jailtemplate}/usr/ports ] || ln -s /basejail/usr/ports ${ezjail_jailtemplate}/usr/ports | 193 | [ -e "${ezjail_jailtemplate}/usr/ports" ] || ln -s /basejail/usr/ports "${ezjail_jailtemplate}/usr/ports" |
161 | 194 | ||
162 | # A ports collection inside jails is hardly useful w/o an appropriate | 195 | # A ports collection inside jails is hardly useful w/o an appropriate |
163 | # /etc/make.conf. | 196 | # /etc/make.conf. |
164 | if [ -f ${ezjail_examples}/default/etc/make.conf -a ! -f ${ezjail_jailtemplate}/etc/make.conf ]; then | 197 | if [ -f "${ezjail_examples}/default/etc/make.conf" -a ! -f "${ezjail_jailtemplate}/etc/make.conf" ]; then |
165 | cp -p ${ezjail_examples}/default/etc/make.conf ${ezjail_jailtemplate}/etc/ | 198 | cp -p "${ezjail_examples}/default/etc/make.conf" "${ezjail_jailtemplate}/etc/" |
166 | echo "Note: a non-standard /etc/make.conf was copied to the template jail in order to get the ports collection running inside jails." | 199 | echo "Note: a non-standard /etc/make.conf was copied to the template jail in order to get the ports collection running inside jails." |
167 | fi | 200 | fi |
168 | 201 | ||
169 | # The ugly perl hack[tm]. Note: we wont do such things for any given | 202 | # The ugly perl hack[tm]. Note: we wont do such things for any given |
170 | # port :( | 203 | # port :( |
171 | [ "${ezjail_uglyperlhack}" = "YES" -a ! -L ${ezjail_jailbase}/usr/bin/perl ] && ln -s /usr/local/bin/perl ${ezjail_jailbase}/usr/bin/perl | 204 | [ "${ezjail_uglyperlhack}" = "YES" -a ! -L "${ezjail_jailbase}/usr/bin/perl" ] && ln -s /usr/local/bin/perl "${ezjail_jailbase}/usr/bin/perl" |
172 | } | 205 | } |
173 | 206 | ||
174 | # The user may want to have a ports tree in basejail | 207 | # The user may want to have a ports tree in basejail |
@@ -176,18 +209,18 @@ ezjail_updateports () { | |||
176 | local _portsnap_fetch="fetch" | 209 | local _portsnap_fetch="fetch" |
177 | # if /usr/ports/CVS exists, assume cvs up is safe | 210 | # if /usr/ports/CVS exists, assume cvs up is safe |
178 | # this is legacy | 211 | # this is legacy |
179 | if [ -f ${ezjail_jailbase}/usr/ports/CVS/Root ]; then | 212 | if [ -f "${ezjail_jailbase}/usr/ports/CVS/Root" ]; then |
180 | echo -n "Updating ports from "; cat ${ezjail_jailbase}/usr/ports/CVS/Root | 213 | echo -n "Updating ports from "; cat "${ezjail_jailbase}/usr/ports/CVS/Root" |
181 | echo "Warning: Upgrading legacy ports copy. Consider removing ${ezjail_jailbase}/usr/ports and use the new portsnap strategy instead." | 214 | echo "Warning: Upgrading legacy ports copy. Consider removing ${ezjail_jailbase}/usr/ports and use the new portsnap strategy instead." |
182 | echo "Gathering local information may take a while." | 215 | echo "Gathering local information may take a while." |
183 | cd ${ezjail_jailbase}/usr/ports/ && cvs -d ${ezjail_portscvsroot} up -Pd | 216 | cd "${ezjail_jailbase}/usr/ports/" && cvs -d "${ezjail_portscvsroot}" up -Pd |
184 | else | 217 | else |
185 | [ -z "$TERM" -o "$TERM" = dumb ] && _portsnap_fetch="cron" | 218 | [ -z "$TERM" -o "$TERM" = "dumb" ] && _portsnap_fetch="cron" |
186 | portsnap ${_portsnap_fetch} | 219 | portsnap ${_portsnap_fetch} |
187 | [ -d ${ezjail_jailbase}/usr/ports ] && ezjail_portsnapaction=update | 220 | [ -d "${ezjail_jailbase}/usr/ports" ] && ezjail_portsnapaction="update" |
188 | portsnap -p ${ezjail_jailbase}/usr/ports ${ezjail_portsnapaction:-"extract"} | 221 | portsnap -p "${ezjail_jailbase}/usr/ports" ${ezjail_portsnapaction:-"extract"} |
189 | fi | 222 | fi |
190 | [ $? = 0 ] || exerr "Updating ports failed." | 223 | [ $? -eq 0 ] || exerr "Updating ports failed." |
191 | } | 224 | } |
192 | 225 | ||
193 | # Try to fetch the list of releases the server provides | 226 | # Try to fetch the list of releases the server provides |
@@ -200,7 +233,7 @@ ezjail_queryftpserver () { | |||
200 | echo "Warning: I am having problems querying the ftp server you specified (${ezjail_ftphost})." | 233 | echo "Warning: I am having problems querying the ftp server you specified (${ezjail_ftphost})." |
201 | _ret=1; break | 234 | _ret=1; break |
202 | fi | 235 | fi |
203 | ezjail_ftpresponse=`echo ls | ftp ${ezjail_ftphost}:${ezjail_path}/${ezjail_installarch}/ 2> /dev/null` 2> /dev/null | 236 | ezjail_ftpresponse=`echo ls | ftp "${ezjail_ftphost}:${ezjail_path}/${ezjail_installarch}/" 2> /dev/null` 2> /dev/null |
204 | if [ $? -eq 0 ]; then | 237 | if [ $? -eq 0 ]; then |
205 | echo -e "The ftp server you specified (${ezjail_ftphost}) seems to provide the following builds:\n${ezjail_ftpresponse}" | 238 | echo -e "The ftp server you specified (${ezjail_ftphost}) seems to provide the following builds:\n${ezjail_ftpresponse}" |
206 | _ret=0; break 2 | 239 | _ret=0; break 2 |
@@ -222,17 +255,17 @@ case "$1" in | |||
222 | ######################## ezjail-admin CREATE ######################## | 255 | ######################## ezjail-admin CREATE ######################## |
223 | create) | 256 | create) |
224 | # Clean variables, prevent polution | 257 | # Clean variables, prevent polution |
225 | unset ezjail_rootdir ezjail_flavour ezjail_softlink ezjail_image ezjail_imagetype ezjail_imageparams ezjail_imagesize ezjail_device ezjail_config ezjail_attachparams ezjail_exists ezjail_attachblocking ezjail_forceblocking ezjail_sourcedevice ezjail_rootdirempty ezjail_fromarchive | 258 | 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 |
226 | shift; while getopts :f:r:s:xbic:C:a: arg; do case ${arg} in | 259 | shift; while getopts :f:r:s:xbic:C:a: arg; do case ${arg} in |
227 | x) ezjail_exists="YES";; | 260 | x) ezjail_exists="YES";; |
228 | r) ezjail_rootdir="${OPTARG}";; | 261 | r) ezjail_rootdir=${OPTARG};; |
229 | f) ezjail_flavour="${OPTARG}";; | 262 | f) ezjail_flavour=${OPTARG};; |
230 | a) ezjail_fromarchive="${OPTARG}";; | 263 | a) ezjail_fromarchive=${OPTARG};; |
231 | c) ezjail_imagetype="${OPTARG}";; | 264 | c) ezjail_imagetype=${OPTARG};; |
232 | C) ezjail_imageparams="${OPTARG}";; | 265 | C) ezjail_imageparams=${OPTARG};; |
233 | b) ezjail_forceblocking="YES";; | 266 | b) ezjail_forceblocking="YES";; |
234 | i) ezjail_imagetype=${ezjail_imagetype:-"simple"};; | 267 | i) ezjail_imagetype=${ezjail_imagetype:-"simple"};; |
235 | s) ezjail_imagesize="${OPTARG}";; | 268 | s) ezjail_imagesize=${OPTARG};; |
236 | ?) exerr ${ezjail_usage_create};; | 269 | ?) exerr ${ezjail_usage_create};; |
237 | esac; done; shift $(( ${OPTIND} - 1 )) | 270 | esac; done; shift $(( ${OPTIND} - 1 )) |
238 | 271 | ||
@@ -242,7 +275,7 @@ create) | |||
242 | [ "${ezjail_name}" -a "${ezjail_ip}" -a $# -eq 2 ] || exerr ${ezjail_usage_create} | 275 | [ "${ezjail_name}" -a "${ezjail_ip}" -a $# -eq 2 ] || exerr ${ezjail_usage_create} |
243 | 276 | ||
244 | # check for sanity of settings concerning the image feature | 277 | # check for sanity of settings concerning the image feature |
245 | [ "${ezjail_imagetype}" -a -z "${ezjail_exists}" -a -z "${ezjail_imagesize}" ] && exerr "Image jails need an image size." | 278 | [ -z "${ezjail_imagetype}" -o "${ezjail_exists}" -o "${ezjail_imagesize}" ] || exerr "Image jails need an image size." |
246 | 279 | ||
247 | # check for a sane image type | 280 | # check for a sane image type |
248 | case ${ezjail_imagetype} in ""|simple|bde|eli) ;; *) exerr ${ezjail_usage_create};; esac | 281 | case ${ezjail_imagetype} in ""|simple|bde|eli) ;; *) exerr ${ezjail_usage_create};; esac |
@@ -257,7 +290,7 @@ create) | |||
257 | 290 | ||
258 | # check, whether ezjail has been set up correctly. existence of | 291 | # check, whether ezjail has been set up correctly. existence of |
259 | # ezjail_jailbase is our indicator | 292 | # ezjail_jailbase is our indicator |
260 | [ -d ${ezjail_jailbase} ] || exerr "Error: base jail does not exist. Please run '${ezjail_admin} install' or '${ezjail_admin} update' first." | 293 | [ -d "${ezjail_jailbase}" ] || exerr "Error: base jail does not exist. Please run '${ezjail_admin} install' or '${ezjail_admin} update' first." |
261 | 294 | ||
262 | # relative paths don't make sense in rc.scripts | 295 | # relative paths don't make sense in rc.scripts |
263 | [ "${ezjail_jaildir%%[!/]*}" ] || exerr "Error: Need an absolute path in ezjail_jaildir, it currently is set to: ${ezjail_jaildir}." | 296 | [ "${ezjail_jaildir%%[!/]*}" ] || exerr "Error: Need an absolute path in ezjail_jaildir, it currently is set to: ${ezjail_jaildir}." |
@@ -266,10 +299,10 @@ create) | |||
266 | # was done intentionally to permit foo.com style directory names, however, | 299 | # was done intentionally to permit foo.com style directory names, however, |
267 | # the jail name will be foo_com in most scripts | 300 | # the jail name will be foo_com in most scripts |
268 | 301 | ||
269 | ezjail_hostname=`echo -n ${ezjail_name} | tr '/~' '__'` | 302 | ezjail_hostname=`echo -n "${ezjail_name}" | tr '/~' '__'` |
270 | ezjail_safename=`echo -n "${ezjail_name}" | tr -c '[:alnum:]' _` | 303 | ezjail_safename=`echo -n "${ezjail_name}" | tr -c '[:alnum:]' _` |
271 | ezjail_rootdir=${ezjail_rootdir:-"${ezjail_jaildir}/${ezjail_hostname}"} | 304 | ezjail_rootdir=${ezjail_rootdir:-"${ezjail_jaildir}/${ezjail_hostname}"} |
272 | ezjail_config=${ezjail_jailcfgs}/${ezjail_safename} | 305 | ezjail_config="${ezjail_jailcfgs}/${ezjail_safename}" |
273 | 306 | ||
274 | # This scenario really will only lead to real troubles in the 'fulljail' | 307 | # This scenario really will only lead to real troubles in the 'fulljail' |
275 | # case, but I should still explain this to the user and not claim that | 308 | # case, but I should still explain this to the user and not claim that |
@@ -278,48 +311,48 @@ create) | |||
278 | 311 | ||
279 | # jail names may lead to identical configs, eg. foo.bar.com == foo-bar.com | 312 | # jail names may lead to identical configs, eg. foo.bar.com == foo-bar.com |
280 | # so check, whether we might be running into problems | 313 | # so check, whether we might be running into problems |
281 | [ -e ${ezjail_config} -o -e ${ezjail_config}.norun ] && exerr "Error: an ezjail config already exists at ${ezjail_config}. Please rename the ezjail." | 314 | [ -e "${ezjail_config}" -o -e "${ezjail_config}.norun" ] && exerr "Error: an ezjail config already exists at ${ezjail_config}. Please rename the ezjail." |
282 | 315 | ||
283 | # if jail root specified on command line is not absolute, make it absolute | 316 | # if jail root specified on command line is not absolute, make it absolute |
284 | # inside our jail directory | 317 | # inside our jail directory |
285 | [ "${ezjail_rootdir%%[!/]*}" ] || ezjail_rootdir=${ezjail_jaildir}/${ezjail_rootdir} | 318 | [ "${ezjail_rootdir%%[!/]*}" ] || ezjail_rootdir="${ezjail_jaildir}/${ezjail_rootdir}" |
286 | 319 | ||
287 | # if a directory at the specified jail root already exists, refuse to | 320 | # if a directory at the specified jail root already exists, refuse to |
288 | # install. Empty root dirs are considered okay, sometimes they are | 321 | # install. Empty root dirs are considered okay, sometimes they are |
289 | # mount points to be filled by ezjail. | 322 | # mount points to be filled by ezjail. |
290 | [ -d ${ezjail_rootdir} ] && [ -z "`ls -I ${ezjail_rootdir}`" ] && ezjail_rootdirempty="YES" | 323 | [ -d "${ezjail_rootdir}" ] && [ -z "`ls -I ${ezjail_rootdir}`" ] && ezjail_rootdirempty="YES" |
291 | [ -e ${ezjail_rootdir} -a -z "${ezjail_rootdirempty}" -a -z "${ezjail_exists}" ] && exerr "Error: the specified jail root ${ezjail_rootdir} already exists." | 324 | [ -e "${ezjail_rootdir}" -a -z "${ezjail_rootdirempty}" -a -z "${ezjail_exists}" ] && exerr "Error: the specified jail root ${ezjail_rootdir} already exists." |
292 | 325 | ||
293 | # if jail root specified on command line does not lie within our jail | 326 | # if jail root specified on command line does not lie within our jail |
294 | # directory, we need to create a softlink | 327 | # directory, we need to create a softlink |
295 | if [ "${ezjail_rootdir##${ezjail_jaildir}}" = "${ezjail_rootdir}" ]; then | 328 | if [ "${ezjail_rootdir##${ezjail_jaildir}}" = "${ezjail_rootdir}" ]; then |
296 | ezjail_softlink=${ezjail_jaildir}/`basename -- ${ezjail_rootdir}` | 329 | ezjail_softlink=${ezjail_jaildir}/`basename -- "${ezjail_rootdir}"` |
297 | [ -e ${ezjail_softlink} ] && exerr "Error: an ezjail already exists at ${ezjail_softlink}." | 330 | [ -e "${ezjail_softlink}" ] && exerr "Error: an ezjail already exists at ${ezjail_softlink}." |
298 | fi | 331 | fi |
299 | 332 | ||
300 | # do some sanity checks on the selected flavour (if any) | 333 | # do some sanity checks on the selected flavour (if any) |
301 | [ "${ezjail_flavour}" -a ! -d ${ezjail_flavours}/${ezjail_flavour} ] && exerr "Error: Flavour config directory ${ezjail_flavours}/${ezjail_flavour} not found." | 334 | [ "${ezjail_flavour}" -a ! -d "${ezjail_flavours}/${ezjail_flavour}" ] && exerr "Error: Flavour config directory ${ezjail_flavours}/${ezjail_flavour} not found." |
302 | 335 | ||
303 | # check for restore circumstances, normally this is invoked by the restore command | 336 | # check for restore circumstances, normally this is invoked by the restore command |
304 | [ "${ezjail_fromarchive}" -a "${ezjail_exists}" ] && exerr "Error: Cannot restore a jail that exists." | 337 | [ "${ezjail_fromarchive}" -a "${ezjail_exists}" ] && exerr "Error: Cannot restore a jail that exists." |
305 | [ "${ezjail_fromarchive}" -a "${ezjail_flavour}" ] && exerr "Error: Cannot apply flavours to a restored jail." | 338 | [ "${ezjail_fromarchive}" -a "${ezjail_flavour}" ] && exerr "Error: Cannot apply flavours to a restored jail." |
306 | [ "${ezjail_fromarchive}" -a ! -r ${ezjail_fromarchive} ] && exerr "Error: Cannot restore from non existing archive: ${ezjail_fromarchive}." | 339 | [ "${ezjail_fromarchive}" -a ! -r "${ezjail_fromarchive}" ] && exerr "Error: Cannot restore from non existing archive: ${ezjail_fromarchive}." |
307 | 340 | ||
308 | # | 341 | # |
309 | # All sanity checks that may lead to errors are hopefully passed here | 342 | # All sanity checks that may lead to errors are hopefully passed here |
310 | # | 343 | # |
311 | 344 | ||
312 | if [ -n "${ezjail_imagetype}" ]; then | 345 | if [ "${ezjail_imagetype}" ]; then |
313 | # Strip trailing slashes from jail root, those would confuse image path | 346 | # Strip trailing slashes from jail root, those would confuse image path |
314 | ezjail_image=${ezjail_rootdir%/}; while [ "${ezjail_image}" -a -z "${ezjail_image%%*/}" ]; do ezjail_image=${ezjail_image%/}; done | 347 | ezjail_image=${ezjail_rootdir%/}; while [ "${ezjail_image}" -a -z "${ezjail_image%%*/}" ]; do ezjail_image=${ezjail_image%/}; done |
315 | [ -z "${ezjail_image}" ] && exerr "Error: Could not determine image file name, something is wrong with the jail root: ${ezjail_rootdir}." | 348 | [ "${ezjail_image}" ] || exerr "Error: Could not determine image file name, something is wrong with the jail root: ${ezjail_rootdir}." |
316 | 349 | ||
317 | # Location of our image file | 350 | # Location of our image file |
318 | ezjail_image="${ezjail_image}.img" | 351 | ezjail_image="${ezjail_image}.img" |
319 | 352 | ||
320 | # Prepare crypto jail so that an attacker cannot guess which blocks | 353 | # Prepare crypto jail so that an attacker cannot guess which blocks |
321 | # have been written | 354 | # have been written |
322 | case ${ezjail_imagetype} in bde|eli) ezjail_sourcedevice=/dev/random;; simple) ezjail_sourcedevice=/dev/zero;; esac | 355 | case ${ezjail_imagetype} in bde|eli) ezjail_sourcedevice="/dev/random";; simple) ezjail_sourcedevice="/dev/zero";; esac |
323 | 356 | ||
324 | # If NOT exist, create image | 357 | # If NOT exist, create image |
325 | if [ -z "${ezjail_exists}" ]; then | 358 | if [ -z "${ezjail_exists}" ]; then |
@@ -329,36 +362,38 @@ create) | |||
329 | touch "${ezjail_image}" | 362 | touch "${ezjail_image}" |
330 | echo "Creating jail image ${ezjail_image}. This may take a while." | 363 | echo "Creating jail image ${ezjail_image}. This may take a while." |
331 | if [ "${ezjail_imageblockcount}" -gt 0 ]; then | 364 | if [ "${ezjail_imageblockcount}" -gt 0 ]; then |
332 | dd if=${ezjail_sourcedevice} of="${ezjail_image}" bs=1m count=${ezjail_imageblockcount} || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." | 365 | dd if="${ezjail_sourcedevice}" of="${ezjail_image}" bs=1m count=${ezjail_imageblockcount} || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." |
333 | fi | 366 | fi |
334 | if [ "${ezjail_imagerestbytes}" -gt 0 ]; then | 367 | if [ "${ezjail_imagerestbytes}" -gt 0 ]; then |
335 | ( dd if=${ezjail_sourcedevice} bs=${ezjail_imagerestbytes} count=1 >> "${ezjail_image}" ) || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." | 368 | ( dd if="${ezjail_sourcedevice}" bs=${ezjail_imagerestbytes} count=1 >> "${ezjail_image}" ) || exerr "Error: Could not (or not fully) create the image file. You might want to check (and possibly remove) the file ${ezjail_image}. The image size provided was ${ezjail_imagesize}." |
336 | fi | 369 | fi |
337 | 370 | ||
338 | # Attach device | 371 | # Attach device |
339 | ezjail_imagedevice=`mdconfig -a -t vnode -f ${ezjail_image}` | 372 | ezjail_imagedevice=`mdconfig -a -t vnode -f "${ezjail_image}"` |
340 | [ $? = 0 ] || detach_images || exerr "Error: Could not attach image device. (Command failed was 'mdconfig -a -t vnode -f ${ezjail_image}')" | 373 | ezjail_devicelink="${ezjail_rootdir}.device" |
341 | case "${ezjail_imagetype}" in | 374 | |
375 | [ $? -eq 0 ] || detach_images || exerr "Error: Could not attach image device. (Command failed was 'mdconfig -a -t vnode -f ${ezjail_image}')" | ||
376 | case ${ezjail_imagetype} in | ||
342 | bde|eli) | 377 | bde|eli) |
343 | # parse imageparams, generate attachparams | 378 | # parse imageparams, generate attachparams |
344 | ezjail_attachblocking="YES" | 379 | ezjail_attachblocking="YES" |
345 | if [ -n "${ezjail_imageparams}" ]; then | 380 | if [ "${ezjail_imageparams}" ]; then |
346 | ezjail_attachparams=`echo $0 _parse_g${ezjail_imagetype}_attach_args_ ${ezjail_imageparams} | /bin/sh` | 381 | ezjail_attachparams=`echo $0 _parse_g${ezjail_imagetype}_attach_args_ ${ezjail_imageparams} | /bin/sh` |
347 | [ 5 -eq $? ] && exerr "processing of ezjail_imageparams failed" | 382 | [ 5 -eq $? ] && exerr "processing of ezjail_imageparams failed" |
348 | [ 3 -eq $? ] && unset ezjail_attachblocking | 383 | [ 3 -eq $? ] && unset ezjail_attachblocking |
349 | fi | 384 | fi |
350 | case "${ezjail_imagetype}" in | 385 | case ${ezjail_imagetype} in |
351 | bde) init_cmd="gbde init /dev/${ezjail_imagedevice} ${ezjail_imageparams}" | 386 | bde) init_cmd="gbde init /dev/${ezjail_imagedevice} ${ezjail_imageparams}" |
352 | attach_cmd="gbde attach /dev/${ezjail_imagedevice} ${ezjail_attachparams}";; | 387 | attach_cmd="gbde attach /dev/${ezjail_imagedevice} ${ezjail_attachparams}";; |
353 | eli) init_cmd="geli init ${ezjail_imageparams} /dev/${ezjail_imagedevice}" | 388 | eli) init_cmd="geli init ${ezjail_imageparams} /dev/${ezjail_imagedevice}" |
354 | attach_cmd="geli attach ${ezjail_attachparams} /dev/${ezjail_imagedevice}";; | 389 | attach_cmd="geli attach ${ezjail_attachparams} /dev/${ezjail_imagedevice}";; |
355 | esac | 390 | esac |
356 | [ -n "${ezjail_attachblocking}" ] && echo "Initialising crypto device. Enter a new passphrase twice... " | 391 | [ "${ezjail_attachblocking}" ] && echo "Initialising crypto device. You will be asked to enter a new passphrase twice... " |
357 | ( echo ${init_cmd} | /bin/sh ) || detach_images || exerr "Error: Could not initialise crypto image." | 392 | ( echo ${init_cmd} | /bin/sh ) || detach_images || exerr "Error: Could not initialise crypto image." |
358 | 393 | ||
359 | [ -n "${ezjail_attachblocking}" ] && echo "Attaching crypto device. Enter the passphrase... " | 394 | [ "${ezjail_attachblocking}" ] && echo "Attaching crypto device. You will be asked to enter the new passphrase... " |
360 | ( echo ${attach_cmd} | /bin/sh ) || detach_images || exerr "Error: Could not attach crypto image." | 395 | ( echo ${attach_cmd} | /bin/sh ) || detach_images || exerr "Error: Could not attach crypto image." |
361 | ezjail_device=${ezjail_imagedevice}.${ezjail_imagetype} | 396 | ezjail_device="${ezjail_imagedevice}.${ezjail_imagetype}" |
362 | ;; | 397 | ;; |
363 | simple) | 398 | simple) |
364 | ezjail_device=${ezjail_imagedevice} | 399 | ezjail_device=${ezjail_imagedevice} |
@@ -366,39 +401,38 @@ create) | |||
366 | esac | 401 | esac |
367 | 402 | ||
368 | # Format memory image | 403 | # Format memory image |
369 | newfs -U /dev/${ezjail_device} || detach_images || exerr "Error: Could not newfs /dev/${ezjail_device}." | 404 | newfs -U "/dev/${ezjail_device}" || detach_images || exerr "Error: Could not newfs /dev/${ezjail_device}." |
370 | # Create mount point and mount | 405 | # Create mount point and mount |
371 | mkdir -p ${ezjail_rootdir} || detach_images || exerr "Error: Could not create jail root mount point ${ezjail_rootdir}." | 406 | mkdir -p "${ezjail_rootdir}" || detach_images || exerr "Error: Could not create jail root mount point ${ezjail_rootdir}." |
372 | mount /dev/${ezjail_device} ${ezjail_rootdir} || detach_images || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_root}." | 407 | mount "/dev/${ezjail_device}" "${ezjail_rootdir}" || detach_images || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_root}." |
373 | else | 408 | else |
374 | [ -e ${ezjail_rootdir} -a ! -d ${ezjail_rootdir} ] && exerr "Error: Could not create mount point for your jail image. A file exists at its location. (For existing image jails, call this tool without the .img suffix when specifying jail root.)" | 409 | [ -e "${ezjail_rootdir}" -a ! -d "${ezjail_rootdir}" ] && exerr "Error: Could not create mount point for your jail image. A file exists at its location. (For existing image jails, call this tool without the .img suffix when specifying jail root.)" |
375 | [ -d ${ezjail_rootdir} ] || mkdir -p ${ezjail_rootdir} | 410 | [ -d "${ezjail_rootdir}" ] || mkdir -p "${ezjail_rootdir}" |
376 | fi | 411 | fi |
377 | fi | 412 | fi |
378 | 413 | ||
379 | if [ "${ezjail_fromarchive}" ]; then | 414 | if [ "${ezjail_fromarchive}" ]; then |
380 | mkdir -p ${ezjail_rootdir} && tar xfp ${ezjail_fromarchive} -C ${ezjail_rootdir} --strip-components 1 ezjail | 415 | mkdir -p "${ezjail_rootdir}" && tar xfp "${ezjail_fromarchive}" -C "${ezjail_rootdir}" --strip-components 1 ezjail |
381 | [ $? = 0 ] || detach_images || exerr "Error: Could not extract archive from ${ezjail_fromarchive}." | 416 | [ $? -eq 0 ] || detach_images || exerr "Error: Could not extract archive from ${ezjail_fromarchive}." |
382 | elif [ -z "${ezjail_exists}" ]; then | 417 | elif [ -z "${ezjail_exists}" ]; then |
383 | # now take a copy of our template jail | 418 | # now take a copy of our template jail |
384 | mkdir -p ${ezjail_rootdir} && cd ${ezjail_jailtemplate} && find * | cpio -p -v ${ezjail_rootdir} > /dev/null | 419 | mkdir -p "${ezjail_rootdir}" && cd "${ezjail_jailtemplate}" && find * | cpio -p -v "${ezjail_rootdir}" > /dev/null |
385 | [ $? = 0 ] || detach_images || exerr "Error: Could not copy template jail." | 420 | [ $? -eq 0 ] || detach_images || exerr "Error: Could not copy template jail." |
386 | fi | 421 | fi |
387 | 422 | ||
388 | |||
389 | # if a soft link is necessary, create it now | 423 | # if a soft link is necessary, create it now |
390 | [ "${ezjail_softlink}" ] && ln -s ${ezjail_rootdir} ${ezjail_softlink} | 424 | [ "${ezjail_softlink}" ] && ln -s "${ezjail_rootdir}" "${ezjail_softlink}" |
391 | 425 | ||
392 | # if the automount feature is not disabled, this fstab entry for new jail | 426 | # if the automount feature is not disabled, this fstab entry for new jail |
393 | # will be obeyed | 427 | # will be obeyed |
394 | echo -n > /etc/fstab.${ezjail_safename} | 428 | echo -n > /etc/fstab.${ezjail_safename} |
395 | [ -n "${ezjail_imagetype}" ] && \ | 429 | [ "${ezjail_imagetype}" ] && \ |
396 | echo ${ezjail_rootdir}.device ${ezjail_rootdir} ufs rw 0 0 >> /etc/fstab.${ezjail_safename} | 430 | echo ${ezjail_devicelink} ${ezjail_rootdir} ufs rw 0 0 >> "/etc/fstab.${ezjail_safename}" |
397 | echo ${ezjail_jailbase} ${ezjail_rootdir}/basejail nullfs ro 0 0 >> /etc/fstab.${ezjail_safename} | 431 | echo ${ezjail_jailbase} ${ezjail_rootdir}/basejail nullfs ro 0 0 >> "/etc/fstab.${ezjail_safename}" |
398 | 432 | ||
399 | # now, where everything seems to have gone right, create control file in | 433 | # now, where everything seems to have gone right, create control file in |
400 | # ezjails config dir | 434 | # ezjails config dir |
401 | mkdir -p ${ezjail_jailcfgs} || exerr "Error: can't create ezjails control directory (${ezjail_jailcfgs})." | 435 | mkdir -p "${ezjail_jailcfgs}" || exerr "Error: can't create ezjails control directory (${ezjail_jailcfgs})." |
402 | ( echo -e "# To specify the start up order of your ezjails, use these lines to\n# create a Jail dependency tree. See rcorder(8) for more details." | 436 | ( echo -e "# To specify the start up order of your ezjails, use these lines to\n# create a Jail dependency tree. See rcorder(8) for more details." |
403 | echo -e "#\n# PROVIDE: standard_ezjail\n# REQUIRE: \n# BEFORE: \n#\n" | 437 | echo -e "#\n# PROVIDE: standard_ezjail\n# REQUIRE: \n# BEFORE: \n#\n" |
404 | echo export jail_${ezjail_safename}_hostname=\"${ezjail_hostname}\" | 438 | echo export jail_${ezjail_safename}_hostname=\"${ezjail_hostname}\" |
@@ -415,21 +449,21 @@ create) | |||
415 | echo export jail_${ezjail_safename}_attachparams=\"${ezjail_attachparams}\" | 449 | echo export jail_${ezjail_safename}_attachparams=\"${ezjail_attachparams}\" |
416 | echo export jail_${ezjail_safename}_attachblocking=\"${ezjail_attachblocking}\" | 450 | echo export jail_${ezjail_safename}_attachblocking=\"${ezjail_attachblocking}\" |
417 | echo export jail_${ezjail_safename}_forceblocking=\"${ezjail_forceblocking}\" | 451 | echo export jail_${ezjail_safename}_forceblocking=\"${ezjail_forceblocking}\" |
418 | ) > ${ezjail_config} | 452 | ) > "${ezjail_config}" |
419 | 453 | ||
420 | # Final steps for flavour installation | 454 | # Final steps for flavour installation |
421 | if [ -z "${ezjail_exists}" -a -n "${ezjail_flavour}" ]; then | 455 | if [ -z "${ezjail_exists}" -a "${ezjail_flavour}" ]; then |
422 | # install files and config to new jail | 456 | # install files and config to new jail |
423 | cd ${ezjail_flavours}/${ezjail_flavour} && find * | cpio -p -u -v ${ezjail_rootdir} > /dev/null | 457 | cd "${ezjail_flavours}/${ezjail_flavour}" && find * | cpio -p -u -v "${ezjail_rootdir}" > /dev/null |
424 | [ $? = 0 ] || echo "Warning: Could not fully install flavour." | 458 | [ $? -eq 0 ] || echo "Warning: Could not fully install flavour." |
425 | 459 | ||
426 | # if the packages are links and not files we have to copy them now | 460 | # if the packages are links and not files we have to copy them now |
427 | find ${ezjail_rootdir}/pkg/ -type l -exec cp -r -f {} {}.ezjail \; -exec mv {}.ezjail {} \; | 461 | find "${ezjail_rootdir}/pkg/" -type l -exec cp -r -f {} {}.ezjail \; -exec mv {}.ezjail {} \; |
428 | 462 | ||
429 | # If a config is found, make it auto run on jails startup | 463 | # If a config is found, make it auto run on jails startup |
430 | if [ -f ${ezjail_rootdir}/ezjail.flavour ]; then | 464 | if [ -f "${ezjail_rootdir}/ezjail.flavour" ]; then |
431 | ln -s /ezjail.flavour ${ezjail_rootdir}/etc/rc.d/ezjail-config.sh | 465 | ln -s /ezjail.flavour "${ezjail_rootdir}/etc/rc.d/ezjail-config.sh" |
432 | chmod 0700 ${ezjail_rootdir}/ezjail.flavour | 466 | chmod 0700 "${ezjail_rootdir}/ezjail.flavour" |
433 | echo "Note: Shell scripts installed, flavourizing on jails first startup." | 467 | echo "Note: Shell scripts installed, flavourizing on jails first startup." |
434 | fi | 468 | fi |
435 | fi | 469 | fi |
@@ -443,26 +477,27 @@ create) | |||
443 | 477 | ||
444 | # check, whether IP is configured on a local interface, warn if it isnt | 478 | # check, whether IP is configured on a local interface, warn if it isnt |
445 | ping -c 1 -m 1 -t 1 -q ${ezjail_ip} > /dev/null | 479 | ping -c 1 -m 1 -t 1 -q ${ezjail_ip} > /dev/null |
446 | [ $? = 0 ] || echo "Warning: IP ${ezjail_ip} not configured on a local interface." | 480 | [ $? -eq 0 ] || echo "Warning: IP ${ezjail_ip} not configured on a local interface." |
447 | 481 | ||
448 | # check, whether some host system services do listen on the Jails IP | 482 | # check, whether some host system services do listen on the Jails IP |
449 | TIFS=${IFS}; IFS=_ | 483 | TIFS=${IFS}; IFS=_ |
450 | ezjail_listener=`sockstat -4 -l | grep "${ezjail_ip}:[[:digit:]]"` | 484 | ezjail_listener=`sockstat -4 -l | grep "${ezjail_ip}:[[:digit:]]"` |
451 | [ $? = 0 ] && echo -e "Warning: Some services already seem to be listening on IP ${ezjail_ip}\n This may cause some confusion, here they are:\n${ezjail_listener}" | 485 | [ $? -eq 0 ] && echo -e "Warning: Some services already seem to be listening on IP ${ezjail_ip}\n This may cause some confusion, here they are:\n${ezjail_listener}" |
452 | 486 | ||
453 | ezjail_listener=`sockstat -4 -l | grep "*:[[:digit:]]"` | 487 | ezjail_listener=`sockstat -4 -l | grep "*:[[:digit:]]"` |
454 | [ $? = 0 ] && echo -e "Warning: Some services already seem to be listening on all IP, (including ${ezjail_ip})\n This may cause some confusion, here they are:\n${ezjail_listener}" | 488 | [ $? -eq 0 ] && echo -e "Warning: Some services already seem to be listening on all IP, (including ${ezjail_ip})\n This may cause some confusion, here they are:\n${ezjail_listener}" |
455 | IFS=${TIFS} | 489 | IFS=${TIFS} |
456 | 490 | ||
457 | [ -n "${ezjail_imagetype}" ] && echo "Note: To administrate your image jail, attach it using the '${ezjail_admin} config -i attach ${ezjail_hostname}' command." | 491 | [ "${ezjail_imagetype}" ] && echo "Note: To administrate your image jail, attach it using the '${ezjail_admin} config -i attach ${ezjail_hostname}' command." |
458 | ;; | 492 | ;; |
459 | ######################## ezjail-admin DELETE ######################## | 493 | ######################## ezjail-admin DELETE ######################## |
460 | delete) | 494 | delete) |
461 | # Clean variables, prevent polution | 495 | # Clean variables, prevent polution |
462 | unset ezjail_wipeme | 496 | unset ezjail_wipeme ezjail_forcestop |
463 | 497 | ||
464 | shift; while getopts :w arg; do case ${arg} in | 498 | shift; while getopts :w arg; do case ${arg} in |
465 | w) ezjail_wipeme="YES";; | 499 | w) ezjail_wipeme="YES";; |
500 | f) ezjail_forcestop="YES";; | ||
466 | ?) exerr ${ezjail_usage_delete};; | 501 | ?) exerr ${ezjail_usage_delete};; |
467 | esac; done; shift $(( $OPTIND - 1 )) | 502 | esac; done; shift $(( $OPTIND - 1 )) |
468 | 503 | ||
@@ -473,25 +508,38 @@ delete) | |||
473 | fetchjailinfo $1 | 508 | fetchjailinfo $1 |
474 | 509 | ||
475 | # check for existence of jail in our records | 510 | # check for existence of jail in our records |
476 | [ -n "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." | 511 | [ "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." |
512 | |||
513 | if [ "${ezjail_id}" ]; then | ||
514 | # if jail is still running, refuse to go any further | ||
515 | [ "${ezjail_forcestop}" ] || exerr "Error: Jail appears to be still running, stop it first (or use delete -f for force stop)." | ||
477 | 516 | ||
478 | # if jail is still running, refuse to go any further | 517 | # This one will also exerr on failure |
479 | [ -n "${ezjail_id}" ] && exerr "Error: Jail appears to be still running, stop it first." | 518 | start_stop_jail_by_script stop |
519 | fi | ||
520 | |||
521 | if [ "${ezjail_attached}" ]; then | ||
522 | # if jail is attached and detach is not forced, refuse to go any further | ||
523 | [ "${ezjail_forcestop}" ] || exerr "Error: Jail image file ${ezjail_image} is attached as ${ezjail_device}. '${ezjail_admin} config -i detach' it first, or (or use delete -f for force detach)." | ||
524 | |||
525 | detach_images keep | ||
480 | 526 | ||
481 | # if jail is attached, refuse to go any further | 527 | # See, if it successfully detached |
482 | [ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} is attached as ${ezjail_device}. '${ezjail_admin} config -i detach' it first." | 528 | fetchjailinfo ${ezjail_name} |
529 | [ "${ezjail_attached}" ] && exerr "Error: Could not detach ${ezjail_name}. You need to detach it by hand." | ||
530 | fi | ||
483 | 531 | ||
484 | # now we know everything we need to let the jail be gone. remove entry | 532 | # now we know everything we need to let the jail be gone. remove entry |
485 | # from ezjail resource structure, delete fstab.JAILNAME | 533 | # from ezjail resource structure, delete fstab.JAILNAME |
486 | rm -f ${ezjail_config} /etc/fstab.${ezjail_safename} | 534 | rm -f "${ezjail_config}" "/etc/fstab.${ezjail_safename}" |
487 | 535 | ||
488 | # if there is a soft link pointing to the jail root, remove it | 536 | # if there is a soft link pointing to the jail root, remove it |
489 | [ -L ${ezjail_softlink} ] && rm ${ezjail_softlink} | 537 | [ -L "${ezjail_softlink}" ] && rm "${ezjail_softlink}" |
490 | 538 | ||
491 | # if wiping the jail was requested, remove it | 539 | # if wiping the jail was requested, remove it |
492 | if [ "${ezjail_wipeme}" ]; then | 540 | if [ "${ezjail_wipeme}" ]; then |
493 | [ "${ezjail_image}" ] && rm -f ${ezjail_image} ${ezjail_image%.img}.device | 541 | [ "${ezjail_image}" ] && rm -f "${ezjail_image}" "${ezjail_image%.img}.device" |
494 | rm -rf ${ezjail_rootdir} | 542 | rm -rf "${ezjail_rootdir}" |
495 | fi | 543 | fi |
496 | 544 | ||
497 | ;; | 545 | ;; |
@@ -508,11 +556,11 @@ list) | |||
508 | fetchjailinfo ${ezjail%.norun} | 556 | fetchjailinfo ${ezjail%.norun} |
509 | case ${ezjail_imagetype} in simple) ezjail_state="I";; bde) ezjail_state="B";; eli) ezjail_state="E";; *) ezjail_state="D";; esac | 557 | case ${ezjail_imagetype} in simple) ezjail_state="I";; bde) ezjail_state="B";; eli) ezjail_state="E";; *) ezjail_state="D";; esac |
510 | if [ "${ezjail_id}" ]; then | 558 | if [ "${ezjail_id}" ]; then |
511 | ezjail_state=${ezjail_state}R | 559 | ezjail_state="${ezjail_state}R" |
512 | else | 560 | else |
513 | [ -n "${ezjail_attached}" ] && ezjail_state=${ezjail_state}A || ezjail_state=${ezjail_state}S | 561 | [ "${ezjail_attached}" ] && ezjail_state="${ezjail_state}A" || ezjail_state="${ezjail_state}S" |
514 | fi | 562 | fi |
515 | [ "${ezjail_safename}" != "${ezjail}" ] && ezjail_state=${ezjail_state}N | 563 | [ "${ezjail_safename}" != "${ezjail}" ] && ezjail_state="${ezjail_state}N" |
516 | 564 | ||
517 | printf "%-3s %-5s %-15s %-28s %s\\n" "${ezjail_state}" "${ezjail_id:-N/A}" "${ezjail_ip}" "${ezjail_hostname}" "${ezjail_rootdir}" | 565 | printf "%-3s %-5s %-15s %-28s %s\\n" "${ezjail_state}" "${ezjail_id:-N/A}" "${ezjail_ip}" "${ezjail_hostname}" "${ezjail_rootdir}" |
518 | done | 566 | done |
@@ -526,7 +574,7 @@ setup|update) | |||
526 | 574 | ||
527 | shift; while getopts :ipPs: arg; do case ${arg} in | 575 | shift; while getopts :ipPs: arg; do case ${arg} in |
528 | i) ezjail_installaction="installworld";; | 576 | i) ezjail_installaction="installworld";; |
529 | s) ezjail_sourcetree="${OPTARG}";; | 577 | s) ezjail_sourcetree=${OPTARG};; |
530 | p) ezjail_provideports="YES";; | 578 | p) ezjail_provideports="YES";; |
531 | P) ezjail_provideports="YES"; ezjail_installaction="none";; | 579 | P) ezjail_provideports="YES"; ezjail_installaction="none";; |
532 | ?) exerr ${ezjail_usage_update};; | 580 | ?) exerr ${ezjail_usage_update};; |
@@ -537,21 +585,21 @@ setup|update) | |||
537 | if [ "${ezjail_installaction}" = "none" ]; then | 585 | if [ "${ezjail_installaction}" = "none" ]; then |
538 | # check, whether ezjail has been setup correctly. existence of | 586 | # check, whether ezjail has been setup correctly. existence of |
539 | # ezjail_jailbase is our indicator | 587 | # ezjail_jailbase is our indicator |
540 | [ -d ${ezjail_jailbase} ] || exerr "Error: base jail does not exist. You cannot fill base jails ports tree before creating it. Please run '${ezjail_admin} update' or '${ezjail_admin} install' first." | 588 | [ -d "${ezjail_jailbase}" ] || exerr "Error: base jail does not exist. You cannot fill base jails ports tree before creating it. Please run '${ezjail_admin} update' or '${ezjail_admin} install' first." |
541 | else | 589 | else |
542 | # Bump the user for some of the most common errors | 590 | # Bump the user for some of the most common errors |
543 | [ -d ${ezjail_sourcetree} ] || exerr "Cannot find your copy of the FreeBSD source tree in ${ezjail_sourcetree}." | 591 | [ -d "${ezjail_sourcetree}" ] || exerr "Cannot find your copy of the FreeBSD source tree in ${ezjail_sourcetree}." |
544 | [ -e ${ezjail_sourcetree}/Makefile ] || exerr "Your source tree in ${ezjail_sourcetree} seems to be incomplete (Makefile missing)." | 592 | [ -e "${ezjail_sourcetree}/Makefile" ] || exerr "Your source tree in ${ezjail_sourcetree} seems to be incomplete (Makefile missing)." |
545 | [ "`sysctl -n kern.securelevel`" -gt 0 ] && exerr "You're running in a secure level higher than 0. ezjail will not run correctly." | 593 | [ "`sysctl -n kern.securelevel`" -gt 0 ] && exerr "You're running in a secure level higher than 0. ezjail will not run correctly." |
546 | 594 | ||
547 | # Normally fulljail should be renamed by past ezjail-admin commands. | 595 | # Normally fulljail should be renamed by past ezjail-admin commands. |
548 | # However those may have failed | 596 | # However those may have failed |
549 | [ -d "${ezjail_jailfull}" ] && chflags -R noschg ${ezjail_jailfull} && rm -rf ${ezjail_jailfull} | 597 | [ -d "${ezjail_jailfull}" ] && chflags -R noschg "${ezjail_jailfull}" && rm -rf "${ezjail_jailfull}" |
550 | mkdir -p ${ezjail_jailfull} || exerr "Cannot create temporary Jail directory." | 598 | mkdir -p "${ezjail_jailfull}" || exerr "Cannot create temporary Jail directory." |
551 | 599 | ||
552 | # make and setup our world, then split basejail and newjail | 600 | # make and setup our world, then split basejail and newjail |
553 | cd ${ezjail_sourcetree} && env DESTDIR=${ezjail_jailfull} make ${ezjail_installaction} || exerr "make ${ezjail_installaction} failed." | 601 | cd "${ezjail_sourcetree}" && env DESTDIR="${ezjail_jailfull}" make ${ezjail_installaction} || exerr "make ${ezjail_installaction} failed." |
554 | cd ${ezjail_sourcetree}/etc && env DESTDIR=${ezjail_jailfull} make distribution || exerr "make distribution failed." | 602 | cd "${ezjail_sourcetree}/etc" && env DESTDIR="${ezjail_jailfull}" make distribution || exerr "make distribution failed." |
555 | ezjail_splitworld | 603 | ezjail_splitworld |
556 | 604 | ||
557 | fi # installaction="none" | 605 | fi # installaction="none" |
@@ -569,8 +617,8 @@ install) | |||
569 | m) ezjail_installmanpages=" manpages";; | 617 | m) ezjail_installmanpages=" manpages";; |
570 | s) ezjail_installsources=" src";; | 618 | s) ezjail_installsources=" src";; |
571 | p) ezjail_installports="YES";; | 619 | p) ezjail_installports="YES";; |
572 | h) ezjail_ftphost="${OPTARG}";; | 620 | h) ezjail_ftphost=${OPTARG};; |
573 | r) ezjail_release="${OPTARG}";; | 621 | r) ezjail_release=${OPTARG};; |
574 | ?) exerr ${ezjail_usage_install};; | 622 | ?) exerr ${ezjail_usage_install};; |
575 | esac; done; shift $(( ${OPTIND} - 1 )) | 623 | esac; done; shift $(( ${OPTIND} - 1 )) |
576 | 624 | ||
@@ -599,24 +647,24 @@ install) | |||
599 | 647 | ||
600 | # Normally fulljail should be renamed by past ezjail-admin commands. | 648 | # Normally fulljail should be renamed by past ezjail-admin commands. |
601 | # However those may have failed | 649 | # However those may have failed |
602 | [ -d "${ezjail_jailfull}" ] && chflags -R noschg ${ezjail_jailfull} && rm -rf ${ezjail_jailfull} | 650 | [ -d "${ezjail_jailfull}" ] && chflags -R noschg "${ezjail_jailfull}" && rm -rf "${ezjail_jailfull}" |
603 | mkdir -p ${ezjail_jailfull} || exerr "Cannot create temporary Jail directory." | 651 | mkdir -p "${ezjail_jailfull}" || exerr "Cannot create temporary Jail directory." |
604 | DESTDIR=${ezjail_jailfull} | 652 | DESTDIR=${ezjail_jailfull} |
605 | 653 | ||
606 | rm -rf ${ezjail_jailtemp} | 654 | rm -rf "${ezjail_jailtemp}" |
607 | for pkg in base ${ezjail_installmanpages} ${ezjail_installsources}; do | 655 | for pkg in base ${ezjail_installmanpages} ${ezjail_installsources}; do |
608 | 656 | ||
609 | # The first case means, that a remote host has been specified. | 657 | # The first case means, that a remote host has been specified. |
610 | if [ "${ezjail_dir}" = "${ezjail_ftphost}" ]; then | 658 | if [ "${ezjail_dir}" = "${ezjail_ftphost}" ]; then |
611 | # Create and try to access temp dir | 659 | # Create and try to access temp dir |
612 | mkdir -p ${ezjail_jailtemp} || exerr "Could not create temporary base jail directory ${ezjail_jailtemp}." | 660 | mkdir -p "${ezjail_jailtemp}" || exerr "Could not create temporary base jail directory ${ezjail_jailtemp}." |
613 | cd ${ezjail_jailtemp} || exerr "Could not cd to ${ezjail_jailtemp}." | 661 | cd "${ezjail_jailtemp}" || exerr "Could not cd to ${ezjail_jailtemp}." |
614 | 662 | ||
615 | # Try all paths as stolen from sysinstall, break on success. | 663 | # Try all paths as stolen from sysinstall, break on success. |
616 | for ezjail_path in pub/FreeBSD/releases pub/FreeBSD/snapshot pub/FreeBSD releases snapshots NO; do | 664 | for ezjail_path in pub/FreeBSD/releases pub/FreeBSD/snapshot pub/FreeBSD releases snapshots NO; do |
617 | if [ "${ezjail_path}" = "NO" ]; then | 665 | if [ "${ezjail_path}" = "NO" ]; then |
618 | echo -e "\nCould not fetch ${pkg} from ${ezjail_ftphost}.\nMaybe your release (${ezjail_release}) is specified incorrectly or the host ${ezjail_ftphost} does not provide that release build.\nUse the -r option to specify an existing release or the -h option to specify an alternative ftp server." >&2 | 666 | echo -e "\nCould not fetch ${pkg} from ${ezjail_ftphost}.\nMaybe your release (${ezjail_release}) is specified incorrectly or the host ${ezjail_ftphost} does not provide that release build.\nUse the -r option to specify an existing release or the -h option to specify an alternative ftp server." >&2 |
619 | [ -z "${ezjail_ftpserverqueried}" ] && ezjail_queryftpserver | 667 | [ "${ezjail_ftpserverqueried}" ] || ezjail_queryftpserver |
620 | exit 1 | 668 | exit 1 |
621 | fi | 669 | fi |
622 | ftp "${ezjail_ftphost}:${ezjail_path}/${ezjail_installarch}/${ezjail_release}/${pkg}/*" && break | 670 | ftp "${ezjail_ftphost}:${ezjail_path}/${ezjail_installarch}/${ezjail_release}/${pkg}/*" && break |
@@ -628,14 +676,14 @@ install) | |||
628 | [ "${pkg}" = "base" ] && echo "Ignore the next question, ezjail answers it for you." | 676 | [ "${pkg}" = "base" ] && echo "Ignore the next question, ezjail answers it for you." |
629 | set -- all | 677 | set -- all |
630 | [ -f install.sh ] && yes | . install.sh | 678 | [ -f install.sh ] && yes | . install.sh |
631 | [ $? = 0 ] || exerr "Package install script for ${pkg} failed." | 679 | [ $? -eq 0 ] || exerr "Package install script for ${pkg} failed." |
632 | 680 | ||
633 | rm -rf ${ezjail_jailtemp} | 681 | rm -rf "${ezjail_jailtemp}" |
634 | else | 682 | else |
635 | cd ${ezjail_reldir}/${ezjail_dir}/${pkg} || exerr "Could not cd to ${ezjail_dir}." | 683 | cd "${ezjail_reldir}/${ezjail_dir}/${pkg}" || exerr "Could not cd to ${ezjail_dir}." |
636 | set -- all | 684 | set -- all |
637 | [ -f install.sh ] && yes | . install.sh | 685 | [ -f install.sh ] && yes | . install.sh |
638 | [ $? = 0 ] || exerr "Package install script for ${pkg} failed." | 686 | [ $? -eq 0 ] || exerr "Package install script for ${pkg} failed." |
639 | fi | 687 | fi |
640 | done | 688 | done |
641 | 689 | ||
@@ -671,39 +719,27 @@ console) | |||
671 | fetchjailinfo $1 | 719 | fetchjailinfo $1 |
672 | 720 | ||
673 | # check for existence of jail in our records | 721 | # check for existence of jail in our records |
674 | [ -n "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." | 722 | [ "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." |
675 | 723 | ||
676 | # if jail is not running, we either try to force start it or fail | 724 | # if jail is not running, we either try to force start it or fail |
677 | if [ -z "${ezjail_id}" ]; then | 725 | if [ -z "${ezjail_id}" ]; then |
678 | 726 | ||
679 | # If force start is requested, try that | 727 | # If force start is requested, try that |
680 | [ -n "$ezjail_forcestart}" ] || exerr "Error: Jail ${ezjail_name} appears not to be running, start it first (or use console -f for force start)." | 728 | [ "$ezjail_forcestart}" ] || exerr "Error: Jail ${ezjail_name} appears not to be running, start it first (or use console -f for force start)." |
681 | |||
682 | echo "Trying to bring up ${ezjail_name} ..." | ||
683 | # Try to locate and run ezjails rc.d script | ||
684 | if [ -x "${ezjail_prefix}/etc/rc.d/ezjail" ]; then | ||
685 | (exec "${ezjail_prefix}/etc/rc.d/ezjail" start ${ezjail_name}); | ||
686 | elif [ -x "${ezjail_prefix}/etc/rc.d/ezjail.sh" ]; then | ||
687 | (exec "${ezjail_prefix}/etc/rc.d/ezjail.sh" start ${ezjail_name}); | ||
688 | else | ||
689 | exerr "Could not find ezjail's rc.d script in ${ezjail_prefix}/etc/rc.d/. You need to start ${ezjail_name} by hand." | ||
690 | fi | ||
691 | |||
692 | # See, if it is running now | ||
693 | fetchjailinfo ${ezjail_name} | ||
694 | 729 | ||
695 | [ -n "${ezjail_id}" ] || exerr "Error: Could not start ${ezjail_name}. You need to start it by hand." | 730 | # This one will also exerr on failure |
731 | start_stop_jail_by_script start | ||
696 | fi | 732 | fi |
697 | 733 | ||
698 | # Try to attach to jail | 734 | # Try to attach to jail |
699 | [ -n "${ezjail_execute}" ] && exec jexec ${ezjail_id} ${ezjail_execute} | 735 | [ "${ezjail_execute}" ] && exec jexec ${ezjail_id} ${ezjail_execute} |
700 | 736 | ||
701 | exec jexec ${ezjail_id} ${ezjail_default_execute} | 737 | exec jexec ${ezjail_id} ${ezjail_default_execute} |
702 | ;; | 738 | ;; |
703 | ######################## ezjail-admin ARCHIVE ######################## | 739 | ######################## ezjail-admin ARCHIVE ######################## |
704 | archive) | 740 | archive) |
705 | # Clean variables, prevent polution | 741 | # Clean variables, prevent polution |
706 | unset ezjail_archive ezjail_force ezjail_archivealljails | 742 | unset ezjail_archive ezjail_archive_tag ezjail_force ezjail_archivealljails |
707 | 743 | ||
708 | shift; while getopts :Afa:d: arg; do case ${arg} in | 744 | shift; while getopts :Afa:d: arg; do case ${arg} in |
709 | f) ezjail_force="YES";; | 745 | f) ezjail_force="YES";; |
@@ -717,7 +753,7 @@ archive) | |||
717 | [ $# -lt 1 -a -z "${ezjail_archivealljails}" ] && exerr ${ezjail_usage_archive} | 753 | [ $# -lt 1 -a -z "${ezjail_archivealljails}" ] && exerr ${ezjail_usage_archive} |
718 | 754 | ||
719 | # Default archive directory to . | 755 | # Default archive directory to . |
720 | ezjail_archivedir="${ezjail_archivedir:-`pwd -P`}" | 756 | ezjail_archivedir=${ezjail_archivedir:-`pwd -P`} |
721 | 757 | ||
722 | # Will not backup more than one jail per archive | 758 | # Will not backup more than one jail per archive |
723 | [ "${ezjail_archive}" -a "${ezjail_archivealljails}" ] && exerr "Error: Must not specify an archive location for multiple archives." | 759 | [ "${ezjail_archive}" -a "${ezjail_archivealljails}" ] && exerr "Error: Must not specify an archive location for multiple archives." |
@@ -738,16 +774,19 @@ archive) | |||
738 | fetchjailinfo ${1%.norun} | 774 | fetchjailinfo ${1%.norun} |
739 | 775 | ||
740 | # check for existence of jail in our records | 776 | # check for existence of jail in our records |
741 | [ -n "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." | 777 | [ "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." |
742 | 778 | ||
743 | # if jail is still running, refuse to go any further - unless forced | 779 | # if jail is still running, refuse to go any further - unless forced |
744 | [ -n "${ezjail_id}" -a -z "${ezjail_force}" ] && exerr "Error: Jail appears to be still running, stop it first or [-f]orce archiving." | 780 | [ "${ezjail_id}" -a -z "${ezjail_force}" ] && exerr "Error: Jail appears to be still running, stop it first or [-f]orce archiving." |
781 | |||
782 | # This one goes into archive to identify jail by name and restore date | ||
783 | ezjail_archive_tag="${ezjail_safename}-`date +%Y%m%d%H%M.%S`" | ||
745 | 784 | ||
746 | # if no archive name was specified, make one up | 785 | # if no archive name was specified, make one up |
747 | [ -z "${ezjail_archive}" ] && ezjail_archive="${ezjail_safename}-`date +%Y%m%d%H%M.%S`.tar.gz" | 786 | [ "${ezjail_archive}" ] || ezjail_archive="${ezjail_archive_tag}.tar.gz" |
748 | 787 | ||
749 | # if archive location is not absolute, prepend archive directory | 788 | # if archive location is not absolute, prepend archive directory |
750 | [ "${ezjail_archive%%[!/]*}" ] || ezjail_archive="${ezjail_archivedir}"/"${ezjail_archive}" | 789 | [ "${ezjail_archive%%[!/]*}" ] || ezjail_archive="${ezjail_archivedir}/${ezjail_archive}" |
751 | 790 | ||
752 | # It's a tar archive, after all | 791 | # It's a tar archive, after all |
753 | case ${ezjail_archive} in | 792 | case ${ezjail_archive} in |
@@ -756,25 +795,43 @@ archive) | |||
756 | esac; | 795 | esac; |
757 | 796 | ||
758 | cd "${ezjail_rootdir}" || exerr "Error: can't cd to ${ezjail_root}." | 797 | cd "${ezjail_rootdir}" || exerr "Error: can't cd to ${ezjail_root}." |
759 | pax -wXtz -x ustar -f ${ezjail_archive} \ | 798 | pax -wXtz -x ustar -f "${ezjail_archive}" \ |
760 | -s:"^[^\\.].*/ezjail\\.conf\$":ezjail.conf: \ | 799 | -s:"^[^\\.].*/ezjail\\.conf\$":ezjail.conf: \ |
761 | -s:"^[^\\.].*/${ezjail_safename}\$":prop.ezjail_${ezjail_safename}: \ | 800 | -s:"^[^\\.].*/${ezjail_safename}\$":prop.ezjail_${ezjail_archive_tag}: \ |
762 | -s:"^[^\\.].*/${ezjail_safename}.norun\$":prop.ezjail_${ezjail_safename}: \ | 801 | -s:"^[^\\.].*/${ezjail_safename}.norun\$":prop.ezjail_${ezjail_archive_tag}.norun: \ |
763 | -s:"etc/fstab.${ezjail_safename}\$":fstab.ezjail: \ | 802 | -s:"etc/fstab.${ezjail_safename}\$":fstab.ezjail: \ |
764 | -s:"^\\.":ezjail: \ | 803 | -s:"^\\.":ezjail: \ |
765 | "/etc/fstab.${ezjail_safename}" "${ezjail_config}" "${ezjail_etc}/ezjail.conf" . 2> /dev/null | 804 | "/etc/fstab.${ezjail_safename}" "${ezjail_config}" "${ezjail_etc}/ezjail.conf" . 2> /dev/null |
766 | 805 | ||
767 | # An error on a jail not running is bad | 806 | # An error on a jail not running is bad |
768 | [ $? != "0" -a -z "${ezjail_force}" ] && exerr "Error: Archiving jail failed. You might want to check ${ezjail_archive}." | 807 | [ $? -eq 0 -o "${ezjail_force}" ] || exerr "Error: Archiving jail failed. You might want to check ${ezjail_archive}." |
769 | 808 | ||
770 | # When archiving a running jail, some errors might occur | 809 | # When archiving a running jail, some errors might occur |
771 | [ $? = "0" ] || echo "Warning: Archiving jail ${ezjail_name} was not completely successful. For a running jail this is not unusual. You might want to check ${ezjail_archive}." | 810 | [ $? -eq 0 ] || echo "Warning: Archiving jail ${ezjail_name} was not completely successful. For a running jail this is not unusual. You might want to check ${ezjail_archive}." |
772 | 811 | ||
773 | # To the next jail on command line | 812 | # To the next jail on command line |
774 | shift 1; | 813 | shift 1 |
775 | unset ezjail_archive | 814 | unset ezjail_archive |
776 | done | 815 | done |
777 | ;; | 816 | ;; |
817 | ####################### ezjail-admin RESTORE ######################## | ||
818 | restore) | ||
819 | # Clean variables, prevent polution | ||
820 | unset ezjail_fromarchive ezjail_archivedir | ||
821 | |||
822 | #ezjail_usage_restore="Usage: ${ezjail_admin} restore [-d archivedir] (archive|jailname)..." | ||
823 | |||
824 | shift; while getopts :d: arg; do case ${arg} in | ||
825 | d) ezjail_archivedir=${OPTARG};; | ||
826 | ?) exerr ${ezjail_usage_restore};; | ||
827 | esac; done; shift $(( ${OPTIND} - 1 )) | ||
828 | |||
829 | [ $# -eq 0 ] || exerr ${ezjail_usage_restore} | ||
830 | |||
831 | # Jail name mandatory | ||
832 | fetchjailinfo $1 | ||
833 | |||
834 | ;; | ||
778 | ######################## ezjail-admin CONFIG ######################## | 835 | ######################## ezjail-admin CONFIG ######################## |
779 | config) | 836 | config) |
780 | # Clean variables, prevent polution | 837 | # Clean variables, prevent polution |
@@ -793,26 +850,26 @@ config) | |||
793 | fetchjailinfo $1 | 850 | fetchjailinfo $1 |
794 | 851 | ||
795 | # check for existence of jail in our records | 852 | # check for existence of jail in our records |
796 | [ -n "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." | 853 | [ "${ezjail_config}" ] || exerr "Error: Nothing known about jail ${ezjail_name}." |
797 | 854 | ||
798 | # Nothing to be configured? | 855 | # Nothing to be configured? |
799 | [ -z "${ezjail_setrunnable}" -a -z "${ezjail_new_name}" -a -z "${ezjail_imageaction}" ] && echo "Warning: No config option specified." | 856 | [ "${ezjail_setrunnable}" -o "${ezjail_new_name}" -o "${ezjail_imageaction}" ] || echo "Warning: No config option specified." |
800 | 857 | ||
801 | # Do we want a new name for our jail? | 858 | # Do we want a new name for our jail? |
802 | if [ -n "${ezjail_new_name}" ]; then | 859 | if [ "${ezjail_new_name}" ]; then |
803 | # if jail is still running, refuse to go any further | 860 | # if jail is still running, refuse to go any further |
804 | [ -n "${ezjail_id}" ] && exerr "Error: Jail appears to be still running, stop it first." | 861 | [ "${ezjail_id}" ] && exerr "Error: Jail appears to be still running, stop it first." |
805 | 862 | ||
806 | # Cannot rename an attached jail | 863 | # Cannot rename an attached jail |
807 | [ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} is attached as ${ezjail_device}. '${ezjail_admin} config -i detach' it first." | 864 | [ "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} is attached as ${ezjail_device}. '${ezjail_admin} config -i detach' it first." |
808 | 865 | ||
809 | # The new values for the jail | 866 | # The new values for the jail |
810 | ezjail_new_hostname=`echo -n ${ezjail_new_name} | tr '/~' '__'` | 867 | ezjail_new_hostname=`echo -n ${ezjail_new_name} | tr '/~' '__'` |
811 | ezjail_new_safename=`echo -n "${ezjail_new_name}" | tr -c '[:alnum:]' _` | 868 | ezjail_new_safename=`echo -n "${ezjail_new_name}" | tr -c '[:alnum:]' _` |
812 | ezjail_new_rootdir=`dirname -- ${ezjail_rootdir}`/${ezjail_new_hostname} | 869 | ezjail_new_rootdir=`dirname -- ${ezjail_rootdir}`/${ezjail_new_hostname} |
813 | ezjail_new_config=${ezjail_jailcfgs}/${ezjail_new_safename} | 870 | ezjail_new_config="${ezjail_jailcfgs}/${ezjail_new_safename}" |
814 | [ "${ezjail_config}" = "${ezjail_config%.norun}" ] || ezjail_new_config=${ezjail_jailcfgs}/${ezjail_new_safename}.norun | 871 | [ "${ezjail_config}" = "${ezjail_config%.norun}" ] || ezjail_new_config="${ezjail_jailcfgs}/${ezjail_new_safename}.norun" |
815 | ezjail_new_softlink=${ezjail_jaildir}/`basename -- ${ezjail_new_rootdir}` | 872 | ezjail_new_softlink=${ezjail_jaildir}/`basename -- "${ezjail_new_rootdir}"` |
816 | 873 | ||
817 | # those are just copied | 874 | # those are just copied |
818 | eval ezjail_new_ip=\"\$jail_${ezjail_safename}_ip\" | 875 | eval ezjail_new_ip=\"\$jail_${ezjail_safename}_ip\" |
@@ -834,22 +891,22 @@ config) | |||
834 | 891 | ||
835 | # jail names may lead to identical configs, eg. foo.bar.com == foo-bar.com | 892 | # jail names may lead to identical configs, eg. foo.bar.com == foo-bar.com |
836 | # so check, whether we might be running into problems | 893 | # so check, whether we might be running into problems |
837 | [ -e ${ezjail_new_config} -o -e ${ezjail_new_config}.norun ] && exerr "Error: an ezjail config already exists at ${ezjail_new_config}. Please rename the ezjail." | 894 | [ -e "${ezjail_new_config}" -o -e "${ezjail_new_config}.norun" ] && exerr "Error: an ezjail config already exists at ${ezjail_new_config}. Please rename the ezjail." |
838 | 895 | ||
839 | # since we just used the old rootdir prefix and added the new hostname, | 896 | # since we just used the old rootdir prefix and added the new hostname, |
840 | # we might end up at an existing directory | 897 | # we might end up at an existing directory |
841 | [ -e ${ezjail_new_rootdir} ] && exerr "Error: An object already exists at ${ezjail_new_rootdir}, cant rename." | 898 | [ -e "${ezjail_new_rootdir}" ] && exerr "Error: An object already exists at ${ezjail_new_rootdir}, cant rename." |
842 | 899 | ||
843 | # prevent trouble with creating our softlink | 900 | # prevent trouble with creating our softlink |
844 | [ -L ${ezjail_softlink} -a -e ${ezjail_new_softlink} ] && exerr "Error: An object already exists at ${ezjail_new_softlink}, cant create softlink there." | 901 | [ -L "${ezjail_softlink}" -a -e "${ezjail_new_softlink}" ] && exerr "Error: An object already exists at ${ezjail_new_softlink}, cant create softlink there." |
845 | 902 | ||
846 | # need to rename the image? | 903 | # need to rename the image? |
847 | if [ -n "${ezjail_image}" ]; then | 904 | if [ "${ezjail_image}" ]; then |
848 | # Do we have an auto generated image name? | 905 | # Do we have an auto generated image name? |
849 | if [ "${ezjail_rootdir}.img" = "${ezjail_image}" ]; then | 906 | if [ "${ezjail_rootdir}.img" = "${ezjail_image}" ]; then |
850 | ezjail_new_image=${ezjail_new_rootdir}.img | 907 | ezjail_new_image="${ezjail_new_rootdir}.img" |
851 | [ -e ${ezjail_new_image} ] && exerr "Error: An object already exists at ${ezjail_new_image}, cant rename image." | 908 | [ -e "${ezjail_new_image}" ] && exerr "Error: An object already exists at ${ezjail_new_image}, cant rename image." |
852 | mv ${ezjail_image} ${ezjail_new_image} | 909 | mv "${ezjail_image}" "${ezjail_new_image}" |
853 | else | 910 | else |
854 | ezjail_new_image=${ezjail_image} | 911 | ezjail_new_image=${ezjail_image} |
855 | echo "Warning: Image file for jail ${ezjail_name} remains ${ezjail_image}, as it was not auto generated" | 912 | echo "Warning: Image file for jail ${ezjail_name} remains ${ezjail_image}, as it was not auto generated" |
@@ -860,23 +917,23 @@ config) | |||
860 | 917 | ||
861 | # adjust softlink | 918 | # adjust softlink |
862 | if [ -L "${ezjail_softlink}" ]; then | 919 | if [ -L "${ezjail_softlink}" ]; then |
863 | rm ${ezjail_softlink} | 920 | rm "${ezjail_softlink}" |
864 | ln -s ${ezjail_new_rootdir} ${ezjail_new_softlink} | 921 | ln -s "${ezjail_new_rootdir}" "${ezjail_new_softlink}" |
865 | fi | 922 | fi |
866 | 923 | ||
867 | # rename rootdir | 924 | # rename rootdir |
868 | mv ${ezjail_rootdir} ${ezjail_new_rootdir} | 925 | mv "${ezjail_rootdir}" "${ezjail_new_rootdir}" |
869 | 926 | ||
870 | # rename fstab | 927 | # rename fstab |
871 | echo -n > /etc/fstab.${ezjail_new_safename} | 928 | echo -n > "/etc/fstab.${ezjail_new_safename}" |
872 | [ -n "${ezjail_new_imagetype}" ] && \ | 929 | [ "${ezjail_new_imagetype}" ] && \ |
873 | echo ${ezjail_new_rootdir}.device ${ezjail_new_rootdir} ufs rw 0 0 >> /etc/fstab.${ezjail_new_safename} | 930 | echo ${ezjail_new_rootdir}.device ${ezjail_new_rootdir} ufs rw 0 0 >> "/etc/fstab.${ezjail_new_safename}" |
874 | echo ${ezjail_jailbase} ${ezjail_new_rootdir}/basejail nullfs ro 0 0 >> /etc/fstab.${ezjail_new_safename} | 931 | echo ${ezjail_jailbase} ${ezjail_new_rootdir}/basejail nullfs ro 0 0 >> "/etc/fstab.${ezjail_new_safename}" |
875 | rm /etc/fstab.${ezjail_safename} | 932 | rm "/etc/fstab.${ezjail_safename}" |
876 | 933 | ||
877 | # rename config file, preserve comments | 934 | # rename config file, preserve comments |
878 | ( | 935 | ( |
879 | grep -e ^\# ${ezjail_config} | 936 | grep -e ^\# "${ezjail_config}" |
880 | echo | 937 | echo |
881 | echo export jail_${ezjail_new_safename}_hostname=\"${ezjail_new_hostname}\" | 938 | echo export jail_${ezjail_new_safename}_hostname=\"${ezjail_new_hostname}\" |
882 | echo export jail_${ezjail_new_safename}_ip=\"${ezjail_new_ip}\" | 939 | echo export jail_${ezjail_new_safename}_ip=\"${ezjail_new_ip}\" |
@@ -892,10 +949,10 @@ config) | |||
892 | echo export jail_${ezjail_new_safename}_attachparams=\"${ezjail_new_attachparams}\" | 949 | echo export jail_${ezjail_new_safename}_attachparams=\"${ezjail_new_attachparams}\" |
893 | echo export jail_${ezjail_new_safename}_attachblocking=\"${ezjail_new_attachblocking}\" | 950 | echo export jail_${ezjail_new_safename}_attachblocking=\"${ezjail_new_attachblocking}\" |
894 | echo export jail_${ezjail_new_safename}_forceblocking=\"${ezjail_new_forceblocking}\" | 951 | echo export jail_${ezjail_new_safename}_forceblocking=\"${ezjail_new_forceblocking}\" |
895 | ) > ${ezjail_new_config} | 952 | ) > "${ezjail_new_config}" |
896 | 953 | ||
897 | # remove old config | 954 | # remove old config |
898 | rm ${ezjail_config} | 955 | rm "${ezjail_config}" |
899 | 956 | ||
900 | # usually that doesnt go smoothly, but the user wanted it | 957 | # usually that doesnt go smoothly, but the user wanted it |
901 | # that way ;) | 958 | # that way ;) |
@@ -906,65 +963,51 @@ config) | |||
906 | fetchjailinfo ${ezjail_new_safename} | 963 | fetchjailinfo ${ezjail_new_safename} |
907 | fi | 964 | fi |
908 | 965 | ||
909 | case ${ezjail_setrunnable} in | 966 | case "${ezjail_setrunnable}" in |
910 | run) [ "${ezjail_config}" = "${ezjail_config%.norun}" ] || mv ${ezjail_config} ${ezjail_config%.norun};; | 967 | run) [ "${ezjail_config}" = "${ezjail_config%.norun}" ] || mv "${ezjail_config}" "${ezjail_config%.norun}";; |
911 | norun) [ "${ezjail_config}" = "${ezjail_config%.norun}" ] && mv ${ezjail_config} ${ezjail_config}.norun ;; | 968 | norun) [ "${ezjail_config}" = "${ezjail_config%.norun}" ] && mv "${ezjail_config}" "${ezjail_config}.norun" ;; |
912 | esac | 969 | esac |
913 | 970 | ||
914 | [ -n "${ezjail_imageaction}" -a -z "${ezjail_image}" ] && exerr "Error: Jail ${ezjail_name} not an image jail." | 971 | [ "${ezjail_imageaction}" -a -z "${ezjail_image}" ] && exerr "Error: Jail ${ezjail_name} not an image jail." |
915 | 972 | ||
916 | case "${ezjail_imageaction}" in | 973 | case "${ezjail_imageaction}" in |
917 | attach) | 974 | attach) |
918 | # Check, if image already attached | 975 | # Check, if image already attached |
919 | [ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." | 976 | [ "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." |
920 | rm -f ${ezjail_rootdir}.device | 977 | rm -f "${ezjail_devicelink}" |
921 | 978 | ||
922 | # Attach images by type | 979 | # Attach images by type |
923 | attach_images | 980 | attach_images |
924 | 981 | ||
925 | # Clean image | 982 | # Clean image |
926 | fsck -t ufs -p -B /dev/${ezjail_device} | 983 | fsck -t ufs -p -B "/dev/${ezjail_device}" |
927 | 984 | ||
928 | mount /dev/${ezjail_device} ${ezjail_rootdir} || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}." | 985 | mount "/dev/${ezjail_device}" "${ezjail_rootdir}" || detach_images keep || exerr "Error: Could not mount /dev/${ezjail_device} to ${ezjail_rootdir}." |
929 | # relink image device | 986 | # relink image device |
930 | ln -s /dev/${ezjail_device} ${ezjail_rootdir}.device | 987 | ln -s "/dev/${ezjail_device}" "${ezjail_devicelink}" |
931 | 988 | ||
932 | ;; | 989 | ;; |
933 | detach) | 990 | detach) |
934 | # Check, if image really attached or running | 991 | # Check, if image really attached or running |
935 | [ -n "${ezjail_id}" ] && exerr "Error: Jail ${ezjail_name} still running. Can not detach." | 992 | [ "${ezjail_id}" ] && exerr "Error: Jail ${ezjail_name} still running. Can not detach." |
936 | [ -n "${ezjail_attached}" ] || exerr "Error: Jail image file ${ezjail_name} is not attached." | 993 | [ "${ezjail_attached}" ] || exerr "Error: Jail image file ${ezjail_name} is not attached." |
937 | ezjail_device=${ezjail_device#/dev/} | ||
938 | |||
939 | # Add this device to the list of devices to be unmounted | ||
940 | case ${ezjail_imagetype} in | ||
941 | crypto|bde) ezjail_imagedevice="${ezjail_device%.bde}" ;; | ||
942 | eli) ezjail_imagedevice="${ezjail_device%.eli}" ;; | ||
943 | *) ezjail_imagedevice="${ezjail_device}" ;; | ||
944 | esac | ||
945 | 994 | ||
946 | # Unmount/detach everything | 995 | # Unmount/detach everything |
947 | detach_images keep | 996 | detach_images keep |
948 | |||
949 | # Remove soft link (which acts as a lock) | ||
950 | [ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device | ||
951 | ;; | 997 | ;; |
952 | fsck) | 998 | fsck) |
953 | # Check, if image already attached | 999 | # Check, if image already attached |
954 | [ -n "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." | 1000 | [ "${ezjail_attached}" ] && exerr "Error: Jail image file ${ezjail_image} already attached as ${ezjail_device}." |
955 | rm -f ${ezjail_rootdir}.device | 1001 | rm -f "${ezjail_devicelink}" |
956 | 1002 | ||
957 | # Attach images by type | 1003 | # Attach images by type |
958 | attach_images | 1004 | attach_images |
959 | 1005 | ||
960 | # Clean image | 1006 | # Clean image |
961 | fsck -t ufs /dev/${ezjail_device} | 1007 | fsck -t ufs "/dev/${ezjail_device}" |
962 | 1008 | ||
963 | # Detach images by type | 1009 | # Detach images by type |
964 | detach_images keep | 1010 | detach_images keep |
965 | |||
966 | # Remove soft link (which acts as a lock) | ||
967 | [ -e /dev/${ezjail_imagedevice} ] || rm -f ${ezjail_rootdir}.device | ||
968 | ;; | 1011 | ;; |
969 | esac | 1012 | esac |
970 | ;; | 1013 | ;; |