/usr/sbin/ltsp-update-kernels is in ltsp-server 5.4.2-6+deb7u1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | #!/bin/sh
#
# Copyright (c) 2005 Canonical LTD
#
# Author: Matt Zimmerman <mdz@canonical.com>
#
# 2006, Oliver Grawert <ogra@canonical.com>
# Vagrant Cascadian <vagrant@freegeek.org>
# 2007, Scott Balneaves <sbalneav@ltsp.org>
# Oliver Grawert <ogra@canonical.com>
# 2008, Vagrant Cascadian <vagrant@freegeek.org>
# Warren Togami <wtogami@redhat.com>
# Oliver Grawert <ogra@canonical.com>
# 2009, Warren Togami <wtogami@redhat.com>
# 2012, Alkis Georgopoulos <alkisg@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, you can find it on the World Wide
# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
usage() {
cat <<EOF
Usage: $0 [OPTION] [CHROOT...]
Copies the chroot kernels to the TFTP directory. The TFTP directory
can be set in /etc/ltsp/ltsp-server.conf using a TFTP_DIR and a
TFTP_BOOT_DIR. The default TFTP directories are
/var/lib/tftpboot/ltsp, /tftpboot/ltsp and /srv/tftp/ltsp.
Options:
-b, --base= The LTSP base directory. Defaults to "/opt/ltsp".
-h, --help This message.
EOF
}
trap_cleanup() {
# Stop trapping
trap - 0 HUP INT QUIT KILL SEGV PIPE TERM
umount_marked
rmdir "$mnt"
}
update_kernels() {
local name tftpdir tftpboot chroot
name=$1
tftpdir=$2
tftpboot="$tftpdir/$TFTP_BOOT_DIR"
tftpboot=${tftpboot%/}
# Loop-mounting NBD images in order to copy their kernels is supported
# in order to allow for btrfs or ext loopback images, or images transferred
# from other sources to the LTSP server.
# But if both the chroot and the NBD image exist, the chroot is preferred,
# to make updating BOOTPROMPT_OPTS in update-kernels.conf easier.
# A PREFER_NBD_IMAGE environment variable is supported though, to make it
# possible for `ltsp-update-image --revert` to use the NBD kernels.
unset chroot
if [ -x "$BASE/$name/bin/true" ] && [ "$PREFER_NBD_IMAGE" != true ]; then
chroot="$BASE/$name"
elif [ -f "$BASE/images/$name.img" ]; then
if [ -z "$mnt" ]; then
mnt=$(mktemp -d)
trap "trap_cleanup" 0 HUP INT QUIT KILL SEGV PIPE TERM
else
umount_marked
fi
if mark_mount -o loop,ro "$BASE/images/$name.img" "$mnt"; then
chroot="$mnt"
fi
fi
if [ -z "$chroot" ]; then
echo "Skipping invalid chroot: $name"
continue
fi
echo "Updating $tftpdir directories for chroot: $name"
mkdir -p "$tftpboot/$name"
cp -a "$chroot/boot/." "$tftpboot/$name/"
# Ensure that the kernel is readable (LP: #759115)
for kernelpath in $(find "$tftpboot/$name/" -name 'vmlinuz-*' -o -name 'vmlinux-*'); do
chmod +r "$kernelpath"
done
# OFW on Mac is lame, they cannot tftp from directories
if [ -e "$tftpboot/$name/yaboot" ]; then
if [ ! -e "$tftpdir/yaboot" ]; then
ln -sf "$TFTP_BOOT_DIR/$name/yaboot" "$tftpdir/yaboot"
fi
if [ ! -e "$tftpdir/yaboot.conf" ]; then
ln -sf "$TFTP_BOOT_DIR/$name/yaboot.conf" "$tftpdir/yaboot.conf"
fi
fi
# Cleanup old kernels and images from tftpboot directory
cleanup_kernels "$name" "$tftpboot" "$chroot"
}
# distro specific functions
# For all kernels in TFTP, find the kernel $version from vmlinuz-* filename.
# If the corresponding /opt/ltsp/$name/lib/modules/$version is missing,
# then delete kernel and images for this version from tftpboot directory.
# Distros that don't match vmlinuz-* should override this function.
cleanup_kernels() {
local name tftpboot chroot
name=$1
tftpboot=$2
chroot=$3
# Loop through every vmlinuz-* file
for kernelpath in $(find "$tftpboot/$name/" -name 'vmlinuz-*' -o -name 'vmlinux-*'); do
kernel=${kernelpath##*/}
case $kernel in
vmlinuz-*) version=${kernel#vmlinuz-} ;;
vmlinux-*) version=${kernel#vmlinux-} ;;
esac
if [ ! -d "$chroot/lib/modules/$version" ]; then
echo "Removing $kernelpath"
# Common
rm -f "$tftpboot/$name/$kernel"
rm -f "$tftpboot/$name/config-$version"
rm -f "$tftpboot/$name/System.map-$version"
# Fedora
rm -f "$tftpboot/$name/initrd-$version.img"
rm -f "$tftpboot/$name/initramfs-$version.img"
rm -f "$tftpboot/$name/elf-$version.img"
rm -f "$tftpboot/$name/wraplinux-nbi-$version.img"
rm -f "$tftpboot/$name/aout-$version.img"
rm -f "$tftpboot/$name/symvers-$version.gz"
# Debian
rm -f "$tftpboot/$name/initrd.img-$version"
rm -f "$tftpboot/$name/nbi.img-$version"
# Ubuntu
rm -f "$tftpboot/$name/abi-$version"
rm -f "$tftpboot/$name/vmcoreinfo-$version"
fi
done
}
# This also sources vendor functions and .conf file settings
. /usr/share/ltsp/ltsp-server-functions
if ! args=$(getopt -n "$0" -o b:h \
-l "base:,help" -- "$@")
then
exit 1
fi
eval "set -- $args"
while true ; do
case "$1" in
-b|--base) shift; BASE=$1 ;;
-h|--help) usage; exit 0 ;;
--) shift ; break ;;
*) die "$0: Internal error!" ;;
esac
shift
done
require_root
BASE=${BASE:-"/opt/ltsp"}
# Remove trailing /, if present
BASE=${BASE%/}
# Chroots can be specified in the command line. If not, update all of them.
if [ $# -eq 0 ]; then
set -- $(
{
find "$BASE/" -mindepth 1 -maxdepth 1 -type d ! -name images \
-printf "%f\n"
if [ -d "$BASE/images/" ]; then
find "$BASE/images/" -mindepth 1 -maxdepth 1 -type f \
-name '*.img' -printf "%f\n" | sed 's/.img$//'
fi
} | sort -u
)
fi
test $# -gt 0 || die "No chroots found in $BASE"
for tftpdir in $TFTP_DIRS; do
if [ ! -d "$tftpdir" ]; then
# skip directory
continue
fi
for name in "$@"; do
update_kernels "$name" "$tftpdir"
done
# Update selinux file contexts if necessary
if [ -f /selinux/enforce ] && [ -x /sbin/restorecon ]; then
restorecon -R "$tftpdir" > /dev/null
fi
done
|