Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / libpam / modules / register_static
1 #!/bin/bash
2 # $FreeBSD: src/contrib/libpam/modules/register_static,v 1.1.1.1.6.1 2001/06/11 15:28:16 markm Exp $
3
4 if [ `basename $PWD` != "modules" ]; then
5         echo "$0 must be run from the .../modules directory"
6         exit 1
7 fi
8
9 merge_line ()
10 {
11         if [ $# != 3 ]; then
12                 echo "usage: merge_line token filename 'new line'"
13         fi
14         if [ -f $2 ]; then
15 # remove any existing entry...
16                 grep -v "$1" $2 > tmp.$2
17                 rm -f $2
18                 mv {tmp.,}$2
19         fi
20         cat << EOT >> $2
21 $3
22 EOT
23
24 }
25
26
27 if [ $# -ne 2 ]; then
28
29         cat << EOT 2>&1
30 $0:     this script takes TWO arguments:
31         the 'alphanumeric label' of the module and the location of
32         its object file from the .../modules/ directory
33 EOT
34         exit 1
35
36 else
37         echo "
38  *> registering static module: $1 ($2) <*
39 "
40         merge_line "$1" _static_module_list "\
41 extern struct pam_module _$1_modstruct;"
42
43         merge_line "$1" _static_module_entry "    &_$1_modstruct,"
44         if [ -n "$2" ]; then
45                 merge_line "$2" _static_module_objects "../modules/$2"
46         fi
47
48 fi
49
50 exit 0