- change Copyright to License
[mom.git] / pl_mom.spec
1 %define name pl_mom
2 %define version 0.3
3 %define release 10.planetlab%{?date:.%{date}}
4  
5 Summary: PlanetLab mom -- Cleans up your mess
6 Name: %{name}
7 Version: %{version}
8 Release: %{release}
9 License: dontknow
10 Group: System Environment/Kernel
11 Source: %{name}-%{version}.tgz
12 Vendor: PlanetLab
13 Packager: PlanetLab Central <support@planet-lab.org>
14 Distribution: PlanetLab 3.0
15 URL: http://cvs.planet-lab.org/cvs/pl_mom
16 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
17 Requires: expect
18  
19 %description
20
21 A small daemon that watches the consumed swap space.  At 90% utilization, it
22 resets the slice that is the biggest memory hog.  At 95% utilization, it 
23 reboots the machine.
24
25 A cron job which "fixes" various common problems with nodes (dead
26 services, ext3 corruption, zombie SSH sessions) is also installed.
27
28 %prep
29
30 %setup
31
32 %build
33
34 %install
35 mkdir -p $RPM_BUILD_ROOT/usr/local/planetlab/bin/
36 mkdir -p $RPM_BUILD_ROOT/etc/init.d/
37
38 cp pl_mom $RPM_BUILD_ROOT/etc/init.d/
39 cp pl_mom.pl $RPM_BUILD_ROOT/usr/local/planetlab/bin/
40 cp pl_mop.sh $RPM_BUILD_ROOT/usr/local/planetlab/bin/
41
42 install -D -m 644 pl_mop.cron $RPM_BUILD_ROOT/etc/cron.d/pl_mop.cron
43
44 %clean
45 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
46
47 %files
48 %defattr(0755, root, root)
49 /etc/init.d/pl_mom
50 /usr/local/planetlab/bin/pl_mom.pl
51 /usr/local/planetlab/bin/pl_mop.sh
52
53 %pre
54
55
56 %post 
57 if [ "$1" -ge 1 ]; then
58
59         chkconfig --add pl_mom
60         chkconfig --level 3 pl_mom on
61
62         if [[ "$PL_BOOTCD" != "1" ]]; then
63                 /etc/init.d/pl_mom stop
64                 /etc/init.d/pl_mom start
65         fi
66
67         # Randomize pl_mop run time
68         M=$((60 * $RANDOM / 32768))
69         H=$((24 * $RANDOM / 32768))
70         sed -i -e "s/@M@/$M/" -e "s/@H@/$H/" /etc/cron.d/pl_mop.cron
71 fi
72
73 %preun
74 if [ "$1" -eq 0 ]; then
75         if [[ "$PL_BOOTCD" != "1" ]]; then
76                 /etc/init.d/pl_mom stop
77         fi
78
79         chkconfig --del pl_mom
80         chkconfig pl_mom off
81 fi
82
83
84 %postun
85
86