- 论坛徽章:
- 0
|
以下脚本在AIX和HP-UX下运行正常,但在Solaris运行不太好,各位老大给点意见,我对这它们之间的命令不熟阿!
# Script environment variables
NOTES_USER=notes # SUN-Solaris8 Userid for this server
NOTES_PATH=/data/notesdata # Data directory for this server
NOTES_SERVER=gdgsoa # Name of Domino Server
OUTPUT_LOG=/tmp/"console_$NOTES_SERVER.out" # Output file for server console
INPUT_FILE=/tmp/"console_$NOTES_SERVER.in" # Input file for server console
export NOTES_USER NOTES_PATH NOTES_SERVER OUTPUT_LOG INPUT_FILE
# the argument "start" ,"stop" or "monitor"will be passed as the first argument.
case $1 in
"start"
if [ ! -x /opt/lotus/bin/server ] ; then
echo "Cannot access server command - exiting"
exit 1
fi
if [ -f $INPUT_FILE ] ; then
rm $INPUT_FILE
fi
touch $INPUT_FILE
if [ ! -d $NOTES_PATH ] ; then
echo "Cannot access Domino data directory - exiting"
exit 1
fi
NOTES_RUNNING=`ps -fu $NOTES_USER | grep lotus | grep -v grep `
if [[ -n $NOTES_RUNNING ]] ; then
echo "Domino Server is already running - exiting"
exit 1
fi
cd $NOTES_PATH
rm -f ~notes.lck
mems=`ipcs | grep $NOTES_USER | awk '{ print $1 $2 }' | awk -F"m" '{ print $2 }' | awk '{ print $1 }'`
sems=`ipcs | grep $NOTES_USER | awk '{ print $1 $2 }' | awk -F"s" '{ print $2 }' | awk '{ print $1 }'`
for j in $mems;do if [ -n "$j" ] ; then ipcrm -m $j;fi;done
for j in $sems;do if [ -n "$j" ] ; then ipcrm -s $j;fi;done
# cp -p $OUTPUT_LOG $OUTPUT_LOG.backup
echo "Starting Domino for SUN-Solaris8 ($NOTES_SERVER)"
/opt/lotus/bin/server < $INPUT_FILE > $OUTPUT_LOG 2>&1 &
sleep 10
echo "Domino Server for SUN-Solaris8 ($NOTES_SERVER) started"
;;
"stop"
echo "Stopping Domino for SUN-Solaris8 ($NOTES_SERVER)"
echo "....waiting for shutdown to complete"
echo "quit">>$INPUT_FILE
count=0
NOTES_RUNNING=`ps -fu $NOTES_USER | grep /opt/lotus | grep -v grep`
while [[ -n $NOTES_RUNNING ]] ; do
sleep 10
count=`expr $count + 1`
echo " ... Waiting "$count"0 seconds"
if [ $count -eq 13 ] ; then
echo "Domino is still running after 2 minutes"
echo " .... now for the ungraceful method"
for i in `ps -fu $NOTES_USER | grep lotus | grep -v grep | awk '{ print $2 }'`; do
kill -9 $i
done
mems=`ipcs | grep $NOTES_USER | awk '{ print $1 $2 }' | awk -F"m" '{ print $2 }' | awk '{ print $1 }'`
sems=`ipcs | grep $NOTES_USER | awk '{ print $1 $2 }' | awk -F"s" '{ print $2 }' | awk '{ print $1 }'`
for j in $mems;do if [ -n "$j" ] ; then ipcrm -m $j;fi;done
for j in $sems;do if [ -n "$j" ] ; then ipcrm -s $j;fi;done
echo "Domino Server ($NOTES_SERVER) TERMINATED"
exit
fi
NOTES_RUNNING=`ps -fu $NOTES_USER | grep /opt/lotus | grep -v grep`
done
echo "Domino for SUN-Solaris8 ($NOTES_SERVER) shutdown completed"
;;
"monitor"
CURRENT_TTY=`tty`
function stop_monitor
{
echo ""
echo "Exiting Domino Monitor..."
echo ""
kill -9 $TAILPID
exit 0
}
PCOUNT=`ps -fu $NOTES_USER | grep /opt/lotus | grep -v grep | awk '{ print $2 }' | wc -w`
if [ $PCOUNT -lt 1 ]; then
echo ""
echo "The Domino for SUN-Solaris8 ($NOTES_SERVER) does not appear to be started. Monitor terminating."
echo ""
exit 1
fi
trap "stop_monitor" 1 2 3
echo ""
echo "******************************************************************"
echo " To exit this monitor enter a <CTRL>-C"
echo "******************************************************************"
echo ""
tail -f $OUTPUT_LOG >> $CURRENT_TTY &
TAILPID=$!
while [ 1 -eq 1 ] ; do
CMD=""
OPT=""
read CMD OPT
case $CMD in
"cls" clear
echo "" >> $INPUT_FILE ;;
"CLS" clear
echo "" >> $INPUT_FILE ;;
"clear" if [[ "$OPT" = "log" || "$OPT" = "LOG" ]]; then
echo "Log cleared on `date`" > $OUTPUT_LOG
echo "" >> $OUTPUT_LOG
fi
echo "" >> $INPUT_FILE ;;
"CLEAR" if [[ "$OPT" = "log" || "$OPT" = "LOG" ]]; then
echo "Log cleared on `date`" > $OUTPUT_LOG
echo "" >> $OUTPUT_LOG
fi
echo "" >> $INPUT_FILE ;;
"exit" echo "If you want to quit monitor console, enter <CTRL>-C" >> $OUTPUT_LOG
echo "If you want to EXIT domino server, enter command 'shutdown' " >> $OUTPUT_LOG
echo ">" >> $OUTPUT_LOG ;;
"quit" echo "If you want to quit monitor console, enter <CTRL>-C" >> $OUTPUT_LOG
echo "If you want to EXIT domino server, enter command 'shutdown' " >> $OUTPUT_LOG
echo ">" >> $OUTPUT_LOG ;;
"q" echo "If you want to quit monitor console, enter <CTRL>-C" >> $OUTPUT_LOG
echo "If you want to EXIT domino server, enter command 'shutdown' " >> $OUTPUT_LOG
echo ">" >> $OUTPUT_LOG ;;
"shutdown") echo "quit" >> $INPUT_FILE ;;
"EXIT") echo "If you want to quit monitor console, enter <CTRL>-C" >> $OUTPUT_LOG
echo "If you want to EXIT domino server, enter command 'shutdown' " >> $OUTPUT_LOG
echo ">" >> $OUTPUT_LOG ;;
"QUIT") echo "If you want to quit monitor console, enter <CTRL>-C" >> $OUTPUT_LOG
echo "If you want to EXIT domino server, enter command 'shutdown' " >> $OUTPUT_LOG
echo ">" >> $OUTPUT_LOG ;;
"Q") echo "If you want to quit monitor console, enter <CTRL>-C" >> $OUTPUT_LOG
echo "If you want to EXIT domino server, enter command 'shutdown' " >> $OUTPUT_LOG
echo ">" >> $OUTPUT_LOG ;;
"SHUTDOWN") echo "quit" >> $INPUT_FILE ;;
*) echo $CMD $OPT >> $INPUT_FILE ;;
esac
done
stop_monitor
;;
*)
echo "Usage: $0 { start | stop | monitor }"
exit 1
;;
esac
exit 0 |
|