echo "******* EDIT /etc/oratab FIRST:"
read -p "Ctrl-C to quit" DUMMY
cat /etc/oratab
echo "******* "

read -p ORACLE_HOME: OH

LSERV="/lib/systemd/system/tnslsnr.service"
OSERV="/lib/systemd/system/oracle.service"

echo "[Unit]" > $LSERV
echo "Description=tnslsnr" >> $LSERV
echo "After=network.target" >> $LSERV
echo "" >> $LSERV
echo "[Service]" >> $LSERV
echo "User=oracle" >> $LSERV
echo "Group=dba" >> $LSERV
echo "Type=forking" >> $LSERV
echo "Environment='ORACLE_HOME=$OH' " >> $LSERV
echo "ExecStart=$OH/bin/lsnrctl start " >> $LSERV
echo "ExecStop=$OH/lsnrctl stop " >> $LSERV
echo " " >> $LSERV
echo "[Install]" >> $LSERV
echo "WantedBy=multi-user.target" >> $LSERV

echo "[Unit]" > $OSERV
echo "Description=oracle" >> $OSERV
echo "" >> $OSERV
echo "[Service]" >> $OSERV
echo "LimitMEMLOCK=infinity" >> $OSERV
echo "LimitNOFILE=65535" >> $OSERV
echo "RemainAfterExit=yes" >> $OSERV
echo "User=oracle" >> $OSERV
echo "Group=dba" >> $OSERV
echo "Restart=no" >> $OSERV
echo "Environment='$OH'" >> $OSERV
echo "ExecStart=$OH/bin/dbstart $OH" >> $OSERV
echo "ExecStop=$OH/bin/dbshut $OH" >> $OSERV
echo "" >> $OSERV
echo "[Install]" >> $OSERV
echo "WantedBy=multi-user.target" >> $OSERV

systemctl daemon-reload

systemctl daemon-reload
systemctl list-unit-files | egrep 'tns|oracle'

systemctl enable tnslsnr.service
systemctl start tnslsnr.service

systemctl enable oracle.service
systemctl start oracle.service


