Last active
May 7, 2020 06:25
-
-
Save avoidik/e01b4dfb61bebecd25825e22aa5f1b5b to your computer and use it in GitHub Desktop.
Build OpenSC from source with Vagrant (PR 1987) - https://github.com/OpenSC/OpenSC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# built especially for https://github.com/OpenSC/OpenSC/pull/1987 | |
# | |
# 1. tweak `usbfilter` parameter below according to your card-reader device specs | |
# 2. run `vagrant up` | |
# 3. run `vagrant ssh` | |
# 4. run `pkcs11-tool --test --login` | |
# | |
DEFAULT_BOX = 'bento/ubuntu-18.04' | |
$bootstrap = <<-SCRIPT | |
if [ -f /etc/.provision ]; then | |
if [ -d OpenSC ]; then | |
echo 'Already provisioned, updating PR locally...' | |
cd OpenSC | |
git pull origin pull/1987/head | |
else | |
echo 'Already provisioned, skipping PR update' | |
exit 0 | |
fi | |
else | |
apt-get update | |
apt-get -y upgrade | |
apt-get -y install pcscd libccid libpcsclite-dev libssl-dev libreadline-dev autoconf automake build-essential docbook-xsl xsltproc libtool pkg-config | |
apt-get -y install zlib1g-dev | |
apt-get -y install git-core | |
touch /etc/.provision | |
git clone https://github.com/OpenSC/OpenSC.git | |
cd OpenSC | |
git fetch origin pull/1987/head:pr1987 | |
git checkout pr1987 | |
fi | |
./bootstrap | |
./configure --prefix=/usr --sysconfdir=/etc/opensc | |
make | |
make install | |
sync | |
SCRIPT | |
nodes = [{ | |
:box => 'bento/ubuntu-18.04', | |
:name => 'ubuntu-test', | |
:hostname => 'ubuntu.test', | |
:ip => '192.168.33.10', | |
:envs => {'DEBIAN_FRONTEND' => 'noninteractive'}, | |
:enable_usb => true, | |
:default_share => true | |
}] | |
Vagrant.configure('2') do |config| | |
nodes.each do |node| | |
config.vm.define node[:hostname] do |nodeconfig| | |
nodeconfig.vm.box = node[:box] || DEFAULT_BOX | |
nodeconfig.vm.hostname = node[:hostname] if node[:hostname] | |
nodeconfig.vm.provider 'virtualbox' do |vb| | |
vb.name = node[:name] if node[:name] | |
vb.memory = node[:ram] || 1024 | |
vb.cpus = node[:cpu] || 1 | |
vb.customize ['modifyvm', :id, '--audio', 'none'] unless node[:audio] | |
vb.customize ['modifyvm', :id, '--usb', 'on'] if node[:enable_usb] | |
vb.customize ['modifyvm', :id, '--usbehci', 'on'] if node[:enable_usb] | |
vb.customize ['usbfilter', | |
'add', '0', | |
'--target', :id, | |
'--active', 'yes', | |
'--name', 'Gemalto USB SmartCard Reader', | |
'--vendorid', '08E6', | |
'--productid', '3437', | |
'--revision', '0201', | |
'--manufacturer', 'Gemalto', | |
'--product', 'USB SmartCard Reader', | |
'--serialnumber', '2134D76C', | |
'--remote', 'no' | |
] if node[:enable_usb] | |
end | |
nodeconfig.vm.provision 'shell', env: node[:envs], inline: $bootstrap | |
nodeconfig.vm.network 'private_network', ip: node[:ip] if node[:ip] | |
nodeconfig.vm.synced_folder '.', '/vagrant', disabled: true unless node[:default_share] | |
if node[:shares] | |
node[:shares].each do |i| | |
nodeconfig.vm.synced_folder i[:src], i[:dst] | |
end | |
end | |
end | |
end | |
end | |
# avoidik |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment