1*eb8dc403SDave Cobbley#!/bin/sh 2*eb8dc403SDave Cobbley# 3*eb8dc403SDave Cobbley# openct This shell script takes care of starting and stopping OpenCT. 4*eb8dc403SDave Cobbley# 5*eb8dc403SDave Cobbley# chkconfig: 2345 24 89 6*eb8dc403SDave Cobbley# description: OpenCT is a middleware framework for smart card terminals. 7*eb8dc403SDave Cobbley# 8*eb8dc403SDave Cobbley# processname: ifdhandler 9*eb8dc403SDave Cobbley# config: /etc/openct.conf 10*eb8dc403SDave Cobbley 11*eb8dc403SDave Cobbley### BEGIN INIT INFO 12*eb8dc403SDave Cobbley# Provides: openct 13*eb8dc403SDave Cobbley# Default-Start: 2 3 4 5 14*eb8dc403SDave Cobbley# Default-Stop: 0 1 6 15*eb8dc403SDave Cobbley# Should-Start: $syslog $network 16*eb8dc403SDave Cobbley# Should-Stop: $syslog $network 17*eb8dc403SDave Cobbley# Short-Description: Middleware framework for smart card terminals 18*eb8dc403SDave Cobbley# Description: This starts/stops the OpenCT middleware framework support 19*eb8dc403SDave Cobbley# for smart card terminals. 20*eb8dc403SDave Cobbley### END INIT INFO 21*eb8dc403SDave Cobbley 22*eb8dc403SDave Cobbley. /etc/init.d/functions 23*eb8dc403SDave Cobbley 24*eb8dc403SDave Cobbleyexec="/usr/sbin/openct-control" 25*eb8dc403SDave Cobbleyprog=openct 26*eb8dc403SDave Cobbleyproc=ifdhandler 27*eb8dc403SDave Cobbley 28*eb8dc403SDave CobbleyOPENCT_OPTIONS= 29*eb8dc403SDave Cobbley[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog 30*eb8dc403SDave Cobbley 31*eb8dc403SDave Cobbleylockfile=/var/lock/subsys/$prog 32*eb8dc403SDave Cobbley 33*eb8dc403SDave Cobbleystart() { 34*eb8dc403SDave Cobbley retval=0 35*eb8dc403SDave Cobbley if ! status $proc >/dev/null 2>&1 ; then 36*eb8dc403SDave Cobbley action $"Initializing OpenCT smart card terminals: " \ 37*eb8dc403SDave Cobbley $exec $OPENCT_OPTIONS init 38*eb8dc403SDave Cobbley retval=$? 39*eb8dc403SDave Cobbley [ $retval -eq 0 ] && touch $lockfile 40*eb8dc403SDave Cobbley fi 41*eb8dc403SDave Cobbley return $retval 42*eb8dc403SDave Cobbley} 43*eb8dc403SDave Cobbley 44*eb8dc403SDave Cobbleystop() { 45*eb8dc403SDave Cobbley if status $proc >/dev/null 2>&1 ; then 46*eb8dc403SDave Cobbley action $"Stopping OpenCT smart card terminals: " \ 47*eb8dc403SDave Cobbley $exec $OPENCT_OPTIONS shutdown 48*eb8dc403SDave Cobbley fi 49*eb8dc403SDave Cobbley retval=$? 50*eb8dc403SDave Cobbley if [ $retval -eq 0 ] ; then 51*eb8dc403SDave Cobbley rm -f /var/run/openct/status 52*eb8dc403SDave Cobbley rm -f $lockfile 53*eb8dc403SDave Cobbley fi 54*eb8dc403SDave Cobbley return $retval 55*eb8dc403SDave Cobbley} 56*eb8dc403SDave Cobbley 57*eb8dc403SDave Cobbleyrestart() { 58*eb8dc403SDave Cobbley stop 59*eb8dc403SDave Cobbley start 60*eb8dc403SDave Cobbley} 61*eb8dc403SDave Cobbley 62*eb8dc403SDave Cobbleyoct_status() { 63*eb8dc403SDave Cobbley status $proc 64*eb8dc403SDave Cobbley retval=$? 65*eb8dc403SDave Cobbley if [ -e /var/run/openct/status ] ; then 66*eb8dc403SDave Cobbley $exec $OPENCT_OPTIONS status 67*eb8dc403SDave Cobbley [ -e /var/run/openct/status ] && \ 68*eb8dc403SDave Cobbley echo $"Waiting for reader attach/detach events..." 69*eb8dc403SDave Cobbley fi 70*eb8dc403SDave Cobbley return $retval 71*eb8dc403SDave Cobbley} 72*eb8dc403SDave Cobbley 73*eb8dc403SDave Cobbleycase "$1" in 74*eb8dc403SDave Cobbley start|stop|restart) 75*eb8dc403SDave Cobbley $1 76*eb8dc403SDave Cobbley ;; 77*eb8dc403SDave Cobbley reload|force-reload) 78*eb8dc403SDave Cobbley restart 79*eb8dc403SDave Cobbley ;; 80*eb8dc403SDave Cobbley status) 81*eb8dc403SDave Cobbley oct_status 82*eb8dc403SDave Cobbley ;; 83*eb8dc403SDave Cobbley try-restart|condrestart) 84*eb8dc403SDave Cobbley [ ! -f $lockfile ] || restart 85*eb8dc403SDave Cobbley ;; 86*eb8dc403SDave Cobbley *) 87*eb8dc403SDave Cobbley echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}" 88*eb8dc403SDave Cobbley exit 2 89*eb8dc403SDave Cobbleyesac 90