Document that you need to run `autoreconf -i' if checking out from git.
[supernested.git] / init.in
1 #!/bin/bash -
2 # supernested Makefile.am
3 # @configure_input@
4 # (C) Copyright 2014 Red Hat Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #
20 # Written by Richard W.M. Jones <rjones@redhat.com>
21
22 echo "*** /init script starting up ***"
23
24 export PATH=/sbin:/usr/sbin:/bin:/usr/bin
25
26 # Create /proc, /sys, /run, /dev, /tmp
27 if [ ! -d /proc ]; then rm -f /proc; fi
28 mkdir -p /proc
29 mount -t proc /proc /proc
30 if [ ! -d /sys ]; then rm -f /sys; fi
31 mkdir -p /sys
32 mount -t sysfs /sys /sys
33 mkdir -p /run
34 mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
35 mkdir -p /run/lock
36 ln -s ../run/lock /var/lock
37 mount -t devtmpfs /dev /dev
38 mkdir -p /tmp
39 mount -t tmpfs tmpfs /tmp
40
41 # Find and start udev.
42 for f in /sbin/udevd /lib/udev/udevd \
43     /lib/systemd/systemd-udevd /usr/lib/systemd/systemd-udevd \
44     /usr/lib/udev/udevd; do
45   if [ -x "$f" ]; then UDEVD="$f"; fi
46 done
47 if [ -z "$UDEVD" ]; then
48   echo "udev not found!  Things will probably not work ..."
49 fi
50 $UDEVD --daemon
51 udevadm trigger
52 udevadm settle --timeout=600
53
54 # Set up kmod static-nodes (RHBZ#1011907).
55 mkdir -p /run/tmpfiles.d
56 kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
57
58 # Set up tmpfiles (must run after kmod.conf is created above).
59 systemd-tmpfiles --prefix=/dev --create
60
61 # libiscsi puts itself in a non-standard directory.
62 /sbin/ldconfig
63
64 # Print some information about the system.
65 echo "/proc/cpuinfo ------------------------------"
66 cat /proc/cpuinfo
67 echo "--------------------------------------------"
68 echo
69
70 echo -n "cmdline: "
71 cat /proc/cmdline
72
73 echo -n "clocksource: "
74 cat /sys/devices/system/clocksource/clocksource0/current_clocksource
75
76 echo -n "kernel: "
77 uname -r
78
79 # ls -lR /dev
80 # cat /proc/mounts
81 # lsmod
82
83 level="$(
84     grep -Eo 'supernested.level=[[:digit:]]+' /proc/cmdline |
85     grep -Eo '[[:digit:]]+'
86     )"
87 echo "*** This is the L$level hypervisor ***"
88
89 # Run the nested guest.
90 /run-supernested.sh --nested
91
92 echo "*** the L$level hypervisor is exiting ***"
93
94 # Exit and reboot.
95 # qemu has the -no-reboot flag, so issuing a reboot here actually
96 # causes qemu to exit gracefully.
97 reboot -f