#1  
Old 2nd March 2012, 03:44
woodson2 woodson2 is offline
Junior Member
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Default Bash "HERE documents " help

I'm trying to enter a block of text into an existing configuration file for OpenLDAP so the setup can be fully scripted.

The text below is what I want to enter into slapd.conf and this all works well and good, however as you probably know this will place the text at the end of the file. What I'd like to know is how can I choose where in an existing file I want to place the text or is this beyond the scope of HERE documents?

Code:
cat >> slapd.conf << "EOF"
access to attrs=userPassword
        by self write
        by anonymous auth
        by dn.base="cn=root,dc=abclott,dc=lott" write
        by group.base="cn=infrastructure,ou=GTECH,ou=groups,dc=abclott,dc=lott" write
        by dn.base="uid=ldapmgr,ou=people,dc=abclott,dc=lott" write
        by * none

access to dn.children="ou=people,dc=abclott,dc=lott"
        by dn.base="cn=root,dc=abclott,dc=lott" write
        by dn.base="cn=bind,dc=abclott,dc=lott" read
        by users read
        by * none

access to dn.children="ou=groups,dc=abclott,dc=lott"
        by dn.base="cn=root,dc=abclott,dc=lott" write
        by dn.base="cn=bind,dc=abclott,dc=lott" read
        by users read
        by * none

access to dn.children="ou=servers,dc=abclott,dc=lott"
        by dn.base="cn=root,dc=abclott,dc=lott" write
        by group.base="cn=infrastructure,ou=GTECH,ou=groups,dc=abclott,dc=lott" write
        by dn.base="cn=bind,dc=abclott,dc=lott" read
        by users read
        by * none

access to dn.subtree="ou=SUDOers,dc=abclott,dc=lott"
        by dn.base="cn=root,dc=abclott,dc=lott" write
        by dn.base="cn=bind,dc=abclott,dc=lott" read
        by users read
        by * none

access to *
        by dn.base="cn=root,dc=abclott,dc=lott" write
        by dn.base="cn=bind,dc=abclott,dc=lott" search
        by * none
EOF
Reply With Quote
Sponsored Links
  #2  
Old 7th May 2012, 08:56
nbhadauria nbhadauria is offline
Member
 
Join Date: Aug 2010
Location: New Delhi, India
Posts: 79
Thanks: 1
Thanked 13 Times in 13 Posts
Send a message via Skype™ to nbhadauria
 
Default

You can use sed command to append the config into file:

sed -i '/^SEARCHPATTERN/ a\
access to attrs=userPassword\
by self write\
by anonymous auth\
by dn.base="cn=root,dc=abclott,dc=lott" write\
by group.base="cn=infrastructure,ou=GTECH,ou=groups,d c=abclott,dc=lott" write\
by dn.base="uid=ldapmgr,ou=people,dc=abclott,dc=lott" write\
by * none' /etc/ldap/slapd.conf

Or even you can insert config.txt file in the config:

sed -i '/^SEARCHPATTERN/r config.txt' /etc/ldap/slapd.conf
__________________
Best
Nitin Bhadauria
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with upgrade to 2.2.34 brianetilley Installation/Configuration 14 11th November 2009 18:22
Where is the Default Documents option? Code5 Installation/Configuration 2 29th July 2009 13:14
Error Documents 40esp General 2 16th May 2009 17:32
Error Documents Fedora 10 40esp General 1 26th March 2009 10:26
Documents for ISPConfig in Traditional Chinese version rosa hsiao Installation/Configuration 0 12th February 2006 05:45


All times are GMT +2. The time now is 01:08.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.