source: trunk/initrd/sali/init @ 565

Last change on this file since 565 was 565, checked in by dennis, 8 years ago

Working version with new udev

File size: 3.6 KB
Line 
1#!/bin/sh
2#
3# This file is part of SALI
4#
5# SALI is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# SALI is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with SALI.  If not, see <http://www.gnu.org/licenses/>.
17#
18# 2013 SURFsara
19
20## For init we don't want to rely on $PATH
21_PRINTF="/usr/bin/printf"
22_MOUNT="/bin/mount"
23_CAT="/bin/cat"
24_MKDIR="/bin/mkdir"
25_GREP="/bin/grep"
26_UDEVD="/lib/udev/udevd"
27_UDEVADM="/sbin/udevadm"
28_LS="/bin/ls"
29_MKNOD="/bin/mknod"
30_DMESG="/bin/dmesg"
31
32## Are we allowed to run?
33if [ -n "$($_MOUNT | $_GREP "/dev")" ]
34then
35    $_PRINTF "Looks like /dev is already mounted, this script can only be used for initialization of SALI\n"
36    exit 1
37fi
38
39## Default value for init
40init="/sbin/init"
41
42## Checking of these directories exists
43for directory in "/proc" "/sys" "/dev" "/run"
44do
45    if [ ! -d "${directory}" ]
46    then
47        $_MKDIR -p "${directory}"
48    fi
49done
50
51## Mount /proc, /sys and /dev
52# -o == Which options must be use when mounting
53$_MOUNT -t proc proc /proc
54$_MOUNT -t sysfs sysfs /sys
55$_MOUNT -t devtmpfs -o mode=0755 tmpfs /dev
56$_MOUNT -t tmpfs -o mode=0755 tmpfs /run
57
58## Fast scan of the kernel paramaters
59for option in $(cat /proc/cmdline)
60do
61    case "${option}" in
62        init=*)
63            init=${option#init=}
64        ;;
65        BLACKLIST=*)
66            blacklist=${option#BLACKLIST=}
67        ;;
68    esac
69done
70
71## Creating blacklist file
72if [ -n "${blacklist}" ]
73then
74    # Make sure the file exists and is empty
75    $_CAT /dev/null /etc/modprobe.d/pxe_blacklist.conf
76    for module in $(echo $blacklist | sed 's/;/ /g')
77    do
78        $_PRINTF "blacklist ${module}\n" >> /etc/modprobe.d/pxe_blacklist.conf
79    done
80fi
81
82####
83## Now the real initialization of SALI
84$_PRINTF "Initializing SALI...\n"
85
86## Make sure /sys/kernel/uevent_helper has just a empty line
87$_PRINTF "\n" > /sys/kernel/uevent_helper
88
89## Make some extra nodes that have been configured in
90## /etc/udev/links.conf
91if [ -e "/etc/udev/links.conf" ]
92then
93    # make sure we don't have any comments or empty lines
94    $_GREP '^[^#]' /etc/udev/links.conf | while read type name args
95    do
96        if [ "${type}" -a "${name}" -a ! -e "/dev/${name}" -a ! -L "/dev/${name}" ]
97        then
98            continue
99        fi
100        case "${type}" in
101            L)
102                $_LS -s "${args}" "/dev/${name}"
103            ;;
104            D)
105                $_MKDIR -p "/dev/${name}"
106            ;;
107            M)
108                $_MKNOD -m 600 "/dev/${name}" $args
109            ;;
110            *)
111                $_PRINTF "/etc/udev/links/conf; unparseable line (${type} ${name} ${args})\n"
112            ;;
113        esac
114    done
115fi
116
117## Starting udev
118$_PRINTF "Starting udev...\n"
119if $_UDEVD --daemon
120then
121    $_PRINTF "Started udevd\n"
122else
123    $_PRINTF "Waiting for 15 seconds an try to continue anyway!\n"
124    sleep 15
125fi
126
127# Wait for udev to process the events in the queue
128$_UDEVADM trigger --action=add
129
130sleep 2
131
132$_UDEVADM settle
133
134# Now mount /dev/pts as devpts
135if [ ! -e "/dev/pts" ]
136then
137    $_MKDIR -p /dev/pts
138fi
139$_MOUNT devpts /dev/pts -t devpts -n
140
141$_PRINTF "Done with udev initalization, continue booting into SALI...\n"
142
143# Change console-level to 6
144$_DMESG -n 6
145
146## Now start SALI
147exec $init
Note: See TracBrowser for help on using the repository browser.