Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Converted LDAP autoconfig to upstart

  • Loading branch information...
commit 71682afef959624b840fee96fe417b71ff93ba2d 1 parent 1be78e0
@ironiemix ironiemix authored
View
8 debian/changelog
@@ -1,3 +1,11 @@
+linuxmuster-client-auth (0.5-precise1) linuxmuster-client; urgency=low
+
+ * Modified ldap autoconfig to use DNS instead of DHCP
+ * Patching host name at boot time
+ * Moved init script to upstart, starting on net-dev-up
+
+ -- Frank Schiebel <frank@linuxmuster.net> Mon, 23 Apr 2012 15:38:37 +0200
+
linuxmuster-client-auth (0.3-precise3) linuxmuster-client; urgency=low
* Moved configuration file to /etc/linuxmuster-client/auth, conf-dirs for all
View
1  debian/links
@@ -0,0 +1 @@
+etc/init.d/linuxmuster-client-auth etc/rc2.d/S10linuxmuster-client-auth
View
72 etc/init/linuxmuster-client-auth.conf
@@ -0,0 +1,72 @@
+# linuxmuster-client-auth
+#
+# gets ldap configuration from dns
+
+description "linuxmuster-client-auth LDAP autoconfiguration"
+
+start on net-device-up
+
+task
+
+script
+ . /etc/linuxmuster-client/auth/config
+
+ if [ "x${AUTOCONFIGURE_LDAP}" != "xYES" ]; then
+ echo "Info: Autoconfiguring of LDAP disabled"
+ return 0
+ fi
+
+ TEMPLATESDIR="/var/lib/linuxmuster-client-auth/templates"
+
+ # determine client ip
+ clientip=`ifconfig | grep 255.240.0.0 | awk '{print $2}' | awk -F: '{print $2}'`
+ clientname=`host $clientip | awk '{print $5}' | cut -d. -f1`
+ # determine servername
+ fqsn=`host -v $clientip | grep -A1 AUTHORITY | grep in.addr | awk '{print $5}'`
+ # determine serverip
+ serverip=`host $fqsn | awk '{print $4}'`
+ PARTS=$(echo $fqsn | tr "." "\n")
+
+ sn=""
+ basedn=""
+ for part in $PARTS; do
+ if [ -z ${sn} ]; then
+ sn="$part"
+ else
+ if [ -z ${basedn} ]; then
+ basedn="dc=$part"
+ else
+ basedn="$basedn,dc=$part"
+ fi
+ fi
+ done
+
+ echo "Autoconfiguring LDAP auth..."
+ echo " Client IP is: <$clientip>"
+ echo " Client hostname is: <$clientname>"
+ echo " Server IP is: <$serverip>"
+ echo " Server name is: <$fqsn>"
+ echo " Server host name is: <$sn>"
+ echo " BaseDN is: <$basedn>"
+
+ # configuring hostname
+ if [ ! -z $clientname ]; then
+ echo $clientname > /etc/hostname
+ fi
+
+ if [ "x${basedn}" != "x" ] && [ "x${serverip}" != "x" ]; then
+ echo -n "Configuring LDAP client to server ${serverip}, base ${basedn}..."
+ # patch template file to /etc
+ cd ${TEMPLATESDIR}
+ find -type f -name ldap.conf | xargs -i -t sh -c \
+ "sed -e 's%@@basedn@@%${basedn}%g
+ s%@@serverip@@%${serverip}%g' {} > /{}" 2> /dev/null 1> /dev/null
+
+ echo " done."
+ else
+ if [ -f /etc/linuxmuster-client/auth/ldap.conf.fallback ]; then
+ echo "WARNING: Autoconfiguring LDAP FAILED! Copying /etc/linuxmuster-client/auth/ldap.conf.fallback to /etc/ldap.conf"
+ cp /etc/linuxmuster-client/auth/ldap.conf.fallback /etc/ldap.conf
+ fi
+ fi
+end script
View
59 etc/linuxmuster-client/boot.d/01-ldapconfig
@@ -1,59 +0,0 @@
-# this script ist called at boot time from
-# /etc/init.d/linuxmuster-client-auth
-#
-
-# getting config
-. /etc/linuxmuster-client/auth/config
-
-if [ "x${AUTOCONFIGURE_LDAP}" != "xYES" ]; then
- echo "Info: Autoconfiguring of LDAP disabled"
- exit 0
-fi
-
-DHCPLEASES="/var/lib/dhcp/dhclient.leases"
-TEMPLATESDIR="/var/lib/linuxmuster-client-auth/templates"
-
-# if no ldap.conf.fallback exists, assume, the existing /etc/ldap.conf is
-# working and save it as fallback
-if [ ! -f /etc/linuxmuster-client/auth/ldap.conf.fallback ]; then
- cp /etc/ldap.conf /etc/linuxmuster-client/auth/ldap.conf.fallback
-fi
-
-# throw away "old" leases
-rm ${DHCPLEASES}
-# get new lease
-dhclient -nw
-# get basdn and ldap server ip from lease file
-i=0
-until [ "x${basedn}" != "x" ] && [ "x${serverip}" != "x" ]; do
- sleep 1
- (( i = $i + 1))
- basedn=`grep "domain-name " ${DHCPLEASES} | \
- uniq | \
- sed 's/\"/\"dc=/' | \
- cut -d "\"" -f 2 | \
- sed 's/\./\,dc=/'`
-
- serverip=`grep "domain-name-servers " ${DHCPLEASES} | \
- uniq | \
- awk -F "domain-name-servers " '{print $2}' | \
- cut -d ";" -f 1`
- if [ $i == 15 ]; then break; fi
-done
-
-
-if [ "x${basedn}" != "x" ] && [ "x${serverip}" != "x" ]; then
- echo -n "Configuring LDAP client to server ${serverip}, base ${basedn}..."
- # patch template file to /etc
- cd ${TEMPLATESDIR}
- find -type f -name ldap.conf | xargs -i -t sh -c \
- "sed -e 's%@@basedn@@%${basedn}%g
- s%@@serverip@@%${serverip}%g' {} > /{}" 2> /dev/null 1> /dev/null
-
- echo " done."
-else
- echo "WARNING: Autoconfiguring LDAP FAILED! Copying /etc/linuxmuster-client/auth/ldap.conf.fallback to /etc/ldap.conf"
- if [ -f /etc/linuxmuster-client/auth/ldap.conf.fallback ]; then
- cp /etc/linuxmuster-client/auth/ldap.conf.fallback /etc/ldap.conf
- fi
-fi
Please sign in to comment.
Something went wrong with that request. Please try again.