summaryrefslogtreecommitdiffstats
path: root/modules.d/openslx-tmp-format/scripts/openslx_tmp_format.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/openslx-tmp-format/scripts/openslx_tmp_format.sh')
-rwxr-xr-xmodules.d/openslx-tmp-format/scripts/openslx_tmp_format.sh58
1 files changed, 0 insertions, 58 deletions
diff --git a/modules.d/openslx-tmp-format/scripts/openslx_tmp_format.sh b/modules.d/openslx-tmp-format/scripts/openslx_tmp_format.sh
deleted file mode 100755
index 9848b923..00000000
--- a/modules.d/openslx-tmp-format/scripts/openslx_tmp_format.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env bash
-#
-# Formats the partition used for "${NEWROOT}/tmp"
-# using filesystem given as SLX_TMP_PARTITION_FILESYSTEM
-# if possible. If not, it tries xfs and ext4 as fallbacks.
-source /usr/lib/configure-logging.sh
-bl.module.import bashlink.filesystem
-
-. /usr/lib/openslx/tools.sh
-. /etc/openslx
-
-# If it is not set, assume the functionality is unwanted
-[ -z "${SLX_TMP_PARTITION_IDENTIFIER}" ] && return 0
-
-# Support comma-separated list of identifiers, e.g.
-# "OpenSLX-ID44,0x44" as these can match GPT label (recommended)
-# and even MBR partition types (more of an ugly hack currently...)
-OLDIFS="$IFS"
-IFS=","
-SLX_TMP_PARTITION_DEVICE=
-for identifier in ${SLX_TMP_PARTITION_IDENTIFIER}; do
- SLX_TMP_PARTITION_DEVICE="$(bl.filesystem.find_block_device "${identifier}" '' \
- "${SLX_TMP_PARTITION_IDENTIFIER_TIMEOUT_IN_SECONDS:-5}")"
- if [ -n "${SLX_TMP_PARTITION_DEVICE}" ]; then
- echo "SLX_TMP_PARTITION_DEVICE=${SLX_TMP_PARTITION_DEVICE}" >> /etc/openslx
- break
- fi
-done
-IFS="$OLDIFS"
-
-if [ -z "${SLX_TMP_PARTITION_DEVICE}" ]; then
- warn "[${BASH_SOURCE[0]}] \
- Could not find device matching identifiers: ${SLX_TMP_PARTITION_IDENTIFIER}."
- return 1
-fi
-# Since a partition identifier is set and this module was built
-# assume that the partition should always be formatted.
-if [ -z "${SLX_TMP_PARTITION_FILESYSTEM_CREATE_COMMAND}" ] ||
- ! command -v "${SLX_TMP_PARTITION_FILESYSTEM_CREATE_COMMAND%%\ *}" >/dev/null; then
- warn "[${BASH_SOURCE[0]}] \
- '${SLX_TMP_PARTITION_FILESYSTEM_CREATE_COMMAND%%\ *}' invalid. Using fallbacks..."
- # Fallbacks
- if command -v mkfs.xfs >/dev/null; then
- SLX_TMP_PARTITION_FILESYSTEM_CREATE_COMMAND="mkfs.xfs -f"
- elif command -v mkfs.ext4 >/dev/null; then
- SLX_TMP_PARTITION_FILESYSTEM_CREATE_COMMAND="mkfs.ext4 -F"
- else
- warn "[${BASH_SOURCE[0]}] No suitable mkfs command found! Skipping..."
- return 1
- fi
-fi
-
-if ! ${SLX_TMP_PARTITION_FILESYSTEM_CREATE_COMMAND} "${SLX_TMP_PARTITION_DEVICE}"; then
- warn "[${BASH_SOURCE[0]}] \
- Failed to format '${SLX_TMP_PARTITION_DEVICE}' using: \
- ${SLX_TMP_PARTITION_FILESYSTEM_CREATE_COMMAND}"
- return 1
-fi