forked from qo-op/G1BILLET
157 lines
6.2 KiB
Bash
Executable File
157 lines
6.2 KiB
Bash
Executable File
#!/bin/bash
|
|
################################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 0.1
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
################################################################################
|
|
# INSTALLER convert et qrencode: sudo apt install imagemagick qrencode
|
|
################################################################################
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
ME="${0##*/}"
|
|
############################################################################################################################################################
|
|
# ${MY_PATH}/G1BILLET_MAKE.sh "nu me ro test" "se cr et" 100 7sn9dKeCNEsHmqm1gMWNREke4YAWtNw8KG1YBSN8CmSh 97968583
|
|
############################################################################
|
|
|
|
SALT="$1"
|
|
SECRET="$2"
|
|
MONTANT="$3"
|
|
NOTERIB="$4"
|
|
UNIQID="$5"
|
|
STYLE="$6"
|
|
## ASTRO TW MODE
|
|
ASTRONAUTENS="$7"
|
|
EMAIL="$8"
|
|
[[ $EMAIL == "" ]] && EMAIL="________@____________"
|
|
|
|
if [[ "$SALT" == "" || "$SECRET" == "" || "$MONTANT" == "" || "$NOTERIB" == "" || "$UNIQID" == "" ]]
|
|
then
|
|
echo "ERROR MISSING PARAM"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p ${MY_PATH}/tmp/g1billet/$UNIQID
|
|
BILLETNAME=$(echo $SALT | sed 's/ /_/g')
|
|
|
|
# Prepare June logo color
|
|
case "$MONTANT" in
|
|
1)
|
|
convert "${MY_PATH}/images/g1${STYLE}.png" -fuzz 20% -fill grey -opaque '#e5912b' "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
2)
|
|
convert "${MY_PATH}/images/g1${STYLE}.png" -fuzz 20% -fill green -opaque '#e5912b' "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
5)
|
|
convert "${MY_PATH}/images/g1${STYLE}.png" -fuzz 20% -fill orange -opaque '#e5912b' "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
10)
|
|
convert "${MY_PATH}/images/g1${STYLE}.png" -fuzz 20% -fill blue -opaque '#e5912b' "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
20)
|
|
convert "${MY_PATH}/images/g1${STYLE}.png" -fuzz 20% -fill purple -opaque '#e5912b' "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
50)
|
|
convert "${MY_PATH}/images/g1${STYLE}.png" -fuzz 20% -fill red -opaque '#e5912b' "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
100)
|
|
convert "${MY_PATH}/images/g1${STYLE}.png" -fuzz 20% -fill black -opaque '#e5912b' "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
*)
|
|
cp "${MY_PATH}/images/g1${STYLE}.png" "${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png"
|
|
;;
|
|
esac
|
|
|
|
|
|
# Add ${MY_PATH}/images/logo.png (250px)
|
|
composite -compose Over -gravity SouthWest -geometry +150+50 -dissolve 70% \
|
|
"${MY_PATH}/images/logo${STYLE}.png" \
|
|
"${MY_PATH}/images/fond${STYLE}.jpg" \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg"
|
|
|
|
# xbian style (ASTROPORT/KODI) + JEU
|
|
if [[ "${STYLE}" == "xbian" || "${STYLE}" == "jeu" || "${STYLE}" == "astro" ]]
|
|
then
|
|
|
|
if [[ $ASTRONAUTENS ]]; then
|
|
## IT IS AN ASTRONAUTENS IPNS LINK
|
|
USALT=$(echo "$SALT" | jq -Rr @uri)
|
|
UPEPPER=$(echo "$SECRET" | jq -Rr @uri)
|
|
DISCO="/?salt=${USALT}&pepper=${UPEPPER}"
|
|
echo "${DISCO}" \
|
|
| gpg --symmetric --armor --batch --passphrase "$UNIQID" -o ${MY_PATH}/tmp/gpg.${BILLETNAME}.asc
|
|
|
|
# qrencode -s 6 -o "${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.TW.png" "https://ipfs.copylaradio.com/ipns/$ASTRONAUTENS"
|
|
|
|
## Add logo to QRCode
|
|
cp ${MY_PATH}/images/astrologo_nb.png -resize ${MY_PATH}/tmp/fond.png
|
|
|
|
## MAKE amzqr WITH astro:// LINK
|
|
amzqr "$(cat ${MY_PATH}/tmp/gpg.${BILLETNAME}.asc | tr -d '\n')" \
|
|
-d ${MY_PATH}/tmp \
|
|
-l H \
|
|
-p ${MY_PATH}/tmp/fond.png
|
|
|
|
## ADD PLAYER EMAIL
|
|
convert -gravity northwest -pointsize 28 -fill black -draw "text 5,5 \"$PLAYER\"" ${MY_PATH}/tmp/fond_qrcode.png ${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.TW.png
|
|
convert ${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.TW.png -resize 300 ${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.TW.png
|
|
|
|
composite -compose Over -gravity SouthWest -geometry +50+50 \
|
|
"${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.TW.png" \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg" \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg"
|
|
|
|
rm ${MY_PATH}/tmp/gpg.${BILLETNAME}.asc
|
|
|
|
fi
|
|
|
|
# ENTETE ET BAS DE BILLET
|
|
XZUID="$EMAIL"
|
|
BOTTOM="$(date) :: $(hostname) :: ♥Box ::"
|
|
|
|
else
|
|
|
|
XZUID="G1 BILLET"
|
|
BOTTOM="$(date) :: https://gchange.fr :: https://cesium.app :: $(hostname)"
|
|
|
|
fi
|
|
|
|
# G1PUB QR CODE
|
|
qrencode -s 6 -o "${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "$NOTERIB"
|
|
|
|
# AJOUT DU QRCODE SUR LE FOND DE BILLET
|
|
composite -compose Over -gravity SouthEast -geometry +35+50 \
|
|
"${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg" \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg"
|
|
|
|
# Add g1 LOGO to Billet
|
|
composite -compose Over -gravity NorthEast -geometry +50+25 -dissolve 90% \
|
|
"${MY_PATH}/tmp/g1billet/${UNIQID}/g1.png" \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg" \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg"
|
|
|
|
|
|
if [[ "$MONTANT" != "___" ]]; then
|
|
convert -font 'Liberation-Sans' \
|
|
-pointsize 40 -fill black -draw 'text 70,50 "'"$XZUID"'"' \
|
|
-pointsize 120 -fill black -draw 'text 450,250 "'"$MONTANT"'"' \
|
|
-pointsize 20 -fill black -draw 'text 380,20 "'"${NOTERIB}"'"' \
|
|
-pointsize 30 -draw 'text 50,100 "'"Identifiant: $SALT"'"' \
|
|
-pointsize 22 -fill black -draw 'text 50,130 "'"Code Secret: $SECRET"'"' \
|
|
-pointsize 25 -fill black -draw 'text 150,440 "'"$BOTTOM"'"' \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg" "${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.BILLET.jpg"
|
|
else
|
|
convert -font 'Liberation-Sans' \
|
|
-pointsize 40 -fill black -draw 'text 50,60 "'"$XZUID"'"' \
|
|
-pointsize 20 -fill black -draw 'text 380,26 "'"${NOTERIB}"'"' \
|
|
-pointsize 30 -draw 'text 50,100 "'"Secret 1: $SALT"'"' \
|
|
-pointsize 30 -fill black -draw 'text 50,130 "'"Secret 2: $SECRET"'"' \
|
|
-pointsize 25 -fill white -draw 'text 50,440 "'"$BOTTOM"'"' \
|
|
"${MY_PATH}/tmp/${BILLETNAME}.jpg" "${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.BILLET.jpg"
|
|
fi
|
|
|
|
rm -f ${MY_PATH}/tmp/${BILLETNAME}.jpg
|
|
## TODO STORE XZUID & G1PUB into ASTROPORT/IPFS, as FUTURE travelers...
|
|
exit 0
|
|
|