2012-07-23 04:07:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2013-05-28 14:43:46 +00:00
|
|
|
# Copyright (c) 2012 NTT DOCOMO, INC.
|
2012-11-15 03:20:32 +00:00
|
|
|
# Copyright 2012 Hewlett-Packard Development Company, L.P.
|
|
|
|
#
|
2012-07-23 04:07:27 +00:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2014-03-20 02:06:31 +00:00
|
|
|
# NOTE(bnemec): We don't want this script to exit on failures because if init
|
|
|
|
# dies then we get a kernel panic on ramdisk boot.
|
|
|
|
# dib-lint: disable=sete setu setpipefail
|
|
|
|
|
2012-07-23 04:07:27 +00:00
|
|
|
echo "init"
|
|
|
|
|
|
|
|
source /init-func
|
|
|
|
|
|
|
|
PATH=/sbin:/bin:/usr/bin:/usr/sbin
|
|
|
|
export PATH
|
|
|
|
|
|
|
|
mkdir -p /proc
|
|
|
|
mkdir -p /sys
|
|
|
|
mkdir -p /dev
|
|
|
|
mkdir -p /boot
|
|
|
|
mkdir -p /etc
|
|
|
|
mkdir -p /mnt
|
|
|
|
mkdir -p /lib/modules
|
|
|
|
|
|
|
|
mount -t proc proc /proc
|
|
|
|
|
|
|
|
readonly _BOOTIF_=$(get_kernel_parameter BOOTIF)
|
|
|
|
readonly _IP_=$(get_kernel_parameter ip)
|
|
|
|
readonly BOOT_MAC_ADDRESS=$(echo "$_BOOTIF_" | sed -e "s/-/:/g" | sed -e "s/^01://g" | tr 'a-f' 'A-F')
|
|
|
|
readonly BOOT_SERVER=$(echo "$_IP_" | cut -d':' -f2)
|
2014-05-22 12:34:54 +00:00
|
|
|
|
|
|
|
# IP address and other parameters may be set later in the init script
|
|
|
|
BOOT_IP_ADDRESS=$(echo "$_IP_" | cut -d':' -f1)
|
|
|
|
BOOT_NETMASK=$(echo "$_IP_" | cut -d':' -f4)
|
|
|
|
BOOT_GATEWAY=$(echo "$_IP_" | cut -d':' -f3)
|
2012-07-23 04:07:27 +00:00
|
|
|
|
|
|
|
readonly DISK=$(get_kernel_parameter disk)
|
|
|
|
|
|
|
|
readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
|
|
|
|
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
|
|
|
|
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
|
2013-11-19 11:25:58 +00:00
|
|
|
TROUBLESHOOT=$(get_kernel_parameter troubleshoot)
|
2013-06-17 20:38:12 +00:00
|
|
|
FIRST_ERR_MSG=
|
2012-07-23 04:07:27 +00:00
|
|
|
|
|
|
|
mount -t sysfs none /sys
|
2013-05-28 14:43:46 +00:00
|
|
|
|
|
|
|
UDEVD=
|
|
|
|
if [ -x "/bin/systemd-udevd" ]; then
|
|
|
|
UDEVD="systemd-udevd"
|
|
|
|
else
|
|
|
|
UDEVD="udevd"
|
|
|
|
fi
|
|
|
|
|
2013-11-20 10:01:06 +00:00
|
|
|
# udev versions 176 and newer require a different on-disk setup
|
2014-04-03 22:49:18 +00:00
|
|
|
UDEVD_VERSION=$(udevadm --version)
|
2013-11-20 10:01:06 +00:00
|
|
|
|
|
|
|
if [ "$UDEVD_VERSION" != "" -a $UDEVD_VERSION -gt 175 ]; then
|
|
|
|
echo "Using new-style udevd setup"
|
2013-05-28 14:43:46 +00:00
|
|
|
mount -t devtmpfs none /dev
|
|
|
|
mkdir -p /run
|
|
|
|
mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
|
|
|
|
mkdir -p /run/lock
|
2013-11-20 10:01:06 +00:00
|
|
|
mkdir -p /run/udev
|
2013-05-28 14:43:46 +00:00
|
|
|
else
|
2013-11-20 10:01:06 +00:00
|
|
|
echo "Using old-style udevd setup"
|
2013-05-28 14:43:46 +00:00
|
|
|
mount -t tmpfs none /dev
|
|
|
|
ln -sf /proc/self/fd /dev/fd
|
|
|
|
mknod /dev/null c 1 3
|
|
|
|
mknod /dev/zero c 1 5
|
|
|
|
mknod /dev/random c 1 8
|
|
|
|
mknod /dev/urandom c 1 9
|
|
|
|
mknod /dev/tty0 c 4 0
|
|
|
|
mknod /dev/tty1 c 4 1
|
|
|
|
mknod /dev/tty2 c 4 2
|
|
|
|
mknod /dev/tty3 c 4 3
|
|
|
|
mknod /dev/tty4 c 4 4
|
|
|
|
mknod /dev/tty5 c 4 5
|
|
|
|
mknod /dev/tty6 c 4 6
|
|
|
|
mknod /dev/tty7 c 4 7
|
|
|
|
mknod /dev/tty8 c 4 8
|
|
|
|
mknod /dev/tty9 c 4 9
|
|
|
|
mknod /dev/tty c 5 0
|
|
|
|
mknod -m 0600 /dev/console c 5 1
|
|
|
|
mknod -m 0666 /dev/ptmx c 5 2
|
|
|
|
mkdir -p /dev/.udev
|
|
|
|
mkdir -p /dev/.udev/data
|
|
|
|
fi
|
2012-07-23 04:07:27 +00:00
|
|
|
|
|
|
|
echo "starting syslogd"
|
|
|
|
|
|
|
|
echo '*.* /initlog' > /etc/syslog.conf
|
|
|
|
syslogd
|
|
|
|
klogd
|
|
|
|
|
|
|
|
echo "starting udevd"
|
2013-05-28 14:43:46 +00:00
|
|
|
$UDEVD --daemon --resolve-names=never
|
2012-07-23 04:07:27 +00:00
|
|
|
|
|
|
|
echo "load modules"
|
|
|
|
load_modules_by_udev
|