summaryrefslogtreecommitdiff
path: root/ezjail-admin
diff options
context:
space:
mode:
authorPhilipp Wuensche <cryx-freebsd@h3q.com>2019-08-27 21:09:32 +0200
committerPhilipp Wuensche <cryx-freebsd@h3q.com>2019-08-27 21:09:32 +0200
commita5dd360cf896ae11c8dda380366a9d9d619a401b (patch)
tree69534062aeec15596d456a3f134c1c6621053755 /ezjail-admin
parent0b2fd52c9ac1219911b3c7ab589ddc22bdcdecbd (diff)
instead of creating temporary folder with files, grep in installlog directly. Skip usr/ports by default, which speeds this up a lot.
Diffstat (limited to 'ezjail-admin')
-rwxr-xr-xezjail-admin53
1 files changed, 17 insertions, 36 deletions
diff --git a/ezjail-admin b/ezjail-admin
index 1a2f4b1..0620d32 100755
--- a/ezjail-admin
+++ b/ezjail-admin
@@ -293,6 +293,7 @@ ezjail_splitworld() {
293 find ${dir} | cpio -d -p -v ${ezjail_keep_basejail} "${ezjail_jailbase}" || exerr "Error: Installation of ${dir} failed." 293 find ${dir} | cpio -d -p -v ${ezjail_keep_basejail} "${ezjail_jailbase}" || exerr "Error: Installation of ${dir} failed."
294 chflags -R noschg ${dir}; rm -r ${dir}; ln -s /basejail/${dir} ${dir} 294 chflags -R noschg ${dir}; rm -r ${dir}; ln -s /basejail/${dir} ${dir}
295 done 295 done
296 [ "${ezjail_uglyperlhack}" = "YES" ] && echo usr/bin/perl >> ${ezjail_jailbase}/.ezjail.installlog
296 mkdir basejail 297 mkdir basejail
297 298
298 # Try to remove the old template jail 299 # Try to remove the old template jail
@@ -1232,47 +1233,27 @@ baseclean)
1232 [ ! -f "${ezjail_jailbase}/.ezjail.installlog" ] && echo "No .ezjail.installlog found in basejail, please run ezjail-admin install first." && exit 1 1233 [ ! -f "${ezjail_jailbase}/.ezjail.installlog" ] && echo "No .ezjail.installlog found in basejail, please run ezjail-admin install first." && exit 1
1233 1234
1234 [ "${ezjail_use_zfs}" = "YES" ] && ensure_jailzfs 1235 [ "${ezjail_use_zfs}" = "YES" ] && ensure_jailzfs
1235 ezjail_makeabsolute ezjail_jailtemp 1236 ezjail_makeabsolute ezjail_jailbase
1236 rm -rf "${ezjail_jailtemp}"
1237
1238 # Create and try to access temp dir
1239 mkdir -p "${ezjail_jailtemp}" || exerr "Error: Could not create temporary base jail directory ${ezjail_jailtemp}."
1240
1241 # create any directories in install log
1242 for line in `cat ${ezjail_jailbase}/.ezjail.installlog | sort`; do
1243 [ ! -d "${ezjail_jailtemp}/${line%/*}" ] && mkdir -p "${ezjail_jailtemp}/${line%/*}"
1244 done
1245
1246 # we ignore any usr/ports and the ezjail install log itself
1247 mkdir -p "${ezjail_jailtemp}/usr/ports"
1248 touch "${ezjail_jailtemp}/.ezjail.installlog"
1249 1237
1250 # touch any files listed in install log 1238 for _parent in `ls -1d ${ezjail_jailbase}/*/* |grep -v ${ezjail_jailbase}/usr/ports`; do
1251 for line in `cat ${ezjail_jailbase}/.ezjail.installlog | sort`; do
1252 [ ! -e "${ezjail_jailtemp}/${line}" ] && touch "${ezjail_jailtemp}/${line}"
1253 done
1254
1255 # User has enabled uglyperlhack in ezjail.conf, make sure symlink doesn't get deleted
1256 [ "${ezjail_uglyperlhack}" = "YES" ] && touch "${ezjail_jailtemp}/usr/bin/perl"
1257 1239
1258 # find all files in base jail that are not listed in the install log and delete them 1240 # find all files in base jail that are not listed in the install log and delete them
1259 for _file in `find ${ezjail_jailbase} -type l -or -type f ! -regex ".*usr/ports.*" | sed s:^${ezjail_jailbase}/:: `; do 1241 for _file in `find ${_parent} -type l -or -type f | sed s:^${ezjail_jailbase}/:: `; do
1260 if [ ! -f "${ezjail_jailtemp}/${_file}" ]; then 1242 if [ `grep --mmap -c -m 1 -F -x ${_file} ${ezjail_jailbase}/.ezjail.installlog` -lt 1 ]; then
1261 [ "${ezjail_yeswecan}" != "YES" ] && echo "File: ${ezjail_jailbase}/${_file} will be deleted" 1243 [ "${ezjail_yeswecan}" != "YES" ] && echo "File: ${ezjail_jailbase}/${_file} will be deleted"
1262 [ "${ezjail_yeswecan}" = "YES" ] && rm "${ezjail_jailbase}/${_file}" && echo "File: ${ezjail_jailbase}/${_file} deleted" 1244 [ "${ezjail_yeswecan}" = "YES" ] && rm "${ezjail_jailbase}/${_file}" && echo "File: ${ezjail_jailbase}/${_file} deleted"
1263 fi 1245 fi
1264 done 1246 done
1265 1247
1266 # find all directories in base jail that are not listed in the install log and delete them when empty 1248 # find all directories in base jail that are not listed in the install log and delete them when empty
1267 for _dir in `find ${ezjail_jailbase} -type d ! -regex ".*usr/ports.*" | sort -r | sed -E s:^${ezjail_jailbase}:: `; do 1249 for _dir in `find ${_parent} -type d | sort -r | sed -E s:^${ezjail_jailbase}/:: `; do
1268 if [ ! -e "${ezjail_jailtemp}/${_dir}" ]; then 1250 if [ `grep -c -m 1 -F -x ${_dir} ${ezjail_jailbase}/.ezjail.installlog` -lt 1 ]; then
1269 [ "${ezjail_yeswecan}" != "YES" ] && echo "Dir: ${ezjail_jailbase}/${_dir} will be deleted" 1251 [ "${ezjail_yeswecan}" != "YES" -a "${_dir}" != "${ezjail_jailbase}" ] && echo "Dir: ${ezjail_jailbase}/${_dir} will be deleted"
1270 [ "${ezjail_yeswecan}" = "YES" ] && rmdir ${ezjail_jailbase}/${_dir} && echo "Dir: ${ezjail_jailbase}/${_dir} deleted" 1252 [ "${ezjail_yeswecan}" = "YES" -a "${_dir}" != "${ezjail_jailbase}" ] && rmdir ${ezjail_jailbase}/${_dir} && echo "Dir: ${ezjail_jailbase}/${_dir} deleted"
1271 fi 1253 fi
1254 done
1272 done 1255 done
1273 1256
1274 # remove our temporary directory
1275 rm -rf "${ezjail_jailtemp}"
1276 ;; 1257 ;;
1277######################## ezjail-admin SHORTCUT ######################## 1258######################## ezjail-admin SHORTCUT ########################
1278*start|*stop|*startcrypto|*stopcrypto) 1259*start|*stop|*startcrypto|*stopcrypto)