Advertisement
luisg_muniz

Oracle SysV script

Nov 10th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. #!/bin/sh
  2. # description: Start/stop script for the Oracle 12c service
  3. #              11/2017 [lmuniz@lmunix.net]
  4. # chkconfig:   345 97 03
  5. #
  6. : ${CTLFILE:="/var/lock/subsys/ora_*_orcl"}
  7. : ${ORACLE_HOME:="/u01/app/oracle/product/12.2.0/dbhome_1"}
  8. : ${ORAUSER:="oracle"}
  9.  
  10. start() { [ "$(id -u)" -eq 0 ] || { echo "You need to be root" 1>&2; exit 2; }
  11.           touch ${CTLFILE}; su ${ORAUSER} -c "${ORACLE_HOME}/bin/dbstart ${ORACLE_HOME}"
  12. }
  13.  
  14. status() {
  15.     if [ "$(ps -ef | grep "ora_" | grep -v "grep" | wc -l)" -gt 0 ]
  16.        then echo "Oracle is running"
  17.        else echo "Oracle is not running"
  18.     fi
  19. }
  20.  
  21. stop()  { [ "$(id -u)" -eq 0 ] || { echo "You need to be root" 1>&2; exit 2; }
  22.           rm -f ${CTLFILE}; su ${ORAUSER} -c "${ORACLE_HOME}/bin/dbshut ${ORACLE_HOME}"
  23. }
  24.  
  25. usage() { echo "Usage: $(basename $0) {start|stop|status|restart|reload}" 1>&2; exit 2
  26. }
  27.  
  28. case $1 in
  29.   start)  start ;;
  30.   stop)   stop ;;
  31.   status) status ;;
  32.   restart |\
  33.   reload) stop; start;;
  34.   *)      usage;;
  35. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement