cloner: Fix the errors that the user gets on running remount-fs.sh
[bootimage-initfs.git] / etc / cloner / remount-fs.sh
1 #!/bin/ash
2
3 . /etc/library.sh
4
5 # we want to sort our filesystems via the mntpoint field so we can mount them in
6 # the correct order
7 sort -k2 /cloner/setup/filesystems \
8         > /cloner/setup/filesystems.sorted 2>> /tmp/stderr.log
9
10 header "Mounting filesystems"
11 while read line
12 do
13         FS_DEVICE=`echo $line | awk '{print $1}'`
14         FS_MNTPOINT=`echo $line | awk '{print $2}'`
15         FS_TYPE=`echo $line | awk '{print $3}'`
16         FS_LABEL=`echo $line | awk '{print $4}'`
17
18         
19         # if it starts with a / it's going to be mounted
20         if [ `echo ${FS_MNTPOINT} | grep '^/'` ]
21         then
22                 MNT_POINT=`echo ${FS_MNTPOINT} | sed 's/^\///'`
23                 msg -n "Mounting ${ANSI_BLUE}${FS_DEVICE}${ANSI_DONE} on ${ANSI_BLUE}/cloner/mnt/${MNT_POINT}${ANSI_DONE}"
24
25                 mkdir -p /cloner/mnt/${MNT_POINT} >> /tmp/stdout.log 2>> /tmp/stderr.log
26
27                 mount -t ${FS_TYPE} ${FS_DEVICE} /cloner/mnt/${MNT_POINT} >> /tmp/stdout.log 2>> /tmp/stderr.log
28                 if [ "$?" = "0" ]
29                 then
30                         ok_msg
31                 else
32                         fail_msg
33                         fatal_error "Failed to mount ${FS_DEVICE} to /cloner/mnt/${MNT_POINT}"
34                 fi
35         fi
36
37 done < /cloner/setup/filesystems.sorted
38