File: install-cron.sh

package info (click to toggle)
slocate 2.7-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 508 kB
  • ctags: 221
  • sloc: ansic: 2,125; sh: 775; makefile: 100
file content (31 lines) | stat: -rwxr-xr-x 757 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

CRONTAB=/etc/crontab

if [ ! -e $CRONTAB ] ; then
   echo "Could not locate $CRONTAB file"
   exit 0
fi

grep "slocate\|updatedb" $CRONTAB >/dev/null 2>&1

if [ "$?" -eq "1" ] ; then

   # Check if updatedb exists
   if [ -x /usr/bin/updatedb ] ; then
   
      # Check if a configuration file exists
      if [ -f /etc/updatedb.conf ] ; then
	 echo "0 6    * * *   root /usr/bin/updatedb" >>$CRONTAB
      else
         echo "0 6    * * *   root /usr/bin/updatedb -f proc" >>$CRONTAB
      fi      
   elif [ -x /usr/bin/slocate ] ; then
       echo "0 6    * * *   root /usr/bin/slocate -u -f proc" >>$CRONTAB
   else
       echo "Could not find a slocate binary"
   fi
   
else
   echo "Cron entry already exists in $CRONTAB for slocate"
fi