moskovets
Рейтинг
0.00
Сила
0.01

moskovets

Юрий

avatar
у меня оцень цуцуть, как то по детски)))

#!/bin/bash
# script ver.1.0 to create dump OpenLDAP
#########################################
# setting environment variable
HOSTNAME=`/bin/hostname`
DUMP_DATE=`/bin/date "+%Y-%m-%d"`
DUMP_DATE_OLD=`/bin/date --date='-4 weeks' '+%Y-%m-%d'`
DUMP_PATH="/repo/backup/OpenLDAP/"
DUMP_NAME="$HOSTNAME"_"$DUMP_DATE".ldif
DUMP_NAME_OLD="$HOSTNAME"_"$DUMP_DATE_OLD".ldif
DUMP_FULL_PATH="$DUMP_PATH""$DUMP_NAME"
DUMP_FULL_PATH_OLD="$DUMP_PATH""$DUMP_NAME_OLD"
SLAPD="/etc/init.d/slapd"
SLAPCAT="/usr/sbin/slapcat -l"
SLAPCAT_RUN="$SLAPCAT $DUMP_FULL_PATH"
#########################################
$SLAPD stop
PID_file=/var/run/slapd/slapd.pid
if [[ -e $PID_file ]]
 then
  echo "slapd is not stopped..."
  echo "script is stopped!!!"
  exit 1
fi
#########################################
$SLAPCAT_RUN
if [[ -e $DUMP_FULL_PATH ]]
  then
  echo "OpenLDAP database dump is written to the file!"
  $SLAPD start
  PID_number=`cat /var/run/slapd/slapd.pid`
   if [ -n "$PID_number" ]
    then
     echo "slapd is running...ProcessID $PID_number"
      rm -rf $DUMP_FULL_PATH_OLD
     exit 0
    else
     echo "slapd is not running!!!"
     exit 1
   fi
fi
#########################################
echo "OpenLDAP database dump is NOT written!!!"
$SLAPD start
PID_number=`cat /var/run/slapd/slapd.pid`
if [ -n "$PID_number" ]
 then
  echo "slapd is running...ProcessID $PID_number"
  exit 0
fi
echo "slapd is not running!!!"
exit 1