File: preload.init.in

package info (click to toggle)
preload 0.6.4-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 772 kB
  • sloc: ansic: 2,100; sh: 1,265; makefile: 196
file content (112 lines) | stat: -rwxr-xr-x 2,042 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#
#	@initddir@/@PACKAGE@
#
# Starts the @PACKAGE@ daemon
#
# chkconfig: 2345 05 95
# description: @PACKAGE_SUMMARY@
# processname: @PACKAGE@
#
### BEGIN INIT INFO
# Provides:          preload.sourceforge.net
# Required-Start:    $local_fs $remote_fs $time
# Required-Stop:     $local_fs $remote_fs $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: @PACKAGE_SUMMARY@
# Description:       Analyzes what applications users run and tries to predict
#                    what they would like to run and loads them into memory
#                    beforehand.
### END INIT INFO


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

[ -x @sbindir@/@PACKAGE@ ] || exit 0

if [ -f @sysconfigdir@/@PACKAGE@ ]; then
	. @sysconfigdir@/@PACKAGE@
fi

# Check for > MIN_MEMORY MB
MIN_MEMORY=${MIN_MEMORY:-256}
free -m | awk '/Mem:/ {exit ($2 >= ('"$MIN_MEMORY"'))?0:1}' || exit 0

# Check for ionice and use idle scheduling if available
RUNAS=""
IONICE="/usr/bin/ionice"
if [ -n "$IONICE_OPTS" ]; then
	if [ -x "$IONICE" ]; then
		RUNAS="$IONICE $IONICE_OPTS"
	else
		echo "ionice not found, running with normal io priority" >&2
	fi
fi

RETVAL=0

#
# See how we were called.
#

start() {
	# Check if it is already running
	if [ ! -f @subsysdir@/@PACKAGE@ ]; then
	    echo -n $"Starting @PACKAGE@ daemon: "
	    daemon $RUNAS @sbindir@/@PACKAGE@ $PRELOAD_OPTS
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch @subsysdir@/@PACKAGE@
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping @PACKAGE@ daemon: "
	killproc /usr/sbin/@PACKAGE@
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f @subsysdir@/@PACKAGE@
	echo
        return $RETVAL
}


restart() {
	stop
	start
}	

reload() {
	trap "" SIGHUP
	killall -HUP @PACKAGE@
}	

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
reload)
	reload
	;;
restart)
	restart
	;;
condrestart)
	if [ -f @subsysdir@/@PACKAGE@ ]; then
	    restart
	fi
	;;
status)
	status @PACKAGE@
	;;
*)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
	exit 1
esac

exit $RETVAL