prefix=/opt/cprocsp
exec_prefix=/opt/cprocsp
#if test -r /etc/debian_version; then
#  if ! dpkg -s lsb-base > /dev/null 2>&1; then
#      echo -e "Lsb-core package is needed. Execute\n\
#      apt-get install lsb-base\nto install it."
#  fi
#fi

if test ! -d /etc/init.d/; then
	mkdir /etc/init.d
fi

if test ! -d /etc/rc.d/; then
	mkdir /etc/rc.d
fi


if test -z "#";then
    test -r /etc/debian_version && debian=1
    if test -n "$debian" && test -f /usr/sbin/update-rc.d;then
      /usr/sbin/update-rc.d cprocsp defaults
    elif test -f /usr/lib/lsb/install_initd;then
      /usr/lib/lsb/install_initd /etc/init.d/cprocsp
    elif test -f /sbin/chkconfig;then
      /sbin/chkconfig --add cprocsp
    elif test -f /usr/sbin/update-rc.d; then
      /usr/sbin/update-rc.d cprocsp defaults
    else
      for i in 2 3 4 5;do
	ln -sf /etc/init.d/cprocsp /etc/rc.d/rc$i.d/S50cprocsp
      done
      for i in 0 1 6;do
	ln -sf /etc/init.d/cprocsp /etc/rc.d/rc$i.d/K60cprocsp
      done
    fi
fi
cp /var/opt/cprocsp/tmp/cprocsp /etc/init.d/cprocsp
ln -sf /etc/init.d/cprocsp /etc/rc2.d/S25cprocsp
#cp /var/opt/cprocsp/tmp/cprocsp /etc/init.d/cprocsp
if test -z "#";then
    sysctl vfs.usermount=1
    test -c /dev/fd0 && chmod a+rw /dev/fd0
    cp /var/opt/cprocsp/tmp/cprocsp /etc/init.d/cprocsp
fi    
if test -z "#" && test -d /etc/cron.daily
then
	cat <<-END >/etc/cron.daily/cprocsp
	#!/bin/sh
	/etc/init.d/cprocsp check > /dev/null 2>&1
	 
	END
    chmod +x /etc/cron.daily/cprocsp
else
    crontab -l 2>/dev/null |fgrep -v '/etc/init.d/cprocsp' > /tmp/crontab.tmp
    echo '00 0,12 * * * /etc/init.d/cprocsp check > /dev/null 2>&1' >> /tmp/crontab.tmp
# echo '@reboot /etc/init.d/cprocsp start > /dev/null 2>&1' >> /tmp/crontab.tmp
    crontab /tmp/crontab.tmp
fi
#  FreeBSD  mac OS     
if test -z "#" || test -z "#"; then
  test ! -d /var/opt/cprocsp/keys && mkdir -p /var/opt/cprocsp/keys
  chmod 1777 /var/opt/cprocsp/keys
  chmod 1777 /var/opt/cprocsp/users
  chmod 1777 /var/opt/cprocsp/tmp
  chmod 711 /var/opt/cprocsp/mnt
fi

test_command=test
test_command=/bin/test

$test_command ! -d /usr/share/man/man8 && mkdir -p /usr/share/man/man8
$test_command ! -d /usr/share/man/ru/man8 && mkdir -p /usr/share/man/ru/man8

#  ,     ,       
$test_command ! -e /usr/share/man/man8/certmgr.8 && \
$test_command ! -h /usr/share/man/man8/certmgr.8 && \
ln -sf /opt/cprocsp/share/man/man8/certmgr.8 /usr/share/man/man8/certmgr.8

$test_command ! -e /usr/share/man/ru/man8/certmgr.8 && \
$test_command ! -h /usr/share/man/ru/man8/certmgr.8 && \
ln -sf /opt/cprocsp/share/man/man8/certmgr.ru.8 /usr/share/man/ru/man8/certmgr.8

#  ln -s  -sf,       stunnel
$test_command ! -e /usr/share/man/man8/stunnel.8 && \
$test_command ! -h /usr/share/man/man8/stunnel.8 && \
ln -s /opt/cprocsp/share/man/man8/stunnel.8 /usr/share/man/man8/stunnel.8

$test_command ! -e /usr/share/man/ru/man8/stunnel.8 && \
$test_command ! -h /usr/share/man/ru/man8/stunnel.8 && \
ln -s /opt/cprocsp/share/man/man8/stunnel.ru.8 /usr/share/man/ru/man8/stunnel.8

true

