Easier install & systemd setup README include "test section"

This commit is contained in:
fred 2023-03-13 15:10:01 +01:00
parent 732c741ac5
commit 4e989a4d03
7 changed files with 46 additions and 52 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.env
*.pyc
tmp/
DICE

View File

@ -22,6 +22,9 @@ if [[ $MONTANT != "daemon" ]]; then
STYLE="$2"
DICE=$(cat $MY_PATH/DICE 2>/dev/null) ## HOW MANY WORDS SECRETS
[[ $DICE != ?(-)+([0-9]) ]] && DICE=4
## CHECK IF STYLE IS EMAIL => astro IPFS G1BILLET
if [[ "${STYLE}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then
echo "ASTROPORT NEW PLAYER"
@ -30,7 +33,7 @@ STYLE="$2"
STYLE="astro"
fi
## PLANCHE PDF DE 6 BILLETS PAR DEFAUT
## STYLE SELECTED: PDF DE 6 BILLETS OR SINGLE
NBbillets=6
[[ "${STYLE}" != "" && "${STYLE}" != "solian" && "${STYLE}" != "jeu" ]] && NBbillets=1
@ -50,8 +53,9 @@ do
boucle=$((boucle+1))
mkdir -p "${MY_PATH}/tmp/g1billet/${UNIQID}"
SALT=$(${MY_PATH}/diceware.sh 4 | xargs)
SECRET=$(${MY_PATH}/diceware.sh 4 | xargs)
## ADAPT SECURITY LEVEL
SALT=$(${MY_PATH}/diceware.sh $DICE | xargs)
SECRET=$(${MY_PATH}/diceware.sh $DICE | xargs)
# CREATION CLEF BILLET
BILLETPUBKEY=$(python3 ${MY_PATH}/key_create_dunikey.py "$SALT" "$SECRET")
@ -63,6 +67,7 @@ do
rm -f ${MY_PATH}/tmp/g1billet.${UNIQID}.ipns.key
ipfs key rm ${UNIQID} && echo "/ipns/$ASTRONAUTENS"
### GRAPHISM #####
# CREATION FICHIER IMAGE BILLET dans ${MY_PATH}/tmp/g1billet/${UNIQID}
$(${MY_PATH}/MAKE_G1BILLET.sh "${SALT}" "${SECRET}" "${MONTANT}" "${BILLETPUBKEY}" "${UNIQID}" "${STYLE}" "${ASTRONAUTENS}" "${EMAIL}")
@ -181,7 +186,9 @@ function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
mkdir -p ${MY_PATH}/tmp
exec 2>&1 >> ${MY_PATH}/tmp/G1BILLETS.log
#####################################################################
########### daemon loop
#####################################################################
while true; do
echo "=================================================="
echo "$ME DAEMON READY"
@ -208,7 +215,9 @@ while true; do
MONTANT=$(urldecode ${arr[1]} | xargs); STYLE=$(urldecode ${arr[3]} | xargs);
# echo "DECODED : $ONE=$MONTANT & $TWO=$STYLE"
#####################################################################
echo ${MY_PATH}/${ME} '"'$MONTANT'"' '"'$STYLE'"'
#####################################################################
# EXECUTE COMMAND
LOG=$(${MY_PATH}/${ME} "$MONTANT" "$STYLE")
@ -261,7 +270,9 @@ else
fi
done
#####################################################################
## loop ###############################################################
#####################################################################
fi

View File

@ -63,7 +63,7 @@ esac
# Add ${MY_PATH}/images/logo.png (250px)
composite -compose Over -gravity SouthWest -geometry +50+50 -dissolve 70% "${MY_PATH}/images/logo${STYLE}.png" "${MY_PATH}/images/fond${STYLE}.jpg" "${MY_PATH}/tmp/${BILLETNAME}.jpg"
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" ]]
@ -73,19 +73,19 @@ then
## IT IS AN ASTRONAUTENS IPNS LINK
MOK="TW."
qrencode -s 6 -o "${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.TW.png" "https://ipfs.copylaradio.com/ipns/$ASTRONAUTENS"
composite -compose Over -gravity SouthWest -geometry +40+45 "${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.TW.png" "${MY_PATH}/tmp/${BILLETNAME}.jpg" "${MY_PATH}/tmp/${BILLETNAME}${MOK}.jpg"
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}${MOK}.jpg"
else
MOK=""
fi
# CREATE PSEUDO for Gchange.fr
XZUID="$EMAIL"
BOTTOM="ASTROPORT (TW) : https://astroport.copylaradio.com"
BOTTOM="$(date) :: $(hostname) :: ♥Box ::"
else
XZUID="G1 BILLET"
BOTTOM="$(date) https://gchange.fr https://cesium.app"
BOTTOM="$(date) :: https://gchange.fr :: https://cesium.app :: $(hostname)"
fi
@ -112,7 +112,7 @@ convert -font 'Liberation-Sans' \
-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 black -draw 'text 50,440 "'"$BOTTOM"'"' \
-pointsize 25 -fill white -draw 'text 50,440 "'"$BOTTOM"'"' \
"${MY_PATH}/tmp/${BILLETNAME}.jpg" "${MY_PATH}/tmp/g1billet/${UNIQID}/${BILLETNAME}.BILLET.jpg"
fi

View File

@ -65,11 +65,33 @@ cd G1BILLET
```
Ajoutez les dépendances nécessaire
Installation
```
./install.sh
./setup_systemd.sh
```
sudo apt install python3 python3-pip imagemagick qrencode ttf-mscorefonts-installer netcat-traditional
sudo pip3 install duniterpy
Test Crypto
```
./keygen 'toto' 'toto'
EA7Dsw39ShZg4SpURsrgMaMqrweJPUFPYHwZA8e92e3D
```
Test Graphic
```
SALT=toto; PEPPER=toto;
SECRET=toto; MONTANT=___;
BILLETPUBKEY=EA7Dsw39ShZg4SpURsrgMaMqrweJPUFPYHwZA8e92e3D;
UNIQID=toto; STYLE=astro
ASTRONAUTENS=k51qzi5uqu5dl1zsbaala0bi26zpl5cfi7mogjwl9cg76d8awfc1d0iv738kak
EMAIL=toto@yopmail.com
./MAKE_G1BILLET.sh "${SALT}" "${SECRET}" "${MONTANT}" "${BILLETPUBKEY}" "${UNIQID}" "${STYLE}" "${ASTRONAUTENS}" "${EMAIL}"
xdg-open tmp/g1billet/toto/toto.BILLET.jpg
```
NB: Si une erreur du type "not autorized" apparait, vous devez autoriser la création de pdf en editant /etc/ImageMagick-6/policy.xml pour commenter la ligne:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -1,40 +0,0 @@
#!/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##*/}"
echo "#############################################"
echo ">>>>>>>>>>> SYSTEMD SETUP "
echo "#############################################"
echo "CREATE SYSTEMD g1billet SERVICE >>>>>>>>>>>>>>>>>>"
cat > /tmp/g1billet.service <<EOF
[Unit]
Description=G1BILLET API
After=network.target
Requires=network.target
[Service]
Type=simple
User=_USER_
RestartSec=1
Restart=always
ExecStart=_MYPATH_/G1BILLETS.sh daemon
StandardOutput=file:_MYPATH_/tmp/g1billet.log
[Install]
WantedBy=multi-user.target
EOF
sudo cp -f /tmp/g1billet.service /etc/systemd/system/
sudo sed -i "s~_USER_~${USER}~g" /etc/systemd/system/g1billet.service
sudo sed -i "s~_MYPATH_~${MY_PATH}~g" /etc/systemd/system/g1billet.service
sudo systemctl daemon-reload
sudo systemctl enable g1billet
sudo systemctl restart g1billet