45 lines
1.2 KiB
Bash
Executable File
45 lines
1.2 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
version=@abiname@@localversion@
|
|
image_path=/boot/@image-stem@-$version
|
|
package_name=linux-image-$version
|
|
|
|
if [ "$1" != remove ]; then
|
|
exit 0
|
|
fi
|
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
# Are we in a container? Check for $container in pid 1's environment.
|
|
in_container() {
|
|
grep -qz '^container=' /proc/1/environ
|
|
}
|
|
|
|
# Check to see if we are trying to remove a running kernel.
|
|
if ! in_container && ! ischroot && [ "$(uname -r)" = $version ]; then
|
|
# If we can ask debconf questions, ask whether that's intended
|
|
# and abort if not.
|
|
if [ "$DEBIAN_FRONTEND" = noninteractive ]; then
|
|
echo >&2 "W: removing running kernel image."
|
|
else
|
|
question=${package_name}/prerm/removing-running-kernel-$version
|
|
db_fset $question seen false
|
|
db_subst $question running $version
|
|
db_input critical $question
|
|
db_go
|
|
db_get $question
|
|
if [ $RET = true ]; then
|
|
echo >&2 "Aborting removal of running kernel image."
|
|
exit 1
|
|
fi
|
|
echo >&2 "Ok, proceeding with removing running kernel image."
|
|
fi
|
|
fi
|
|
|
|
if [ -d /etc/kernel/prerm.d ]; then
|
|
DEB_MAINT_PARAMS="$*" run-parts --report --exit-on-error --arg=$version \
|
|
--arg=$image_path /etc/kernel/prerm.d
|
|
fi
|
|
|
|
exit 0
|