Sidebar 1: Copying Files
In one or two places in the main article, I've mentioned that various files get copied. Although the mechanism is very simple, I thought that I'd explain how it works here. In the installation scripts, the following lines of code perform the copying:
FLAG=false
echo " Copying files: \c"
cat directory/INDEX | while read SRC DEST OWNER GROUP PERMS; do
if [ $FLAG = "false" ]; then
echo "$SRC\c"
FLAG=true
else
echo ", $SRC\c"
fi
cp phase1_files/$SRC $DEST
chown $OWNER:$GROUP $DEST
chmod $PERMS $DEST
done
echo "."
I use a variable, FLAG, to indicate if this is the first iteration of the loop; this lets me keep the formatting nice! Each line (which represents one file) of the INDEX file is read in, and is broken into five tokens. The tokens are the source filename, the destination filename, the file's owner and group, and finally, the permissions for the file.
The name of the file is printed out then copied to its destination, and its ownership and permissions are set as required. To illustrate the format of the directory/INDEX file, here are a few lines from one of the INDEX files I use:
dig /opt/local/bin/dig root other 511
ssh /opt/local/bin/ssh root other 4511
top /opt/local/bin/top root sys 2511
Notice that ssh is SUID root, and top is SGID sys.
|