Converted initscript to systemd service file (#617330)
Thanks to Jóhann B. Guðmundsson for initial work.
This commit is contained in:
parent
854751f9bd
commit
305f583cd4
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,94 @@
|
|||
From c7f825b2c4a5c7d4ac8abe5690737c2c8fffbfcc Mon Sep 17 00:00:00 2001
|
||||
From: Kalev Lember <kalev@smartlink.ee>
|
||||
Date: Fri, 24 Jun 2011 00:46:13 +0300
|
||||
Subject: [PATCH 2/3] Add --disable-autostart option
|
||||
|
||||
This option disables pcscd autostarting code in the libpcsclite library.
|
||||
|
||||
With systemd socket activation in place, pcscd can be started
|
||||
automatically by systemd when a request arrives on the IPC socket. That
|
||||
makes starting the service as a fork from user library unnecessary.
|
||||
---
|
||||
PCSC/configure.in | 11 +++++++++++
|
||||
PCSC/src/winscard_clnt.c | 6 ++++++
|
||||
2 files changed, 17 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/PCSC/configure.in b/PCSC/configure.in
|
||||
index 831ee88..97e3360 100644
|
||||
--- a/PCSC/configure.in
|
||||
+++ b/PCSC/configure.in
|
||||
@@ -274,6 +274,16 @@ if test x$use_libusb = xyes; then
|
||||
PCSCLITE_FEATURES="${PCSCLITE_FEATURES} libusb"
|
||||
fi
|
||||
|
||||
+# --disable-autostart
|
||||
+AC_ARG_ENABLE(autostart,
|
||||
+ AC_HELP_STRING([--disable-autostart], [disable pcscd automatic startup]),
|
||||
+ [ use_autostart="${enableval}" ], [ use_autostart="yes" ] )
|
||||
+
|
||||
+if test x$use_autostart != xno; then
|
||||
+ AC_DEFINE(ENABLE_AUTOSTART, 1, [Enable pcscd automatic startup])
|
||||
+ PCSCLITE_FEATURES="${PCSCLITE_FEATURES} autostart"
|
||||
+fi
|
||||
+
|
||||
# --enable-embedded
|
||||
AC_ARG_ENABLE(embedded,
|
||||
AC_HELP_STRING([--enable-embedded], [limit RAM and CPU ressources by disabling features (log)]),
|
||||
@@ -381,6 +391,7 @@ ATR parsing messages: ${debugatr}
|
||||
ipcdir: ${ipcdir}
|
||||
use serial: ${use_serial}
|
||||
use usb: ${use_usb}
|
||||
+use autostart: ${use_autostart}
|
||||
|
||||
PCSCLITE_FEATURES: ${PCSCLITE_FEATURES}
|
||||
|
||||
diff --git a/PCSC/src/winscard_clnt.c b/PCSC/src/winscard_clnt.c
|
||||
index 92c8481..982be01 100644
|
||||
--- a/PCSC/src/winscard_clnt.c
|
||||
+++ b/PCSC/src/winscard_clnt.c
|
||||
@@ -444,8 +444,10 @@ LONG SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1,
|
||||
LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
|
||||
{
|
||||
LONG rv;
|
||||
+#ifdef ENABLE_AUTOSTART
|
||||
int daemon_launched = FALSE;
|
||||
int retries = 0;
|
||||
+#endif
|
||||
|
||||
API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
|
||||
PROFILE_START
|
||||
@@ -457,6 +459,7 @@ again:
|
||||
/* we reconnected to a daemon or we got called from a forked child */
|
||||
rv = SCardCheckDaemonAvailability();
|
||||
|
||||
+#ifdef ENABLE_AUTOSTART
|
||||
if (SCARD_E_NO_SERVICE == rv)
|
||||
{
|
||||
launch:
|
||||
@@ -517,6 +520,7 @@ launch:
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
if (rv != SCARD_S_SUCCESS)
|
||||
goto end;
|
||||
@@ -526,6 +530,7 @@ launch:
|
||||
pvReserved2, phContext);
|
||||
(void)SCardUnlockThread();
|
||||
|
||||
+#ifdef ENABLE_AUTOSTART
|
||||
/* SCardEstablishContextTH may fail if the previous pcscd crashed
|
||||
* without cleaning /var/run/pcscd/pcscd.comm */
|
||||
if (SCARD_E_NO_SERVICE == rv)
|
||||
@@ -534,6 +539,7 @@ launch:
|
||||
if (retries <= 1)
|
||||
goto launch;
|
||||
}
|
||||
+#endif
|
||||
|
||||
end:
|
||||
PROFILE_END(rv)
|
||||
--
|
||||
1.7.5.4
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
From 0f85375fd8949e529a6f46c07cdabda74040fd8a Mon Sep 17 00:00:00 2001
|
||||
From: Kalev Lember <kalev@smartlink.ee>
|
||||
Date: Fri, 24 Jun 2011 22:32:33 +0300
|
||||
Subject: [PATCH 3/3] Install systemd service files
|
||||
|
||||
---
|
||||
PCSC/Makefile.am | 5 ++++-
|
||||
PCSC/configure.in | 32 ++++++++++++++++++++++----------
|
||||
PCSC/etc/Makefile.am | 9 +++++++++
|
||||
PCSC/etc/pcscd.service.in | 13 +++++++++++++
|
||||
PCSC/etc/pcscd.socket.in | 8 ++++++++
|
||||
5 files changed, 56 insertions(+), 11 deletions(-)
|
||||
create mode 100644 PCSC/etc/Makefile.am
|
||||
create mode 100644 PCSC/etc/pcscd.service.in
|
||||
create mode 100644 PCSC/etc/pcscd.socket.in
|
||||
|
||||
diff --git a/PCSC/Makefile.am b/PCSC/Makefile.am
|
||||
index 079b58a..c515128 100644
|
||||
--- a/PCSC/Makefile.am
|
||||
+++ b/PCSC/Makefile.am
|
||||
@@ -1,10 +1,13 @@
|
||||
-SUBDIRS = m4 src doc
|
||||
+SUBDIRS = m4 src etc doc
|
||||
|
||||
fix-rights:
|
||||
$(MAKE) -C src $@
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
+DISTCHECK_CONFIGURE_FLAGS = \
|
||||
+ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
|
||||
+
|
||||
EXTRA_DIST = DRIVERS SECURITY bootstrap HELP ChangeLog.svn
|
||||
|
||||
DISTCLEANFILES = ChangeLog.svn
|
||||
diff --git a/PCSC/configure.in b/PCSC/configure.in
|
||||
index 97e3360..cc6fe5f 100644
|
||||
--- a/PCSC/configure.in
|
||||
+++ b/PCSC/configure.in
|
||||
@@ -274,6 +274,14 @@ if test x$use_libusb = xyes; then
|
||||
PCSCLITE_FEATURES="${PCSCLITE_FEATURES} libusb"
|
||||
fi
|
||||
|
||||
+AC_ARG_WITH([systemdsystemunitdir],
|
||||
+ AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
|
||||
+ [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
|
||||
+if test "x$with_systemdsystemunitdir" != xno; then
|
||||
+ AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
|
||||
+fi
|
||||
+AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
|
||||
+
|
||||
# --disable-autostart
|
||||
AC_ARG_ENABLE(autostart,
|
||||
AC_HELP_STRING([--disable-autostart], [disable pcscd automatic startup]),
|
||||
@@ -383,17 +391,18 @@ PTHREAD_CFLAGS: ${PTHREAD_CFLAGS}
|
||||
PTHREAD_LIBS: ${PTHREAD_LIBS}
|
||||
PCSC_ARCH: ${PCSC_ARCH}
|
||||
|
||||
-pcscd binary ${PCSCD_BINARY}
|
||||
-libudev support: ${use_libudev}
|
||||
-libusb support: ${use_libusb}
|
||||
-USB drop directory: ${usbdropdir}
|
||||
-ATR parsing messages: ${debugatr}
|
||||
-ipcdir: ${ipcdir}
|
||||
-use serial: ${use_serial}
|
||||
-use usb: ${use_usb}
|
||||
-use autostart: ${use_autostart}
|
||||
+pcscd binary ${PCSCD_BINARY}
|
||||
+libudev support: ${use_libudev}
|
||||
+libusb support: ${use_libusb}
|
||||
+USB drop directory: ${usbdropdir}
|
||||
+ATR parsing messages: ${debugatr}
|
||||
+ipcdir: ${ipcdir}
|
||||
+use serial: ${use_serial}
|
||||
+use usb: ${use_usb}
|
||||
+use autostart: ${use_autostart}
|
||||
+systemd unit directory: ${with_systemdsystemunitdir}
|
||||
|
||||
-PCSCLITE_FEATURES: ${PCSCLITE_FEATURES}
|
||||
+PCSCLITE_FEATURES: ${PCSCLITE_FEATURES}
|
||||
|
||||
EOF
|
||||
|
||||
@@ -406,6 +415,9 @@ doc/doxygen.conf
|
||||
doc/pcscd.8
|
||||
doc/reader.conf.5
|
||||
doc/example/Makefile
|
||||
+etc/Makefile
|
||||
+etc/pcscd.service
|
||||
+etc/pcscd.socket
|
||||
src/Makefile
|
||||
src/libpcsclite.pc
|
||||
src/pcscd.h
|
||||
diff --git a/PCSC/etc/Makefile.am b/PCSC/etc/Makefile.am
|
||||
new file mode 100644
|
||||
index 0000000..6ab04fc
|
||||
--- /dev/null
|
||||
+++ b/PCSC/etc/Makefile.am
|
||||
@@ -0,0 +1,9 @@
|
||||
+if HAVE_SYSTEMD
|
||||
+SCRIPT_IN_FILES = \
|
||||
+ pcscd.service.in \
|
||||
+ pcscd.socket.in
|
||||
+
|
||||
+systemdsystemunit_DATA = \
|
||||
+ pcscd.service \
|
||||
+ pcscd.socket
|
||||
+endif
|
||||
diff --git a/PCSC/etc/pcscd.service.in b/PCSC/etc/pcscd.service.in
|
||||
new file mode 100644
|
||||
index 0000000..4800d32
|
||||
--- /dev/null
|
||||
+++ b/PCSC/etc/pcscd.service.in
|
||||
@@ -0,0 +1,13 @@
|
||||
+[Unit]
|
||||
+Description=PC/SC Smart Card Daemon
|
||||
+Requires=pcscd.socket
|
||||
+After=syslog.target
|
||||
+
|
||||
+[Service]
|
||||
+ExecStart=@sbindir_exp@/pcscd -f
|
||||
+ExecReload=@sbindir_exp@/pcscd -H
|
||||
+StandardOutput=syslog
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=multi-user.target
|
||||
+Also=pcscd.socket
|
||||
diff --git a/PCSC/etc/pcscd.socket.in b/PCSC/etc/pcscd.socket.in
|
||||
new file mode 100644
|
||||
index 0000000..6fc93da
|
||||
--- /dev/null
|
||||
+++ b/PCSC/etc/pcscd.socket.in
|
||||
@@ -0,0 +1,8 @@
|
||||
+[Unit]
|
||||
+Description=PC/SC Smart Card Daemon Activation Socket
|
||||
+
|
||||
+[Socket]
|
||||
+ListenStream=@ipcdir@/pcscd.comm
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=sockets.target
|
||||
--
|
||||
1.7.5.4
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
diff -up pcsc-lite-1.6.7/src/winscard_clnt.c.noautostart pcsc-lite-1.6.7/src/winscard_clnt.c
|
||||
--- pcsc-lite-1.6.7/src/winscard_clnt.c.noautostart 2011-02-23 00:20:25.000000000 +0200
|
||||
+++ pcsc-lite-1.6.7/src/winscard_clnt.c 2011-02-25 17:17:32.201085695 +0200
|
||||
@@ -444,80 +444,16 @@ LONG SCardEstablishContext(DWORD dwScope
|
||||
LPCVOID pvReserved2, LPSCARDCONTEXT phContext)
|
||||
{
|
||||
LONG rv;
|
||||
- int daemon_launched = FALSE;
|
||||
- int retries = 0;
|
||||
|
||||
API_TRACE_IN("%ld, %p, %p", dwScope, pvReserved1, pvReserved2)
|
||||
PROFILE_START
|
||||
|
||||
-again:
|
||||
/* Check if the server is running */
|
||||
rv = SCardCheckDaemonAvailability();
|
||||
if (SCARD_E_INVALID_HANDLE == rv)
|
||||
/* we reconnected to a daemon or we got called from a forked child */
|
||||
rv = SCardCheckDaemonAvailability();
|
||||
|
||||
- if (SCARD_E_NO_SERVICE == rv)
|
||||
- {
|
||||
-launch:
|
||||
- if (daemon_launched)
|
||||
- {
|
||||
- retries++;
|
||||
- if (retries < 50) /* 50 x 100ms = 5 seconds */
|
||||
- {
|
||||
- /* give some more time to the server to start */
|
||||
- SYS_USleep(100*1000); /* 100 ms */
|
||||
- goto again;
|
||||
- }
|
||||
-
|
||||
- /* the server failed to start (in time) */
|
||||
- goto end;
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- int pid;
|
||||
-
|
||||
- pid = fork();
|
||||
-
|
||||
- if (pid < 0)
|
||||
- {
|
||||
- Log2(PCSC_LOG_CRITICAL, "fork failed: %s", strerror(errno));
|
||||
- rv = SCARD_F_INTERNAL_ERROR;
|
||||
- goto end;
|
||||
- }
|
||||
-
|
||||
- if (0 == pid)
|
||||
- {
|
||||
- int i, max;
|
||||
- char *param = getenv("PCSCLITE_PCSCD_ARGS");
|
||||
-
|
||||
- /* close all file handles except stdin, stdout and
|
||||
- * stderr so that pcscd does not confiscate ressources
|
||||
- * allocated by the application */
|
||||
- max = sysconf(_SC_OPEN_MAX);
|
||||
- if (-1 == max)
|
||||
- max = 1024;
|
||||
- for (i=3; i<max; i++)
|
||||
- (void)close(i);
|
||||
-
|
||||
- /* son process */
|
||||
- execl(PCSCD_BINARY, "pcscd", "--auto-exit", param,
|
||||
- (char *)NULL);
|
||||
- Log2(PCSC_LOG_CRITICAL, "exec " PCSCD_BINARY " failed: %s",
|
||||
- strerror(errno));
|
||||
- exit(1);
|
||||
- }
|
||||
-
|
||||
- /* father process */
|
||||
- daemon_launched = TRUE;
|
||||
-
|
||||
- if (waitpid(pid, NULL, 0) < 0)
|
||||
- Log2(PCSC_LOG_CRITICAL, "waitpid failed: %s", strerror(errno));
|
||||
-
|
||||
- goto again;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
if (rv != SCARD_S_SUCCESS)
|
||||
goto end;
|
||||
|
||||
@@ -526,15 +462,6 @@ launch:
|
||||
pvReserved2, phContext);
|
||||
(void)SCardUnlockThread();
|
||||
|
||||
- /* SCardEstablishContextTH may fail if the previous pcscd crashed
|
||||
- * without cleaning /var/run/pcscd/pcscd.comm */
|
||||
- if (SCARD_E_NO_SERVICE == rv)
|
||||
- {
|
||||
- retries++;
|
||||
- if (retries <= 1)
|
||||
- goto launch;
|
||||
- }
|
||||
-
|
||||
end:
|
||||
PROFILE_END(rv)
|
||||
API_TRACE_OUT("%ld", *phContext)
|
|
@ -2,25 +2,29 @@
|
|||
|
||||
Name: pcsc-lite
|
||||
Version: 1.7.4
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: PC/SC Lite smart card framework and applications
|
||||
|
||||
Group: System Environment/Daemons
|
||||
License: BSD
|
||||
URL: http://pcsclite.alioth.debian.org/
|
||||
Source0: http://alioth.debian.org/download.php/%{upstream_build}/%{name}-%{version}.tar.bz2
|
||||
Source1: pcscd.init
|
||||
# Disable pcscd on-demand startup (#653903)
|
||||
Patch2: %{name}-1.6.7-noautostart.patch
|
||||
# Patches for systemd support
|
||||
# http://archives.neohapsis.com/archives/dev/muscle/2011-q2/0138.html
|
||||
Patch0: 0001-Support-systemd-socket-activation.patch
|
||||
Patch1: 0002-Add-disable-autostart-option.patch
|
||||
Patch2: 0003-Install-systemd-service-files.patch
|
||||
|
||||
BuildRequires: automake libtool
|
||||
BuildRequires: libudev-devel
|
||||
BuildRequires: doxygen
|
||||
BuildRequires: graphviz
|
||||
Requires(post): initscripts
|
||||
Requires(post): /sbin/chkconfig
|
||||
Requires(preun): /sbin/chkconfig
|
||||
Requires(preun): initscripts
|
||||
Requires(postun): initscripts
|
||||
BuildRequires: systemd-units
|
||||
|
||||
Requires(post): systemd-sysv
|
||||
Requires(post): systemd-units
|
||||
Requires(preun): systemd-units
|
||||
Requires(postun): systemd-units
|
||||
Requires: pcsc-ifd-handler
|
||||
Requires: %{name}-libs = %{version}-%{release}
|
||||
|
||||
|
@ -60,7 +64,11 @@ Requires: %{name}-libs = %{version}-%{release}
|
|||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch2 -p1 -b .noautostart
|
||||
%patch0 -p2 -b .socket_activation
|
||||
%patch1 -p2 -b .noautostart
|
||||
%patch2 -p2 -b .service_files
|
||||
|
||||
autoreconf -f
|
||||
|
||||
# Convert to utf-8
|
||||
for file in ChangeLog; do
|
||||
|
@ -73,6 +81,7 @@ done
|
|||
%build
|
||||
%configure \
|
||||
--disable-static \
|
||||
--disable-autostart \
|
||||
--enable-ipcdir=%{_localstatedir}/run \
|
||||
--enable-usbdropdir=%{_libdir}/pcsc/drivers
|
||||
make %{?_smp_mflags}
|
||||
|
@ -82,8 +91,6 @@ doxygen doc/doxygen.conf ; rm -f doc/api/*.{map,md5}
|
|||
%install
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
install -Dpm 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/pcscd
|
||||
|
||||
# Create empty directories
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/reader.conf.d
|
||||
mkdir -p $RPM_BUILD_ROOT%{_libdir}/pcsc/drivers
|
||||
|
@ -95,17 +102,41 @@ rm $RPM_BUILD_ROOT%{_docdir}/pcsc-lite/README.DAEMON
|
|||
|
||||
|
||||
%post
|
||||
/sbin/chkconfig --add pcscd
|
||||
if [ $1 -eq 1 ] ; then
|
||||
# Initial installation
|
||||
/bin/systemctl enable pcscd.socket >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
%preun
|
||||
if [ $1 = 0 ] ; then
|
||||
/sbin/service pcscd stop >/dev/null 2>&1 || :
|
||||
/sbin/chkconfig --del pcscd
|
||||
if [ $1 -eq 0 ] ; then
|
||||
# Package removal, not upgrade
|
||||
/bin/systemctl --no-reload disable pcscd.service pcscd.socket >/dev/null 2>&1 || :
|
||||
/bin/systemctl stop pcscd.service pcscd.socket >/dev/null 2>&1 || :
|
||||
fi
|
||||
|
||||
%postun
|
||||
if [ "$1" -ge "1" ]; then
|
||||
/sbin/service pcscd condrestart >/dev/null 2>&1 || :
|
||||
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
|
||||
if [ $1 -ge 1 ] ; then
|
||||
# Package upgrade, not uninstall
|
||||
/bin/systemctl try-restart pcscd.service >/dev/null 2>&1 || :
|
||||
fi
|
||||
|
||||
%triggerun -- pcsc-lite < 1.7.4-2
|
||||
# Save the current service runlevel info
|
||||
# User must manually run systemd-sysv-convert --apply pcscd
|
||||
# to migrate them to systemd targets
|
||||
%{_bindir}/systemd-sysv-convert --save pcscd >/dev/null 2>&1 ||:
|
||||
|
||||
# Enable pcscd socket activation
|
||||
/bin/systemctl enable pcscd.socket >/dev/null 2>&1
|
||||
|
||||
# Run these because the SysV package being removed won't do them
|
||||
/sbin/chkconfig --del pcscd >/dev/null 2>&1 || :
|
||||
|
||||
# Restart the service if it's already running
|
||||
if /bin/systemctl is-active pcscd.service >/dev/null 2>&1 ; then
|
||||
/bin/systemctl stop pcscd.service >/dev/null 2>&1 ||:
|
||||
/bin/systemctl start pcscd.socket pcscd.service >/dev/null 2>&1 ||:
|
||||
fi
|
||||
|
||||
%post libs -p /sbin/ldconfig
|
||||
|
@ -116,7 +147,8 @@ fi
|
|||
%files
|
||||
%doc AUTHORS ChangeLog* DRIVERS HELP README SECURITY TODO
|
||||
%dir %{_sysconfdir}/reader.conf.d/
|
||||
%{_initrddir}/pcscd
|
||||
%{_unitdir}/pcscd.service
|
||||
%{_unitdir}/pcscd.socket
|
||||
%{_sbindir}/pcscd
|
||||
%dir %{_libdir}/pcsc/
|
||||
%dir %{_libdir}/pcsc/drivers/
|
||||
|
@ -137,6 +169,9 @@ fi
|
|||
|
||||
|
||||
%changelog
|
||||
* Fri Jul 15 2011 Kalev Lember <kalevlember@gmail.com> - 1.7.4-2
|
||||
- Converted initscript to systemd service file (#617330)
|
||||
|
||||
* Fri Jun 24 2011 Kalev Lember <kalev@smartlink.ee> - 1.7.4-1
|
||||
- Update to 1.7.4
|
||||
|
||||
|
|
84
pcscd.init
84
pcscd.init
|
@ -1,84 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# pcscd Starts the pcscd Daemon
|
||||
#
|
||||
# chkconfig: 2345 27 73
|
||||
# description: The PC/SC smart card daemon is a resource manager for the \
|
||||
# PC/SC lite and Musclecard frameworks. It coordinates \
|
||||
# communications with smart card readers, smart cards, and \
|
||||
# cryptographic tokens that are connected to the system.
|
||||
#
|
||||
# processname: pcscd
|
||||
# config: /etc/reader.conf
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: pcscd
|
||||
# Required-Start: $local_fs $remote_fs $syslog haldaemon
|
||||
# Required-Stop: $local_fs $remote_fs $syslog haldaemon
|
||||
# Should-Start: openct
|
||||
# Should-Stop: openct
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Daemon to access a smart card using PC/SC
|
||||
# Description: The PC/SC smart card daemon is a resource manager for the
|
||||
# PC/SC lite and Musclecard frameworks. It coordinates
|
||||
# communications with smart card readers, smart cards, and
|
||||
# cryptographic tokens that are connected to the system.
|
||||
### END INIT INFO
|
||||
#
|
||||
# Note! pcscd should be started after pcmcia, and shut down before it
|
||||
# for smooth experience with PCMCIA readers.
|
||||
|
||||
. /etc/init.d/functions
|
||||
|
||||
umask 077
|
||||
|
||||
exec=/usr/sbin/pcscd
|
||||
prog=$(basename $exec)
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
PCSCD_OPTIONS=
|
||||
|
||||
# Source config
|
||||
if [ -f /etc/sysconfig/pcscd ] ; then
|
||||
. /etc/sysconfig/pcscd
|
||||
fi
|
||||
|
||||
start() {
|
||||
echo -n $"Starting PC/SC smart card daemon ($prog): "
|
||||
daemon $prog $PCSCD_OPTIONS
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
stop() {
|
||||
echo -n $"Stopping PC/SC smart card daemon ($prog): "
|
||||
killproc $prog
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
$1
|
||||
;;
|
||||
reload|force-reload)
|
||||
restart
|
||||
;;
|
||||
status)
|
||||
status $prog
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
[ ! -f $lockfile ] || restart
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
|
||||
exit 2
|
||||
esac
|
Loading…
Reference in New Issue