- bump release number to differentiate from branch
[mom.git] / pl_mom.spec
1 %define name pl_mom
2 %define version 0.3
3 %define release 15%{?pldistro:.%{pldistro}}%{?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
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 /etc/cron.d/pl_mop
53
54 %pre
55
56
57 %post 
58 if [ "$1" -ge 1 ]; then
59
60         chkconfig --add pl_mom
61         chkconfig --level 3 pl_mom on
62
63         if [[ "$PL_BOOTCD" != "1" ]]; then
64                 /etc/init.d/pl_mom stop
65                 /etc/init.d/pl_mom start
66         fi
67
68         # Randomize pl_mop run time
69         M=$((60 * $RANDOM / 32768))
70         H=$((24 * $RANDOM / 32768))
71         sed -i -e "s/@M@/$M/" -e "s/@H@/$H/" /etc/cron.d/pl_mop
72 fi
73
74 %preun
75 if [ "$1" -eq 0 ]; then
76         if [[ "$PL_BOOTCD" != "1" ]]; then
77                 /etc/init.d/pl_mom stop
78         fi
79
80         chkconfig --del pl_mom
81         chkconfig pl_mom off
82 fi
83
84
85 %postun
86
87