db12.init 2.04 KB
Newer Older
1
2
3
4
#!/bin/bash
#
# db12		Run DB12 fast benchmark and create /etc/db12 files
#
5
# chkconfig: 345 01 99
6
7
8
9
10
11
12
# description: Run DB12 fast benchmark and create /etc/db12 files

# Source function library.
. /etc/init.d/functions

# If total_cpu is already created (in Kickstart?), we use that:
#
13
if [ -r /etc/db12/total_cpu ] ; then
Andrew McNab's avatar
Fixes    
Andrew McNab committed
14
  total_cpu=`cat /etc/db12/total_cpu`
15
16
17
fi

if [ "$total_cpu" == "" ] ; then
Andrew McNab's avatar
Andrew McNab committed
18
  # If total_cpu not given in /etc/db12/total_cpu then count OS processors
19
20
  total_cpu=`grep '^processor[[:space:]]*:' /proc/cpuinfo | wc --lines`
  mkdir -p /etc/db12
Andrew McNab's avatar
Andrew McNab committed
21
  echo "$total_cpu" > /etc/db12/total_cpu
22
23
fi

24
25
26
27
28
29
30
31
32
if [ -r /etc/db12/iterations ] ; then
  iterations=`cat /etc/db12/iterations`
fi

if [ "$iterations" == "" ] ; then
  iterations=1
  echo "$iterations" >/etc/db12/iterations
fi

33
34
35
36
start() {
	[ "$EUID" != "0" ] && exit 1

        echo -n $"Run DB12 fast benchmark: "
Andrew McNab's avatar
Andrew McNab committed
37
38
        
        if [ -x /bin/plymouth ] ; then
Andrew McNab's avatar
Comment    
Andrew McNab committed
39
         # Plymouth boot up splash screen uses lots of CPU!
Andrew McNab's avatar
Andrew McNab committed
40
         plymouth hide-splash
Andrew McNab's avatar
Andrew McNab committed
41
        fi
42
43
44
        
        # Try to use full CPU speed for benchmarking
        modprobe acpi-cpufreq
45
        for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ; do echo performance > $i ; done
46
47

        # Get the total benchmark for this machine, assuming $total_cpu jobslots 
48
        db12_sum=`/usr/sbin/DIRACbenchmark.py --iterations=$iterations --extra-iteration $total_cpu | head -1 | cut -f2 -d' '`
49
50
51
52
53

        if [ "$db12_sum" != "" ] ; then
          echo "$db12_sum" > /etc/db12/db12
        fi

54
55
56
        # Set the governor to ondemand, in case run outside the SysV boot and not followed by cpuspeed
        for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor ; do echo ondemand > $i ; done

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
        echo_success
        echo
	return 0
}

stop() {
	[ "$EUID" != "0" ] && exit 3

        echo -n $"Dummy DB12 stop action: "
        echo_success
        echo
	return 0
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|force-reload|reload)
        stop
	start
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|force-reload|reload}"
	exit 4
esac