Consistency improvements
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (c) 2018-2021, Christer Edwards <christer.edwards@gmail.com>
|
# Copyright (c) 2018-2022, Christer Edwards <christer.edwards@gmail.com>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -76,22 +76,25 @@ update_fstab() {
|
|||||||
# Update fstab to use the new name
|
# Update fstab to use the new name
|
||||||
FSTAB_CONFIG="${bastille_jailsdir}/${NEWNAME}/fstab"
|
FSTAB_CONFIG="${bastille_jailsdir}/${NEWNAME}/fstab"
|
||||||
if [ -f "${FSTAB_CONFIG}" ]; then
|
if [ -f "${FSTAB_CONFIG}" ]; then
|
||||||
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RC[1-2])|([0-9]{1,2}-stable-build-[0-9]{1,3})|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)|(current-BUILD-LATEST)' "${FSTAB_CONFIG}")
|
# Skip if fstab is empty, e.g newly created thick or clone jails
|
||||||
FSTAB_CURRENT=$(grep -w ".*/releases/.*/jails/${TARGET}/root/.bastille" "${FSTAB_CONFIG}")
|
if [ -s "${FSTAB_CONFIG}" ]; then
|
||||||
FSTAB_NEWCONF="${bastille_releasesdir}/${FSTAB_RELEASE} ${bastille_jailsdir}/${NEWNAME}/root/.bastille nullfs ro 0 0"
|
FSTAB_RELEASE=$(grep -owE '([1-9]{2,2})\.[0-9](-RELEASE|-RC[1-2])|([0-9]{1,2}-stable-build-[0-9]{1,3})|(current-build)-([0-9]{1,3})|(current-BUILD-LATEST)|([0-9]{1,2}-stable-BUILD-LATEST)|(current-BUILD-LATEST)' "${FSTAB_CONFIG}")
|
||||||
if [ -n "${FSTAB_CURRENT}" ] && [ -n "${FSTAB_NEWCONF}" ]; then
|
FSTAB_CURRENT=$(grep -w ".*/releases/.*/jails/${TARGET}/root/.bastille" "${FSTAB_CONFIG}")
|
||||||
# If both variables are set, update as needed
|
FSTAB_NEWCONF="${bastille_releasesdir}/${FSTAB_RELEASE} ${bastille_jailsdir}/${NEWNAME}/root/.bastille nullfs ro 0 0"
|
||||||
if ! grep -qw "${bastille_releasesdir}/${FSTAB_RELEASE}.*${bastille_jailsdir}/${NEWNAME}/root/.bastille" "${FSTAB_CONFIG}"; then
|
if [ -n "${FSTAB_CURRENT}" ] && [ -n "${FSTAB_NEWCONF}" ]; then
|
||||||
sed -i '' "s|${FSTAB_CURRENT}|${FSTAB_NEWCONF}|" "${FSTAB_CONFIG}"
|
# If both variables are set, update as needed
|
||||||
|
if ! grep -qw "${bastille_releasesdir}/${FSTAB_RELEASE}.*${bastille_jailsdir}/${NEWNAME}/root/.bastille" "${FSTAB_CONFIG}"; then
|
||||||
|
sed -i '' "s|${FSTAB_CURRENT}|${FSTAB_NEWCONF}|" "${FSTAB_CONFIG}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update linuxjail fstab name entries
|
||||||
|
# Search for either linprocfs/linsysfs, if true assume is a linux jail
|
||||||
|
if grep -qwE "linprocfs|linsysfs" "${FSTAB_CONFIG}"; then
|
||||||
|
sed -i '' "s|.${bastille_jailsdir}/${TARGET}/|${bastille_jailsdir}/${NEWNAME}/|" "${FSTAB_CONFIG}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update linuxjail fstab name entries
|
|
||||||
LINUX_FSTAB_CONFIG="${bastille_jailsdir}/${NEWNAME}/fstab"
|
|
||||||
if [ -n "${LINUX_FSTAB_CONFIG}" ]; then
|
|
||||||
sed -i '' "s|${TARGET}|${NEWNAME}|" "${LINUX_FSTAB_CONFIG}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
change_name() {
|
change_name() {
|
||||||
|
|||||||
Reference in New Issue
Block a user