summaryrefslogtreecommitdiff
path: root/scripts/plymouth-populate-initrd.in
blob: 42b119c3575e8db7dd6bb9a392dafae06b13958d (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash

[ -z "$DESTDIR" ] || exit 0

[ -z "$LIBEXECDIR" ] && LIBEXECDIR="/usr/libexec"
[ -z "$DATADIR" ] && DATADIR="/usr/share"
[ -z "$PLYMOUTH_PLUGIN_PATH" ] && PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
[ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="@logofile@"
[ -z "$PLYMOUTH_THEME_NAME" ] && PLYMOUTH_THEME_NAME=$(plymouth-set-default-theme)

if [ -z "$PLYMOUTH_POPULATE_SOURCE_FUNCTIONS" ]; then

    if [ -f "${LIBEXECDIR}/initrd-functions" ]; then
        PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="${LIBEXECDIR}/initrd-functions"
    fi

    if [ -f "${DATADIR}/dracut/dracut-functions" ]; then
        PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="${DATADIR}/dracut/dracut-functions"
    fi
fi

if [ -n "$PLYMOUTH_POPULATE_SOURCE_FUNCTIONS" ]; then
    source $PLYMOUTH_POPULATE_SOURCE_FUNCTIONS
fi

if [ " $(type -t inst) " != " function " ]; then
    echo "Need 'inst' function, try setting PLYMOUTH_POPULATE_SOURCE_FUNCTIONS to a file that defines it" 1>&2
    exit 1
fi

if [ " $(type -t set_verbose) " != " function " ]; then
    function set_verbose { true; }
fi

function usage() {
    local output="/dev/stdout"
    local rc=0
    if [ "$1" == "error" ]; then
        output="/dev/stderr"
        rc=1
    fi

    echo "usage: plymouth [ --verbose | -v ] { --targetdir | -t } <initrd_directory>" > $output
    exit $rc
}

verbose=false
INITRDDIR=""
while [ $# -gt 0 ]; do
    case $1 in
        --verbose|-v)
            verbose=true
            ;;
        --targetdir|-t)
            shift
            INITRDDIR="$1"
            ;;
        --help|-h)
            usage normal
            ;;
        *)
            usage error
            break
            ;;
    esac
    shift
done
set_verbose $verbose || :

[ -z "$INITRDDIR" ] && usage error

mkdir -p ${INITRDDIR}${DATADIR}/plymouth/themes
inst /sbin/plymouthd $INITRDDIR /bin/plymouthd
inst /bin/plymouth $INITRDDIR
inst ${DATADIR}/plymouth/themes/text/text.plymouth $INITRDDIR
inst ${PLYMOUTH_PLUGIN_PATH}/text.so $INITRDDIR
inst ${DATADIR}/plymouth/themes/details/details.plymouth $INITRDDIR
inst ${PLYMOUTH_PLUGIN_PATH}/details.so $INITRDDIR
inst ${PLYMOUTH_LOGO_FILE} $INITRDDIR
inst @RELEASE_FILE@ $INITRDDIR

if [ -z "$PLYMOUTH_THEME_NAME" ]; then
    echo "No default plymouth plugin is set" > /dev/stderr
    exit 1
fi

PLYMOUTH_MODULE_NAME=$(grep "ModuleName *= *" ${DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ModuleName *= *//')

if [ ! -f ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so ]; then
    echo "The default plymouth plugin (${PLYMOUTH_MODULE_NAME}) doesn't exist" > /dev/stderr
    exit 1
fi

inst ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so $INITRDDIR

inst ${PLYMOUTH_PLUGIN_PATH}/renderers/frame-buffer.so $INITRDDIR

if [ -d ${DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME} ]; then
    for x in ${DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/* ; do
        [ ! -f "$x" ] && break
        inst $x $INITRDDIR
    done
fi

if [ -L ${DATADIR}/plymouth/themes/default.plymouth ]; then
    cp -a ${DATADIR}/plymouth/themes/default.plymouth $INITRDDIR${DATADIR}/plymouth/themes
fi

# vim:ts=8:sw=4:sts=4:et