khmann
07-06-2001, 01:31 PM
Greetings all. I wrote the following bash script to create duplicates of all files on my /var filesystem, for using when my 1.3 Phillips TiVo is updating guide data. This slows things down terribly, but it does seem to work- I just got my local slices and some 'removeDbsObject' script.
Update- I have since used this script to grab a copy of the 2.0.1 upgrade files as they were downloaded - but 'ya gotta have "export GZIP=-f' in your rc.sysinit. really. it's important.
What it does is recursively scan the filesystem and create hard links to files (before they're deleted...). The advantage to mirroring files this way is that the copies take up zero effective space until the original is deleted.
The /var filesystem is duplicated under /var/.hl/var. The only 'gotcha' is that if a file (once mirrored in this fashion) is deleted and then re-created, the mirror (/var/.hl/var/...) will still be the old file. Because of this, you may wish to periodically rename or remove /var/.hl while the script is not running.
*** UPDATE 07/09/01 ***
It is vitally important to add "export GZIP=-f" as one of the first commands in /etc/rc.d/rc.sysinit. If you do not, the tivo will not be able to work with any data that it downloads which is GZIP'd - this includes the 2.0.1 update, and slice data. Trust me, it's important.
Hope this helps someone....
-khmann
#!/bin/bash
parent=/var
echo "PARENT is $parent"
if [ ! -d "$parent/.hl" ]; then
echo "creating $parent/.hl"
mkdir "$parent/.hl"
fi
if [ ! -d "$parent/.hl$parent" ]; then
echo "creating $parent/.hl$parent"
mkdir "$parent/.hl$parent"
fi
hldir() {
for i in $1/* ; do
if [ -e "$i" ]; then # if source really exists
if [ ! -e "$parent/.hl$i" ]; then # dest no exist
if [ -L "$i" ]; then
if [ ! -L "$parent/.hl$i" ] ; then # source is symlink
echo "dup symlink $i"
cp -a "$i" "$parent/.hl$i" # copy the symlink
fi
else
if [ -d "$i" ]; then
echo "new dirsync $i"
mkdir "$parent/.hl$i" # make the directory
else
echo "hardlinking $i"
/bin/ln "$i" "$parent/.hl$i" # create a hardlink
fi
fi
fi
if [ -d "$i" ] && [ ! -L "$i" ] ; then
hldir "$i" # check the subdir also
fi
fi
done
}
while [ true ] ; do
hldir "$parent"
sleep 5
done
~
Update- I have since used this script to grab a copy of the 2.0.1 upgrade files as they were downloaded - but 'ya gotta have "export GZIP=-f' in your rc.sysinit. really. it's important.
What it does is recursively scan the filesystem and create hard links to files (before they're deleted...). The advantage to mirroring files this way is that the copies take up zero effective space until the original is deleted.
The /var filesystem is duplicated under /var/.hl/var. The only 'gotcha' is that if a file (once mirrored in this fashion) is deleted and then re-created, the mirror (/var/.hl/var/...) will still be the old file. Because of this, you may wish to periodically rename or remove /var/.hl while the script is not running.
*** UPDATE 07/09/01 ***
It is vitally important to add "export GZIP=-f" as one of the first commands in /etc/rc.d/rc.sysinit. If you do not, the tivo will not be able to work with any data that it downloads which is GZIP'd - this includes the 2.0.1 update, and slice data. Trust me, it's important.
Hope this helps someone....
-khmann
#!/bin/bash
parent=/var
echo "PARENT is $parent"
if [ ! -d "$parent/.hl" ]; then
echo "creating $parent/.hl"
mkdir "$parent/.hl"
fi
if [ ! -d "$parent/.hl$parent" ]; then
echo "creating $parent/.hl$parent"
mkdir "$parent/.hl$parent"
fi
hldir() {
for i in $1/* ; do
if [ -e "$i" ]; then # if source really exists
if [ ! -e "$parent/.hl$i" ]; then # dest no exist
if [ -L "$i" ]; then
if [ ! -L "$parent/.hl$i" ] ; then # source is symlink
echo "dup symlink $i"
cp -a "$i" "$parent/.hl$i" # copy the symlink
fi
else
if [ -d "$i" ]; then
echo "new dirsync $i"
mkdir "$parent/.hl$i" # make the directory
else
echo "hardlinking $i"
/bin/ln "$i" "$parent/.hl$i" # create a hardlink
fi
fi
fi
if [ -d "$i" ] && [ ! -L "$i" ] ; then
hldir "$i" # check the subdir also
fi
fi
done
}
while [ true ] ; do
hldir "$parent"
sleep 5
done
~