View Single Post
  #6   (View Single Post)  
Old 25th January 2010
J65nko J65nko is offline
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,506

In the following Makefile _aliases is a patch script for the /etc/mail/aliases file created and discussed in the previous post.

The file _newaliases:
# -----------------
cat <<END
Running NEWALIASES to rebuild the aliases database ....

# --
The _existing-root-mail installs or moves the existing /var/mail/root to /var/mail/${USER}. If done as first thing after an install, this will usually do no harm, because the user's /var/mail file will not exist yet or will be empty.

If you don't want this , read the install(1) man page for the correct option to create a backup of an existing /var/mail/${USER} first.

# -------------------------------------------
echo --- move existing root email to $USER
install -o ${USER} -g ${USER} -m u=rw /var/mail/root /var/mail/${USER}
The Makefile itself:

# Makefile to divert root mail to user account

FILE    = _rootmail-to-j65nko

${FILE}:    _aliases _newaliases _existing-root-mail
        cat ${.ALLSRC} >${.TARGET}

        rm -f ${FILE}
You run the Makefile with the make command:
$ make
cat _aliases _newaliases _existing-root-mail >_rootmail-to-j65nko
All components are concatenated to a single file. The resulting file name can be changed easily by editing the FILE variable.
After editing one of the components run make again to create an updated version.

A commonly encountered issue with Makefiles:

"Makefile", line 6: Need an operator
Fatal errors encountered -- cannot continue
You probably got this error by copying and pasting the Makefile instead of downloading and unpacking the attached tgz file.

The Makefile requires a tab before the commands, which (re)create the target. Here the cat command in line 6. By pasting, you lost this tab and it was replaced by a couple of spaces.

You can diagnose this easily with:
 cat -ten Makefile                                 
     1  # Makefile to divert root mail to user account$
     2  $
     3  FILE     = _rootmail-to-j65nko$
     4  $
     5  ${FILE}:    _aliases _newaliases _existing-root-mail$
     6          cat ${.ALLSRC} >${.TARGET}$
The "operator" line 6, has no tab, a ^I, but a series of spaces.

The correct version
$ cat -ten Makefile

     1  # Makefile to divert root mail to user account$
     2  $
     3  FILE^I= _rootmail-to-j65nko$
     4  $
     5  ${FILE}:    _aliases _newaliases _existing-root-mail$
     6  ^Icat ${.ALLSRC} >${.TARGET}$
Here line 6 has a tab character
Attached Files
File Type: tgz Makefile.tgz (949 Bytes, 68 views)
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 11th February 2010 at 10:14 PM. Reason: More detailed explanation of the missing tab/operator
Reply With Quote