#!/bin/sh # description: Start/stop script for the Oracle 12c service # 11/2017 [lmuniz@lmunix.net] # chkconfig: 345 97 03 # : ${CTLFILE:="/var/lock/subsys/ora_*_orcl"} : ${ORACLE_HOME:="/u01/app/oracle/product/12.2.0/dbhome_1"} : ${ORAUSER:="oracle"} start() { [ "$(id -u)" -eq 0 ] || { echo "You need to be root" 1>&2; exit 2; } touch ${CTLFILE}; su ${ORAUSER} -c "${ORACLE_HOME}/bin/dbstart ${ORACLE_HOME}" } status() { if [ "$(ps -ef | grep "ora_" | grep -v "grep" | wc -l)" -gt 0 ] then echo "Oracle is running" else echo "Oracle is not running" fi } stop() { [ "$(id -u)" -eq 0 ] || { echo "You need to be root" 1>&2; exit 2; } rm -f ${CTLFILE}; su ${ORAUSER} -c "${ORACLE_HOME}/bin/dbshut ${ORACLE_HOME}" } usage() { echo "Usage: $(basename $0) {start|stop|status|restart|reload}" 1>&2; exit 2 } case $1 in start) start ;; stop) stop ;; status) status ;; restart |\ reload) stop; start;; *) usage;; esac