Skip to content

Simplify smart card setup script #17

@justenstall

Description

@justenstall

Moving content from an old MR:

#!/usr/bin/env bash

if [[ "$OSTYPE" == "darwin"* ]]; then
	echo "CAC does not need to be setup for macOS, exiting."
	exit 0
fi

# TODO: check for WSL system? WSL users may not need to run this script, so we could exit for them

set -e

############################################################
# Download CACKey Debian Package
############################################################

# Prep download destination
cackey_download="$HOME/Downloads/cackey_0.7.5-1_amd64.deb"
[ -e "$(dirname "$cackey_download")" ] || mkdir -p "$(dirname "$cackey_download")"
[ -e "$cackey_download" ] && rm -rf "$cackey_download"

# Download the package
(
	set -x
	curl -fsSL -o "$cackey_download" http://cackey.rkeene.org/download/0.7.5/cackey_0.7.5-1_amd64.deb
)

# Verify checksum
cackey_checksum="bfbe032d2695d27005f5efdd5cf6c19c96b21f06e52539ef249a68da877582bc2d3625ca3c670a8bfeb970d6302c9d58248443838e7f32bb197de65757c85802"
if ! echo "$cackey_checksum  $cackey_download" | sha512sum --check --status; then
	echo "Checksum verification failed! Deleting downloaded file and aborting."
	rm "$cackey_download"
	echo
	echo "Aborting"
	exit 1
fi

############################################################
# Install OpenSC, middleware, and CACKey
############################################################

# Install:
# - opensc: https://packages.ubuntu.com/jammy/opensc
# - pcscd: https://packages.ubuntu.com/jammy/pcscd
# - cackey: http://cackey.rkeene.org
sudo -- bash -c "\
	set -x;\
	apt install opensc pcscd -y;\
	apt install ./cackey_0.7.5-1_amd64.deb -y --allow-downgrades;\
	systemctl enable pcscd.socket;\
"

# Teach user how to check card reader slot
echo
echo "
Run the following command check if your card reader is recognized by the system:
  pkcs11-tool -L
"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions