Last active
May 5, 2019 08:29
-
-
Save nicklasfrahm/dc17ffd61ade8dcea3a83cad622ca98d to your computer and use it in GitHub Desktop.
A simple bash script to install the RFID B1 CLI tool
This file contains hidden or 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
#!/usr/bin/env bash | |
# Global variables. | |
artifactDownloadLink="https://eccel.co.uk/wp-content/downloads/rfidb1-tool.zip" | |
# Color variables. | |
default='\e[00;0m' | |
red='\e[00;31m' | |
green='\e[00;32m' | |
magenta='\e[00;35m' | |
# Color shortcuts. | |
d=${default} | |
r=${red} | |
g=${green} | |
m=${magenta} | |
# Message indicators. | |
info="${g}info:${d} " | |
error="${r}error:${d} " | |
# Check if user has sudo rights. | |
if [[ ${EUID} -ne 0 ]]; then | |
echo -e "${error}This script must be run as ${m}root${d} or with ${m}sudo${d}." | |
exit 1 | |
fi | |
# Create temporary directory. | |
echo -e "${info}Creating temporary directory: ${m}/tmp/rfidb1-tool${d}" | |
mkdir /tmp/rfidb1-tool | |
pushd /tmp/rfidb1-tool | |
# Download CLI package from hardware vendor. | |
echo -e "${info}Downloading artifact from vendor page ..." | |
curl -SL --progress-bar -o artifact.zip ${artifactDownloadLink} | |
echo -e "${info}Installing development dependencies: ${m}unzip libmcrypt-dev${d}" | |
apt-get update -y | |
apt-get install -y unzip libmcrypt-dev | |
# Unzip downloaded archive. | |
echo -e "${info}Extracting artifact ..." | |
unzip -u artifact.zip | |
# Install RFID command line interface. | |
pushd rfidb1* | |
echo -e "${info}Compiling binary: ${m}rfidb1-tool${d}" | |
make | |
echo -e "${info}Installing binary: ${m}rfidb1-tool${d}" | |
make install | |
popd | |
# Uninstall development dependencies. | |
echo -e "${info}Removing development dependencies: ${m}unzip libmcrypt-dev${d}" | |
apt-get purge -y --autoremove unzip libmcrypt-dev | |
# Clean up temporary files. | |
popd | |
rm -rf /tmp/rfidb1-tool | |
# Indicate successful installation. | |
echo -e "${info}Successfully installed dependency from source: ${m}rfidb1-tool${d}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment