#!/bin/sh
#set -x
tmp=
log_filepath=run.log
pid_name=mongo_sh.pid
mongodb_home=/root/mongo
mongodb_sh=mongo_exec.sh
mongodb_cmd="$mongodb_home/bin/mongo localhost:30000/uc"
function usage(){
echo "Usage: $0 start"
echo "options:"
echo " start --start mongodb clear server service"
echo " help --dispaly mongodb clear server help"
}
function start(){
if [ $# != 1 ]; then
echo "Input error. Please input $0 start"
usage
exit 1
fi
if [ ! -d $mongodb_home ]; then
echo "The mongodb_home $mongodb_home doesn't exist,please make sure the install path is correct."
exit 1
fi
if [ ! -f $log_filepath ]; then
touch $log_filepath
fi
tmp=`ps -ef | grep mongo_run|grep start | wc -l`
if [ $tmp -gt 2 ]; then
echo "The server arealdy started..."
exit 1
fi
echo "$mongodb_cmd << END_CMD " >$mongodb_sh
echo "db.repairDatabase()" >> $mongodb_sh
echo "exit" >> $mongodb_sh
echo "END_CMD" >> $mongodb_sh
chmod +x $mongodb_sh
echo "server is running ,please wait..."
date -d today +"%Y-%m-%d %H:%M:%S" >> $log_filepath
./$mongodb_sh >> $log_filepath 2>&1 &
echo "It's ok. [Finish]"
exit 1
}
case $1 in
start)
start $@
;;
help|*)
usage $@
;;
esac
exit $?
#set -x
tmp=
log_filepath=run.log
pid_name=mongo_sh.pid
mongodb_home=/root/mongo
mongodb_sh=mongo_exec.sh
mongodb_cmd="$mongodb_home/bin/mongo localhost:30000/uc"
function usage(){
echo "Usage: $0 start"
echo "options:"
echo " start --start mongodb clear server service"
echo " help --dispaly mongodb clear server help"
}
function start(){
if [ $# != 1 ]; then
echo "Input error. Please input $0 start"
usage
exit 1
fi
if [ ! -d $mongodb_home ]; then
echo "The mongodb_home $mongodb_home doesn't exist,please make sure the install path is correct."
exit 1
fi
if [ ! -f $log_filepath ]; then
touch $log_filepath
fi
tmp=`ps -ef | grep mongo_run|grep start | wc -l`
if [ $tmp -gt 2 ]; then
echo "The server arealdy started..."
exit 1
fi
echo "$mongodb_cmd << END_CMD " >$mongodb_sh
echo "db.repairDatabase()" >> $mongodb_sh
echo "exit" >> $mongodb_sh
echo "END_CMD" >> $mongodb_sh
chmod +x $mongodb_sh
echo "server is running ,please wait..."
date -d today +"%Y-%m-%d %H:%M:%S" >> $log_filepath
./$mongodb_sh >> $log_filepath 2>&1 &
echo "It's ok. [Finish]"
exit 1
}
case $1 in
start)
start $@
;;
help|*)
usage $@
;;
esac
exit $?