summaryrefslogtreecommitdiffstats
path: root/data/stage3.1/init
blob: a2a4981f3f25b3a2b70d122e338578044925abab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh
# Copyright (c) 2012 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found at http://openslx.org
#
# First script for initial ramfs for OpenSLX linux stateless clients
#############################################################################

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/openslx/bin:/openslx/sbin

mount -n -t tmpfs -o 'mode=755' run "/run"

# mount the important standard directories
[ ! -f /proc/cpuinfo ] && mount -n -t proc proc /proc
[ ! -d /sys/class ] && mount -n -t sysfs sysfs /sys

# read primary graphic adaptor configuration (without proprietary drivers yet)
( hwinfo --gfxcard >/etc/hwinfo.gfxcard
    case $(cat /etc/hwinfo.gfxcard) in
       *i915*)
         modprobe -a i915 2>/dev/null
         ;;
       *intel*|*Intel*)
         modprobe -a i810 i830 i915 2>/dev/null
         ;;
       *nvidia*|*NVidia*|*nouveau*)
         modprobe -q nouveau 2>/dev/null
         ;;
       *radeon*|*Radeon*)
         modprobe -q radeon 2>/dev/null
         ;;
       *mga*|*matrox*|*Matrox*)
         modprobe -q mga 2>/dev/null
         ;;
       *)
         modprobe -qa r128 savage sis tdfx ttm via viafb
         ;;
    esac
    modprobe -a drm fbcon; mdev -s ) &

# load required network and usb controller drivers, filter out wireless adaptors
nwcardlist="forcedeth e1000e e1000 e100 tg3 via-rhine r8169 pcnet32"
echo "modprobe -qa usbhid hid-bright" >/etc/modprobe.base
grep modprobe /etc/hwinfo.netcard-usbctrl | grep -E "$nwcardlist|hcd" \
  | grep -v ehci | sed 's/.* Cmd: "//;s/"//;s/modprobe/modprobe -qb/' \
  | sort -u >>/etc/modprobe.base
# virtio hack
if [ $(grep -ic "virtio_pci" /etc/modprobe.base) -ge 1 ]; then
  echo "modprobe -q virtio_net" >>/etc/modprobe.base
fi
sh /etc/modprobe.base; mdev -s

#modprobe -a squashfs aufs 2>/dev/null

insmod /lib/modules/aufs.ko
insmod /lib/modules/squashfs.ko

# load basic filesystem modules
#modprobe -qa aufs squashfs nfs


mkdir -p /dev/shm/union /dev/shm/uniontmp /rorootfs
mount -n /mnt/openslx.sqfs /rorootfs

mount -n -t tmpfs none /dev/shm/uniontmp

mount -n -t aufs -o br:/dev/shm/uniontmp:/rorootfs=ro none /mnt
mkdir -p /mnt/uniontmp
mount -n --move /dev/shm/uniontmp /mnt/uniontmp


for mnt in proc sys run ; do
  #mount -n --move $mnt /mnt/$mnt
  umount -n $mnt
done

#/bin/sh
unset BOOT_IMAGE initrd
# new style of pivoting (switch_root or run-init)
exec /sbin/switch_root -c /dev/console /mnt /usr/lib/systemd/systemd
setsid sh -c 'exec sh </dev/tty1 >/dev/tty1 2>&1'