]> TLD Linux GIT Repositories - packages/dracut.git/blob - update-initramfs
- updated to 059
[packages/dracut.git] / update-initramfs
1 #!/bin/sh
2
3 create_initramfs () {
4   if ! test -f /lib/modules/${1}/modules.dep; then
5     return 0
6   elif ! test -f /boot/vmlinuz-${1}; then
7     return 0
8   fi
9   echo -n "Generating initramfs image for kernel ${1} ... "
10   /sbin/dracut --force /boot/initramfs-${1}.img ${1} 1>/dev/null 2>&1
11   if [ $? -ne 0 ]; then
12     echo "\e[1;31mFailed\e[0m"
13     return 1
14   fi
15   echo "\e[1;32mOK\e[0m"
16   return 0
17 }
18
19 local status
20 status=0
21
22 if [ "x${1}" = "x" ]; then
23   echo "Usage: update-initramfs <all | kernel version>"
24   echo "Examples:"
25   echo "  update-initramfs all"
26   echo "  update-initramfs 4.4.127-4.4-vanilla-1"
27   exit 0
28 elif [ "x${1}" = "xall" ]; then
29   for kernel in $(/bin/ls -1 /lib/modules/ 2>/dev/null); do
30     create_initramfs ${kernel}
31     if [ $? -ne 0 ]; then
32       status=1
33     fi
34   done
35 else
36   create_initramfs ${1}
37   if [ $? -ne 0 ]; then
38     status=1
39   fi
40 fi
41
42 exit ${status}