packet workers: Update the RAID persistence script
The RAID persistence script(`function persist_data_raid`) currently
assumes that there will be only one entry in the `/etc/mdadm.conf` file.
This commit adds logic to iterate through the file. This also changes
the hardcoded mount point of `/mnt` to `/mnt/device-name`.
@@ -138,10 +138,16 @@ storage:
# Don't mount if no RAID is configured.
[ -z "$${raid_config}" ] && return 0
+ cat /etc/mdadm.conf | while read line; do
# Make mount persistent across reboots.
- local devname=$(awk '{print $2}' /etc/mdadm.conf)
- mount "$${devname}" /mnt/
+ local devname=$(echo "$${line}" | awk '{print $2}')
+ local mount_point=$(echo "$${devname}" | cut -d"/" -f 4)
+
+ # Create the mount point before mounting
+ mkdir "/mnt/$${mount_point}"
+ mount "$${devname}" "/mnt/$${mount_point}"
echo "$${devname} /mnt ext4 defaults,nofail,discard 0 0" | tee -a /etc/fstab
+ done
}
persist_data_raid
