Imported Upstream version 24.1
[rrq/maintain_lilo.git] / hooks / kernel / postinst.d / chattr-lilo
1 #!/bin/sh
2 #
3 #  chattr-lilo  -  postinst script for sure kernel install/upgrade
4 #
5 #  Copyright (C) 2012-2014 Joachim Wiedorn
6 #  All rights reserved.
7 #
8 #  Licensed under the terms contained in the file 'COPYING'
9 #  in the source directory.
10 #
11
12 set -e
13
14 CHATTR=`which chattr` || exit 0
15 XFSINFO=`which xfs_info` || exit 0
16
17 if test -x $XFSINFO; then
18   # check whether root partition is of xfs type
19   [ `LANG=C $XFSINFO / | grep -c "attr="` -eq 1 ] || exit 0
20 fi
21
22 # second argument gives the path and filename
23 # first argument gives only the kernel version
24 if [ -n "${2}" ]; then
25   IMAGE="${2}"
26 elif [ -n "${1}" ]; then
27   IMAGE="/boot/vmlinuz-${1}"
28 else
29   echo "[postinst.d] do not execute chattr"
30   exit 0
31 fi
32
33 if [ -f "$IMAGE" ]; then
34   echo "[postinst.d] chattr +i ${IMAGE}"   >&2
35   $CHATTR +i "${IMAGE}"
36 fi
37
38 # end of file