File: test-init.sh

package info (click to toggle)
dracut 109-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,872 kB
  • sloc: sh: 24,527; ansic: 5,234; makefile: 346; perl: 186; python: 48; javascript: 19
file content (48 lines) | stat: -rwxr-xr-x 1,377 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

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

[ -e /proc/self/mounts ] \
    || (mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)

grep -q '^sysfs /sys sysfs' /proc/self/mounts \
    || (mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)

grep -q '^devtmpfs /dev devtmpfs' /proc/self/mounts \
    || (mkdir -p /dev && mount -t devtmpfs -o mode=755,noexec,nosuid,strictatime devtmpfs /dev)

grep -q '^tmpfs /run tmpfs' /proc/self/mounts \
    || (mkdir -p /run && mount -t tmpfs -o mode=755,noexec,nosuid,strictatime tmpfs /run)

: > /dev/watchdog

exec > /dev/console 2>&1
echo "made it to the test rootfs!"

if command -v systemctl > /dev/null 2>&1; then
    systemctl --failed --no-legend --no-pager >> /run/failed
fi

# run the test case specific test assertion if exists
if [ -x "/assertion.sh" ]; then
    . /assertion.sh
fi

if [ -s /run/failed ]; then
    echo "**************************FAILED**************************"
    cat /run/failed
    echo "**************************FAILED**************************"
else
    echo "dracut-root-block-success" | dd oflag=direct,dsync status=none of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker
    echo "All OK"
fi

echo "Powering down."

if [ -d /usr/lib/systemd/system ]; then
    # graceful poweroff
    systemctl poweroff
else
    # force immediate poweroff
    poweroff -f
fi