Skip to content
Snippets Groups Projects
Commit c0713183 authored by Pietsch, Martin's avatar Pietsch, Martin
Browse files

added function createTargetDirectoryLayout

parent 7bdfa699
No related branches found
No related tags found
No related merge requests found
......@@ -266,7 +266,8 @@ formatDiskPartitions() {
# generateFSTab - generate fstab file
# parameter:
# $1 - path of fstab file
# $2 - mount path prefix (optional)
# $2 - mount with UUID
# $3 - mount path prefix (optional)
# return:
# none
generateFSTab() {
......@@ -279,10 +280,11 @@ generateFSTab() {
local opts
local dmp
local pass
local dev
if [ $# -eq 2 ];
if [ $# -eq 3 ];
then
mntpntpfx="$2"
mntpntpfx="$3"
fi
echo -e "#device mount point filesystem options dump pass\n" >$1
......@@ -306,12 +308,18 @@ generateFSTab() {
if [ -n "${fs}" -a -n "${mntpnt}" -a -n "${uuid}" ];
then
case ${2} in
"uuid") dev="UUID=${uuid}" ;;
*)
dev="/dev/${disk}${idx}"
;;
esac
echo "#/dev/${disk}${idx}" >>$1
if [ ${mntpnt} != "none" ];
if [ "${mntpnt}" != "none" ];
then
echo -e "UUID=${uuid} ${mntpntpfx}${mntpnt} ${fs} ${opts} ${dmp} ${pass}\n" >>$1
echo -e "${dev} ${mntpntpfx}${mntpnt} ${fs} ${opts} ${dmp} ${pass}\n" >>$1
else
echo -e "UUID=${uuid} ${mntpnt} ${fs} ${opts} ${dmp} ${pass}\n" >>$1
echo -e "${dev} ${mntpnt} ${fs} ${opts} ${dmp} ${pass}\n" >>$1
fi
fi
idx=$((${idx} + 1))
......@@ -319,6 +327,37 @@ generateFSTab() {
done
}
# createTargetDirectoryLayout - create directory layout for target installation
# parameter:
# $1 - path to target directory
# return:
# none
createTargetDirectoryLayout(){
local idx
local mntpnt
local fs
for disk in ${DISK_DEVICES[@]}
do
idx=1
for part in $(eval "for p in \${DISK_$(echo ${disk} | tr [a-z] [A-Z])_PARTITIONS[@]}; do echo \$p; done ")
do
fs=$(blkid -s TYPE -o value /dev/${disk}${idx})
mntpnt=$(echo ${part} | cut -f 3 -d ";")
if [ "${fs}" = "swap" -o "${fs}" = "linux-swap" ];
then
mntpnt="none"
fi
if [ "${mntpnt}" != "none" ];
then
mkdir -p $1/${mntpnt}
fi
idx=$((${idx} + 1))
done
done
}
for disk in ${DISK_DEVICES[@]}
do
declare -a diskdata=()
......@@ -348,5 +387,6 @@ do
formatDiskPartitions ${disk}
done
generateFSTab "/tmp/fstab.local"
generateFSTab "/tmp/fstab.target" "/target"
generateFSTab "/tmp/fstab.local" "uuid"
generateFSTab "/tmp/fstab.target" "dev" "/target"
createTargetDirectoryLayout "/target"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment