I would like to create the following hard-link for every one of my users (including root): Code: /storage/backups/%u /home/%u/.backups none loop 0 0 How can I generate all of these hard-links without hand coding them in fstab? My first thought was to use the pam_mount module, but most of my users don't even have shell access, so I don't think that would work. I'm thinking I may have to write a small script that just runs at boot. Thanks for any input.
I ended up just writing a small bash script to run at boot time. The script parses the passwd file for users with UID >= 1000 (ie non-system users). Then for each user, pulls their home directory from the same file and mounts the backups folder if it exists. Code: #!/bin/bash # Mount root user's backup directory mount -o bind /storage/backups/root /root/.backups # Mount remaining users' backup directories USERS="$(awk -F ':' '{ if ( $3 >= 1000 ) print $1 }' /etc/passwd)" for u in $USERS do h="$(grep $u /etc/passwd | cut -d ':' -f 6)" if [ -d "$h/.backups" ] then mount -o bind /storage/backups/$u $h/.backups fi done
Its probably the most practical way of doing things. I guess automount might be coerced into doing it automatically, but its probably not worth the bother.