pcsc-lite/debian/update-reader.conf

78 lines
2.2 KiB
Bash

#! /bin/sh
#
# This is the update-reader.conf script for Debian GNU/Linux.
# Written by Ludovic Rousseau <ludovic.rousseau@free.fr>
# Based on update-modules written by Wichert Akkerman <wakkerma@debian.org>
# Copyright (C) 2001 Software in the Public Interest
#
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# $Id: update-reader.conf,v 1.4 2005-03-24 13:17:57 rousseau Exp $
CFGFILE=/etc/reader.conf
TMPFILE=`mktemp /tmp/reader.conf.XXXXXX`
HEADER="### This file is automatically generated by update-reader.conf"
set -e
# Reset the sorting order since we depend on it
LC_COLLATE=C
export LC_COLLATE
if [ -f "$CFGFILE" ]; then
if ! sed -ne 1p "$CFGFILE" | grep -q "^$HEADER" ; then
echo "Error: the current $CFGFILE is not automatically generated."
if [ "$1" != "force" ]; then
echo "Use \"update-reader.conf force\" to force (re)generation."
exit 1
else
echo "force specified, (re)generating file anyway."
fi
fi
fi
if [ 0 -ne "`id -u`" ]; then
echo "You have to be root to run $0"
exit 2
fi
if [ -e "$CFGFILE" ]; then
cp -f "$CFGFILE" "${CFGFILE}.old"
fi
echo "$HEADER" > "$TMPFILE"
for cfg in /etc/reader.conf.d/* ; do
if ! echo "$cfg" | grep -q '\(\.dpkg-[a-z]*\|~\)$' ; then
echo "### update-reader.conf: start processing $cfg" >> "$TMPFILE"
if [ -x "$cfg" ]; then
"$cfg" >> "$TMPFILE"
else
cat "$cfg" >> "$TMPFILE"
fi
echo >> "$TMPFILE"
echo "### update-reader.conf: end processing $cfg" >> "$TMPFILE"
echo >> "$TMPFILE"
fi
done
cp "$TMPFILE" "$CFGFILE"
chmod 644 "$CFGFILE"
rm -f "$TMPFILE"