1 #!/bin/sh
2 # FAI script for preparing LDAP objects. It calls ldap2fai to generate
3 # the config space after everything is done.
4 #
5 # (C) 2005 Cajus Pollmeier <pollmeier@gonicus.de>
6 echo 0 > /proc/sys/kernel/printk
7 trap '' INT
8 PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
9 LANG=C
11 . /usr/lib/goto/goto-support.lib
13 #dialog() {
14 # echo $*
15 #}
17 abort() {
18 setterm -cursor off
19 while true; do sleep 60; done
20 }
22 # Try to figure out which interface is configured, in doubt
23 # choose the first one.
24 interfaces=$(ifconfig | awk '/^[a-z0-9]/ {print $1}' | grep -v "lo")
25 for int in $interfaces; do
26 ip=$(v=`ifconfig $int | awk '/inet addr/ {print $2}'`; echo ${v##*:})
27 mac=$(ifconfig $int | awk '/HWaddr/ {print $5}')
28 [ -n "$ip" ] && break
29 done
31 # Cancel if there's no IP available
32 if [ -z "$ip" ]; then
33 dialog --title 'Fehler' --no-shadow --infobox 'Fehler: Das System konnte keine Netzwerk-Adresse ermitteln.\n\nDie Installation kann ohne diese Adresse nicht fortgesetzt werden.' 5 60
34 abort
35 fi
37 # Check if DNS setup is correct and set the hostname
38 hostname=$(get_hostname_from_ip $ip)
39 if [ "$hostname" == "unknown" ]; then
40 dialog --title 'Fehler' --no-shadow --infobox 'Fehler: Das System konnte keinen Rechner-Namen ermitteln.\n\nDie Installation kann ohne diese Information nicht fortgesetzt werden.' 5 60
41 abort
42 fi
44 echo "* setting hostname: $hostname"
45 hostname "$hostname"
46 mount -t tmpfs tmpfs /etc/ldap
49 # Look for interesting parameters on kernel commandline
50 ldap=""; splash=""
51 for v in $(cat /proc/cmdline); do
52 case $v in
53 ldap=*)
54 echo -n "* found LDAP information, adapting configuration: "
55 ldap=$(echo ${v##ldap=}|base64-decode)
57 # ldap://hostname:389/basedn
58 LDAP_HOST=$(echo $ldap|sed 's!^[^:][^:]*://\([^:/][^:/]*\).*$!\1!g')
59 LDAP_PORT=$(echo $ldap|sed 's!^[^:]*://[^:][^:]*:\([0-9]*\)/.*$!\1!g')
60 echo -n $ldap_port | grep -q '^[0-9]*$' || LDAP_PORT=389
61 LDAP_BASE=$(echo $ldap|sed 's!^[^:][^:]*://[^/][^/]*/\(.*\)$!\1!g')
62 echo -e "BASE $LDAP_BASE\nURI ldap://$LDAP_HOST:$LDAP_PORT\n" > /etc/ldap/ldap.conf
63 echo "ok"
64 ;;
65 splash=*)
66 echo -n "* setting splash mode: "
67 splash=$(echo ${v##splash=})
68 [ $splash == "silent" ] && echo "silent" || echo "normal"
69 ;;
70 esac
71 done
73 [ -z "$ldap" ] && exit 0
75 # Check if autosetup is needed at this point
76 echo -n "* configurator: "
77 if ! terminal_has_hardware_profile $mac; then
78 setterm -cursor off
79 echo "not configured yet - please wait, detecting hardware"
81 # Switch from bootsplash to normal screen, show dialog
82 [ -f /proc/splash ] && echo "verbose" > /proc/splash
84 setterm -blank 60
85 chvt 1
86 dialog --infobox 'Bitte warten, die installierte Hardware wird untersucht...' 3 64
88 # Get common config
89 hwsetup
90 terminal_alsa_setup
91 terminal_autofs_setup
93 # Save hardware profile
94 terminal_save_hardware_profile $mac
95 fi
97 if ! terminal_activated $mac; then
98 # wait till we get activated
99 setterm -blank 60
100 chvt 1
101 dialog --infobox 'Warte auf Aktivierung durch den Systemadministrator.' 3 60
103 while ! terminal_activated $mac; do
104 sleep 2
105 done
107 # GOsa writes the GOto entry in three steps. To continue, we check
108 # if XDRIVER is present.
109 dialog --infobox 'System wurde aktiviert. Eintr�e werden nun bernommen.' 3 60
110 while ! terminal_load_hardware_profile $mac &> /dev/null; do
111 cat /etc/sysconfig/GOto | grep -v 'XDRIVER="unknown"' | grep -q 'XDRIVER'
112 sleep 2
113 done
115 # Enable splash if it was enabled before
116 [ -f /proc/splash ] && echo "silent" > /proc/splash
118 echo -n "* configurator (pass2): "
119 setterm -cursor on
120 fi
122 # Mount configuration space
123 [ ! -d /tmp/goto-fai ] && mkdir /tmp/goto-fai
124 mount -obind /tmp/goto-fai /fai
125 ldap2fai $mac
127 chvt 3
128 exit 0