Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Enable display of executed commands
- # set -x
- JAIL_NAME=$1
- BASE_DATASET="${2:-vault}"
- echo "Preparing to migrate fstab entries from warden to iocage for the" \
- "${JAIL_NAME} jail under the ${BASE_DATASET} dataset:"
- echo "Do you have the power?"
- sudo echo "I have the power!"
- if [[ $? == 1 ]] ; then
- echo "Apparently, you don't have the power."
- exit 1;
- fi
- FSTAB_ENTRIES="/tmp/${JAIL_NAME}.fstab"
- # Remove the temporary file if it currently exists
- if [[ -e "${JAIL_NAME}" ]]; then
- rm -f "${FSTAB_ENTRIES}"
- fi
- # Grab the Warden fstab file and make a fixed version of it
- sed -e "s/\\/mnt\\/${BASE_DATASET}\\/jails\\/${JAIL_NAME}\\///g" < \
- "/mnt/${BASE_DATASET}/jails/.${JAIL_NAME}.meta/fstab" | \
- sort > "${FSTAB_ENTRIES}"
- # Read in the lines, preventing backslash escapes (such as "\040") from being interpreted
- while IFS='' read -r entry || [[ -n "$entry" ]]; do
- echo "Adding the following entry: ${entry}"
- # Change the "\040" in the fstab entry back to a space
- sub_path=$(echo "${entry}" | cut -d" " -f2 | sed -e "s/\\\\040/ /g")
- new_path="/mnt/iocage/jails/${JAIL_NAME}/root${sub_path}"
- # Create the target directory
- sudo mkdir -pv "${new_path}"
- # Add the mount point
- sudo iocage fstab --add "${JAIL_NAME}" "${entry}"
- done < "${FSTAB_ENTRIES}"
- # Delete the temporary mount entries
- rm -f "${FSTAB_ENTRIES}"
- echo "Done migrating fstab entries to the iocage jail."
Add Comment
Please, Sign In to add comment