Ethernet workflow¶
If you have a display with ethernet connection to a production/license manager computer you can update the licensefile via a simple script. In the example below the software is already installed (yellow box) but the inspector and the license file will be copied to the target via the script.
Proposed workflow
Customer builds licensed application and provides inspector and project with secret key
Install inspector on target
Execute inspector and transfer hardware ID back to standalone linux environment
Run license generator on standalone linux which has access to project tree
Transfer the generated license back to target
Application on target detects license on the next startup
Solution¶
Running the automated_license.sh, in the same folder you should have:
lccgen - the license generator software
lccinspector - inspector built for target
projects folder - with the underlying license-manager generated projects. For example projects/LicenseDemoApp/ where the private key is located
The automated_license.sh has the following parameters
[ -p PROJECT_NAME ], the same name as you built license-manager with
[ -f FEATURES ], a comma separated list of features e.g. feature1,feature2,feature3
[ -d DUE_DATE], date on the form YYYYMMDD
[ -l LICENSE_FILE_NAME ], name of the created license file
[ -o OUTPUT_FOLDER_TARGET ], default /opt/cclicenses
[ -i IP_NUMBER_TARGET ]
Optional args are:
FEATURES (default none)
DUE_DATE (default none)
OUTPUT_FOLDER_TARGET (default /opt/cclicenses)
Example¶
Example output
./automated_license.sh -i 10.131.32.56 -p LicenseDemoApp -l new_license.lic
Found default hardware id
License written
Making output directory on target
Copying licenses to target /opt/cclicenses
Copy license to target ok
/automated_license.sh -f feature3,feature4 -d 2023-12-24 -o /opt/cclicenses/LicenseDemoApp -l testdate.lic -i 10.131.32.56 -p LicenseDemoApp
Found default hardware id
AKH8-hw7Y-lpc=
License written
Making output directory on target
Copying licenses to target /opt/cclicenses/LicenseDemoApp
Copy license testdate.lic to target ok
The automated_license.sh script¶
#!/bin/bash
# Using flags
# -p projectname
# -f features
# -d due_date
# -l license-file
# -o output_folder_target
usage() { # Function: Print a help message.
echo "Usage: $0 [ -p PROJECT_NAME ] [ -f FEATURES ] [ -d DUE_DATE] [ -l LICENSE_FILE_NAME ] [ -o OUTPUT_FOLDER_TARGET ] [ -i IP_NUMBER_TARGET ]" 1>&2
}
exit_abnorm() {
usage
echo "Aborted"
exit 1
}
# Default value?
OUTPUT_FOLDER_TARGET="/opt/cclicenses"
while getopts p:f:d:l:o:h:i: flag
do
case "${flag}" in
p) PROJECT_NAME=${OPTARG};;
f) FEATURES=${OPTARG};;
d) DUE_DATE=${OPTARG};;
l) LICENSE_NAME=${OPTARG};;
o) OUTPUT_FOLDER_TARGET=${OPTARG};;
i) IP_TARGET=${OPTARG};;
h) exit_abnorm;;
:) echo "Missing argument for flag -${OPTARG}" exit_abnorm;;
esac
done
#PROJECT_NAME="VitaLukan"
#FEATURES="feature1,feature2"
#IP_TARGET="10.131.32.56"
#DUE_DATE=20230501
#LICENSE_NAME="MyNewLicense.lic"
#OUTPUT_FOLDER_TARGET="/opt/cclicenses"
# Needed opts?
if [ -z ${IP_TARGET} ]; then
echo "Missing IP_NUMBER_TARGET"
exit_abnorm
fi
if [ -z ${PROJECT_NAME} ]; then
echo "Missing PROJECT_NAME"
exit_abnorm
fi
if [ -z ${LICENSE_NAME} ]; then
echo "Missing LICENSE_FILE_NAME"
exit_abnorm
fi
# How to remove this safely?
if [ -f "$LICENSE_NAME" ]; then
rm $LICENSE_NAME
fi
# Copy and run inspector
sshpass -p default scp -o StrictHostKeyChecking=no -r lccinspector $IP_TARGET:/opt
status=$?
if [ $status -ne 0 ]; then
echo "Failed to scp copy lccinspector to target"
echo $status
exit $status
fi
x=$(sshpass -p default ssh $IP_TARGET /opt/lccinspector | grep DEFAULT)
# Did we get a hardware id?
if grep -q "DEFAULT" <<< "$x"; then
echo "Found default hardware id"
#Put hardware id in variable
prefix=${x%%:*}
hw_id=${x:${#prefix}+1}
echo $hw_id
# Missing project folder?
if [ ! -d "projects/$PROJECT_NAME" ]; then
echo "Cannot find project folder projects/$PROJECT_NAME"
exit 2
fi
# Generate license
run_lcc="./lccgen license issue -p projects/$PROJECT_NAME -s $hw_id -o $LICENSE_NAME"
if [[ -v FEATURES ]]; then
run_lcc="$run_lcc -f $FEATURES"
fi
if [[ -v DUE_DATE ]]; then
run_lcc="$run_lcc -e $DUE_DATE"
fi
# Run license generator
${run_lcc}
# Handle if we couldn't generate licens
# Check if we have the license file?
if [ -f "$LICENSE_NAME" ]; then
# Make directory on remote target
echo "Making output directory on target"
sshpass -p default ssh $IP_TARGET mkdir -p $OUTPUT_FOLDER_TARGET
status=$?
if [ $status -ne 0 ]; then
echo "Failed to make output directory"
echo "$status"
exit $status
fi
echo "Copying licenses to target $OUTPUT_FOLDER_TARGET"
sshpass -p default scp -r $LICENSE_NAME $IP_TARGET:$OUTPUT_FOLDER_TARGET
status=$?
if [ $status -eq 0 ]; then
echo "Copy license $LICENSE_NAME to target ok"
else
echo "Copy license to target went wrong"
echo "$status"
exit $status
fi
else
echo "Could not generate license file!!"
exit 2
fi
else
echo "Failed to read hardware id. Cannot generate license"
exit 2
fi