Hello,
This is a kind request addressed to those who are good with linux shell scripting. Unfortunately, I am not good with this, so I need help.
I want to create a custom script which will do the following:
- mount > mount.txt
- blkid > blkid.txt
- read the content of the mount.txt and isolate all those lines which show mounts for /dev/sd* (sda1, sda2, sdb1, sdb2, and so on)
- read the content of the blkid.txt file and match the elements from mount.txt to the content of the blkid.txt in order to retrieve the UUID
- read the /etc/fstab and match the UUIDs retrieved in the previous step with the declared mount points (identified by UUID) and determine if what is in fstab is actually mounted.
Based on the above, the script will continue with a decision point.
If all declared mount points are actualy mounted, then the script will exit.
If, however, the mount configuration is not the expected one, then the script will perform USB unbind and then USB bind to force the router to re-read all attached USB devices.
Then, it will execute mount -a and verify again if the mount points are the ones from the fstab file.
The USB unbind / bind I already figured out. My problem is that I suppose I will have to make use of awk and / or sed in order to process the 3 files and match the data, and I do not know how to do it.
So, if anyone can lend a hand with this, I will very much appreciate it.
Thank you.
Cheers,
algorab
This is a kind request addressed to those who are good with linux shell scripting. Unfortunately, I am not good with this, so I need help.
I want to create a custom script which will do the following:
- mount > mount.txt
- blkid > blkid.txt
- read the content of the mount.txt and isolate all those lines which show mounts for /dev/sd* (sda1, sda2, sdb1, sdb2, and so on)
- read the content of the blkid.txt file and match the elements from mount.txt to the content of the blkid.txt in order to retrieve the UUID
- read the /etc/fstab and match the UUIDs retrieved in the previous step with the declared mount points (identified by UUID) and determine if what is in fstab is actually mounted.
Based on the above, the script will continue with a decision point.
If all declared mount points are actualy mounted, then the script will exit.
If, however, the mount configuration is not the expected one, then the script will perform USB unbind and then USB bind to force the router to re-read all attached USB devices.
Then, it will execute mount -a and verify again if the mount points are the ones from the fstab file.
The USB unbind / bind I already figured out. My problem is that I suppose I will have to make use of awk and / or sed in order to process the 3 files and match the data, and I do not know how to do it.
So, if anyone can lend a hand with this, I will very much appreciate it.
Thank you.
Cheers,
algorab
Last edited: