Générateur de G1BILLETS Utilisable en ligne de commande (ou sur un site web)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

60 lines
2.1 KiB

#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
################################################################################
# Create and print 6 G1Billets de $MONTANT DU
# ${MY_PATH}/G1BILLETS.sh 5 986397643
################################################################################
MONTANT="$1"
UNIQID="$2"
STYLE="$3"
## PLANCHE DE 6 BILLETS PAR DEFAUT
NBbillets=6
[[ $MONTANT == "" ]] && MONTANT="___"
[[ $UNIQID == "" ]] && UNIQID=$(date -u +%s%N | cut -b1-13)$RANDOM
[[ "$STYLE" == "xbian" ]] && NBbillets=1 ## STYLE=xbian => 1 BILLET
[[ "$STYLE" == "1" ]] && NBbillets=1 && STYLE="" ## 1 BILLET
# CHECK IF $STYLE IMAGES EXIST
[[ ! -f ${MY_PATH}/images/fond${STYLE}.jpg ]] && exit 1
[[ ! -f ${MY_PATH}/images/g1${STYLE}.png ]] && exit 1
[[ ! -f ${MY_PATH}/images/logo${STYLE}.png ]] && exit 1
# CREATION DE $NBbillets BILLETS DE $MONTANT DU
boucle=0;
while [ $boucle -lt $NBbillets ]
do
boucle=$((boucle+1))
NUMBER=$(${MY_PATH}/diceware.sh 4 | xargs)
SECRET=$(${MY_PATH}/diceware.sh 4 | xargs)
# CREATION CLEF BILLET
BILLETPUBKEY=$(python3 ${MY_PATH}/key_create_dunikey.py "$NUMBER" "$SECRET")
rm -f /tmp/secret.dunikey
mkdir -p "/tmp/g1billet/${UNIQID}"
# CREATION FICHIER IMAGE BILLET
$(${MY_PATH}/MAKE_G1BILLET.sh "${NUMBER}" "${SECRET}" "${MONTANT}" "${BILLETPUBKEY}" "${UNIQID}" "${STYLE}")
done
# MONTAGE DES IMAGES DES BILLETS VERS /tmp/g1billet/${UNIQID}.pdf
montage /tmp/g1billet/${UNIQID}/*.jpg -tile 2x3 -geometry 964x459 /tmp/g1billet/${UNIQID}.pdf
# NB!! if "not autorized" then edit /etc/ImageMagick-6/policy.xml and comment
# <!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
# CLEANING TEMP FILES
rm -Rf /tmp/g1billet/${UNIQID}
# ALLOWS ANY USER TO DELETE
chmod 777 /tmp/g1billet/${UNIQID}.pdf
exit