1#!/bin/sh
2# usage: ldapdns-conf acct logacct /ldapdns myip ldapip dn [suffix]
3
4# args
5auser=$1
6auid=`id -u $1`
7agid=`id -g $1`
8luser=$2
9luid=`id -u $2`
10lgid=`id -g $2`
11dir=$3
12myip=$4
13ldapip=$5
14binddn=$6
15suffix=$7
16ldapdns=`which ldapdns`
17
18if [ "X$binddn" = "X" ]; then
19	echo "Usage: ldapdns-conf acct logacct /dir myip ldaphost dn [suffix]" >&2
20	exit 0
21fi
22
23if [ "X$ldapdns" = "X" ]; then exit 1; fi
24if [ "X$auid" = "X" ]; then exit 1; fi
25if [ "X$agid" = "X" ]; then exit 1; fi
26if [ "X$luid" = "X" ]; then exit 1; fi
27if [ "X$lgid" = "X" ]; then exit 1; fi
28
29# make initial dir
30mkdir $dir
31chmod 03755 $dir
32
33# make log
34mkdir $dir/log $dir/log/main
35touch $dir/log/status
36chmod 02755 $dir/log $dir/log/main
37chmod 0644 $dir/log/status
38chown $luid:$lgid $dir/log/main $dir/log/status
39
40echo '#!/bin/sh' > $dir/log/run
41echo 'exec setuidgid '"$luser"' multilog t ./main' >> $dir/log/run
42chmod 0755 $dir/log/run
43
44echo '#!/bin/sh' > $dir/run
45echo 'exec 2>&1' >>$dir/run
46echo 'exec envuidgid '"$auser"' envdir ./env softlimit -d2000000 '$ldapdns >>$dir/run
47chmod 0755 $dir/run
48
49mkdir $dir/root
50chmod 02755 $dir/root
51
52mkdir $dir/env
53chmod 02755 $dir/env
54
55echo $dir/root > $dir/env/ROOT
56chmod 0600 $dir/env/ROOT
57
58echo $myip > $dir/env/IP
59chmod 0644 $dir/env/IP
60
61echo 'hostmaster@'`(domainname.sh || domainname) 2>/dev/null` > $dir/env/HOSTMASTER
62chmod 0644 $dir/env/HOSTMASTER
63
64echo $binddn > $dir/env/LDAP_AUTH_NAME
65chmod 0644 $dir/env/LDAP_AUTH_NAME
66
67echo $ldapip > $dir/env/LDAP_HOSTS
68chmod 0644 $dir/env/LDAP_HOSTS
69
70if [ "X$suffix" != "X" ]; then
71	echo $suffix > $dir/env/LDAP_SUFFIX
72	chmod 0644 $dir/env/LDAP_SUFFIX
73fi
74
75echo "Don't forget to set \$ROOT/root/password" >&2
76exit 0
77