Code: Select all
for i in $(find /changes -type f | sed 's/\/changes//'); do
Code: Select all
find /changes -type f | sed 's/\/changes//' |while read i; do
Hello!
Recently I've lost my usb flash so right now I'm trying to rebuild what I had there, and this topic is about one of preferred scripts.
Idea with "changes.dat" file is nice, but I had several occasions where it resulted in corrupted files (it was long ago and I didn't use it since then), so for a long time I used Porteus where I manually set up the way I want using rootcopy folder.
It gave me more control over the scope of files that I wanted to allow to change
But recently I've decided to write a couple of scripts to automatically change certain files.
Basically I've created directory "./rootcopy/changes" where I placed files that I wanted to allow changes to.
On boot, they are copied to "/" along with everything else inside "rootcopy".
Then a simple script in rc.local:
Code: Select all
echo Removing destination files and linking:
find /changes -type f | sed 's/\/changes//' |while read i; do
echo "/changes$i" '>>' "$i"
rm -f "$i"
mkdir -p $(echo $i | sed 's/\/[^\/]*$//')
ln -s "/changes$i" "$i"
done
created directories as needed for new files (not files actually, just links to /changes/dir1/dir2/file)
and symlinking files inside /changes where they should be.
And on shutdown I used something like this in rc.local_shutdown:
Code: Select all
CHPATH=$(grep "/rootcopy" /var/log/porteus-livedbg | tail -n +2 | sed 's/UUID[^\/]*//')
UUID=$(grep "/rootcopy" /var/log/porteus-livedbg | tail -n +2 | sed -re 's/\/.+//' | sed 's/UUID://')
echo "$UUID"
if [ ! $UUID = '' ]; then
CHDISK=$(find /dev/disk/by-uuid/$UUID -type l -print0 | xargs -0 ls -plah | sed -re 's/^.+\///')
fi
if ! mount -l | grep $CHDISK > /dev/null ; then
mkdir -p /mnt/$CHDISK
mount -t auto /dev/$CHDISK /mnt/$CHDISK
fi
echo /mnt/$CHDISK$CHPATH/changes
cp -u -r /changes /mnt/$CHDISK$CHPATH
Anyway, just wanted to share this with everybody in case someone wants similar setup.
These scripts aren't elegant (I didn't have much time to re-create them after the loss of data), but at least they work for me. Most likely someone knows better ways to do this kind of thing.
Of course I had many other personal scripts (like the one that links all drives to ~/disks, all "games*", "music*", etc from all disks into appropriate folders inside home folder ) but I doubt the will be of much use... I think...