#!/bin/sh # # Copyright (c) 2005 Canonical LTD # # Author: Matt Zimmerman # # 2006, Oliver Grawert # Vagrant Cascadian # 2007, Scott Balneaves # Oliver Grawert # 2008, Vagrant Cascadian # Warren Togami # Oliver Grawert # 2009, Warren Togami # # 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. # set -e usage() { cat < /dev/null ### Cleanup old kernels and images from tftpboot directory ### # Find $version from vmlinuz-* filename # if corresponding /opt/ltsp/$arch/lib/modules/$version is missing # then delete kernel and images from tftpboot directory # # Some distros wont match vmlinuz-*, but this is at least safe # because it will simply cleanup nothing. removefiles() { # Common rm -f "$archpath/vmlinuz-$version" rm -f "$archpath/config-$version" rm -f "$archpath/System.map-$version" # Fedora rm -f "$archpath/initrd-$version.img" rm -f "$archpath/initramfs-$version.img" rm -f "$archpath/elf-$version.img" rm -f "$archpath/wraplinux-nbi-$version.img" rm -f "$archpath/aout-$version.img" # Debian rm -f "$archpath/initrd.img-$version" rm -f "$archpath/nbi.img-$version" } # Loop through every arch for archpath in $(find "$TFTPDIR/$TFTPBOOTDIR" -mindepth 1 -maxdepth 1 -type d); do arch=`basename $archpath` # Loop through every vmlinuz-* file for kernelpath in $(find "$TFTPDIR/$TFTPBOOTDIR/$arch" -name 'vmlinuz-*'); do kernel=`basename $kernelpath` version="${kernel##vmlinuz-}" if [ ! -d "$BASE/$arch/lib/modules/$version" ]; then echo "Removing $kernelpath" removefiles fi done done done exit 0