1
0
mirror of https://github.com/Yubico/yubikey-ksm.git synced 2024-11-29 00:24:14 +01:00
yubikey-ksm/selftest.sh

49 lines
1.3 KiB
Bash
Raw Normal View History

2013-11-06 14:54:42 +01:00
#!/bin/bash
set -e
set -x
packages="help2man apache2 php5-mcrypt curl"
if [ "x$DB" = "xmysql" ]; then
dbuser=travis
packages="$packages php5-mysql"
mysql -u $dbuser -e 'create database ykksm;'
mysql -u $dbuser ykksm < ykksm-db.sql
dbrun="mysql -u $dbuser ykksm -e"
2013-11-06 14:57:39 +01:00
elif [ "x$DB" = "xpgsql" ]; then
2013-11-06 14:54:42 +01:00
dbuser=postgres
packages="$packages php5-pgsql"
psql -U $dbuser -c 'create database ykksm;'
psql -U $dbuser ykksm < ykksm-db.sql
dbrun="psql -U $dbuser ykksm -c"
2013-11-06 14:57:39 +01:00
else
echo "unknown DB $DB"
exit 1
2013-11-06 14:54:42 +01:00
fi
sudo apt-get update -qq
2013-11-06 15:00:47 +01:00
sudo apt-get install -qq -y $packages
2013-11-06 14:54:42 +01:00
git submodule update --init
sudo make install symlink
sudo sh -c "echo 'include_path = "/etc/yubico/ksm:/usr/share/ykksm"' > /etc/php5/conf.d/ykksm.ini"
sudo chmod a+r /usr/share/yubikey-ksm/* /etc/yubico/ksm/*
cat > config-db.php << EOF
<?php
\$dbuser = '$dbuser';
\$dbpass = '';
\$dbname = 'ykksm';
\$dbtype = '$DB';
?>
EOF
sudo mv config-db.php /etc/yubico/ksm/
$dbrun 'insert into yubikeys (publicname,internalname,aeskey) values("idkfefrdhtru","609963eae7b5","c68c9df8cbfe7d2f994cb904046c7218");'
sudo /etc/init.d/apache2 restart
curl --silent http://localhost/wsapi/decrypt?otp=idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgku | grep -q "^OK counter=0001 low=8d40 high=0f use=00" || (echo "failed OTP"; exit 1)