Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > 68ca03e6ec94a17ea56bc81915a42477 > files > 12

dynamic-0.4-7mdk.noarch.rpm

#---------------------------------------------------------------
# Project         : Mandrake Linux
# Module          : dynamic
# File            : functions.script
# Version         : $Id: functions.script,v 1.5 2001/09/21 00:06:13 flepied Exp $
# Author          : Frederic Lepied
# Created On      : Wed Aug  8 11:32:16 2001
# License         : GPL
# Purpose         : generic functions used by the dynamic scripts
#---------------------------------------------------------------

function call_hooks() {
    if [ $1 = add -a -x /sbin/pam_console_apply ]; then
	/sbin/pam_console_apply
    fi
    
    for f in /etc/dynamic/hooks/*.hook; do
	$f "$@"
    done
}

LAUNCHERS=/etc/dynamic/launchers

function handle_entry() {
    action=$1
    type=$2
    device=$3
    descr=$4
    desktop=$5
    dir=$6

    # generate a uniq filename
    name=$dir/dynamic`echo -n $device | sed 's@/@_@g'`.desktop
    
    if [ "$action" = add -a -f $LAUNCHERS/$type/$desktop.desktop ]; then
	cat $LAUNCHERS/$type/$desktop.desktop | sed -e "s@\$device@$device@g" -e "s@\$descr@$descr@g" > $name 2> /dev/null
    else
	rm -f $name
    fi
}

function check_activated() {
    name=`basename $0 .script | awk '{print toupper($0);}'`
    [ -r /etc/sysconfig/system ] && egrep -q "^DYNAMIC(_$name)?=no$" /etc/sysconfig/system && exit 0

    [ -r /proc/mounts ] || exit 0

    # Do nothing when root is mounted ro (mostly in rc.sysinit)
    ROOTOPTS=`awk '$2 == "/" {print $4}' < /proc/mounts`
    case ",$ROOTOPTS," in
	*,ro,*)
	exit 0
	;;
    esac
}

# functions.script ends here