#!/bin/sh # rc.licences # This script checks for available licence text files in /etc/licence.d # Then prompt for the user agreement. In case the user denies the licence # the package(s) is(are) uninstalled # # Version: 1.0 12/12/2007 # # Author: Jean-Philippe Guillemin, # create the buffer directory buffer="$(mktemp -d -p /tmp temp.XXXXXXXX)" licencedir="/etc/licences.d" # Check for licence files and prompt for user agreement for licencetxt in $(ls ${licencedir}/* 2>/dev/null) ; do # if licence was already accepted, then skip grep -q "*** ACCEPTED ***" ${licencetxt} && continue sleep 2 clear licencename="$(sed -n 's/LICENCE NAME:[ \t]*\(.*\)/\1/p' ${licencetxt})" pkglist="$(sed -n 's/LICENCED PACKAGES:[ \t]*\(.*\)/\1/p' ${licencetxt})" pkgcount=$(echo $pkglist | wc -w) egrep -v "LICENCE NAME:|LICENCED PACKAGES:" ${licencetxt} > ${buffer}/licenceprompt.txt # Show the licence text dialog --cr-wrap --title "${licencename}" --textbox ${buffer}/licenceprompt.txt 20 80 if [ "$pkgcount" = "0" ] ; then echo "*** ACCEPTED ***" >> ${licencetxt} else answer="$(dialog --stdout --defaultno --title "${licencename}" --yesno "Do you accept the terms of the $licencename ?" 8 80 )" if [ $? -eq 0 ] ; then echo "*** ACCEPTED ***" >> ${licencetxt} else removepkg $pkglist 2>/dev/null 1>&2 rm -f ${licencetxt} /sbin/depmod -A /sbin/ldconfig fi fi done rm -rf $buffer