maj ansible install + divers

This commit is contained in:
icon 2022-09-01 10:11:45 +04:00
parent f471d42486
commit 23524b9491
16 changed files with 445 additions and 174 deletions

9
auto_startx_bashrc Executable file
View File

@ -0,0 +1,9 @@
#! /bin/bash
if grep "#modif bashrc = ok" /home/sysop/.bashrc > /dev/null
then
echo 'bashrc déjà modifié pour auto startx !'
else
sudo echo 'export TYPE_SERVEUR_NFC=VMA405' >> /home/sysop/.bashrc
sudo echo '#modif bashrc = ok' >> /home/sysop/.bashrc
sudo echo '[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor' >> /home/sysop/.bashrc
fi

View File

@ -18,5 +18,5 @@ rm -fr /home/sysop/.config/chromium/Default/
xrandr --output DSI-1 --rotate right xrandr --output DSI-1 --rotate right
# lance chromium avec un user agent spécifique hostname,password,periph,ip (provenant en partie de .chromium_env) # lance chromium avec un user agent spécifique hostname,password,periph,ip (provenant en partie de .chromium_env)
cd /home/sysop/serveurNfcNodeJs/ cd /home/sysop/serveurNfcNodeJsVma405/
node serveur_nfc.js node serveur_nfc.js

BIN
branchement_ecran_pi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 MiB

View File

@ -0,0 +1,248 @@
---
- hosts: dsi1024x600_vma405Pi2
remote_user: sysop
become: yes
tasks:
- name: Maj dépôts
apt:
upgrade: yes
update_cache: yes
- name: install "7zip"
apt:
name: p7zip-full
state: present
- name: install git
apt:
name: git
state: present
- name: install "xserver-xorg"
apt:
name: xserver-xorg
state: present
- name: install "x11-xserver-utils"
apt:
name: x11-xserver-utils
state: present
- name: install "xinit"
apt:
name: xinit
state: present
#
- name: install "openbox"
apt:
name: openbox
state: present
- name: install "chromium-browser"
apt:
name: chromium-browser
state: present
- name: install "xdotool"
apt:
name: xdotool
state: present
- name: Copie du fichier de démarrage automatique de Xorg
copy:
src: ./auto_startx_bashrc
dest: /home/sysop/auto_startx_bashrc
owner: sysop
group: sysop
mode: '0770'
backup: yes
- name: Ajout du fichier de démarrage automatique de Xorg au fichier .bashrc
shell: /home/sysop/auto_startx_bashrc
- name: Copie du fichier autostart
copy:
src: ./autostart
dest: /home/sysop/autostart
owner: sysop
group: sysop
mode: '0770'
backup: yes
- name: Remplacer le fichier autostart
shell:
cmd: cp /home/sysop/autostart /etc/xdg/openbox/autostart
- name: Copie du fichier serveurNfcNodeJsVma405.7z
copy:
src: ./serveurNfcNodeJsVma405.7z
dest: /home/sysop/serveurNfcNodeJsVma405.7z
owner: sysop
group: sysop
backup: yes
- name: décompresser le fichier serveurNfcNodeJsVma405.7z
shell:
cmd: 7z x serveurNfcNodeJsVma405.7z
- name: Changer les droits du dossier serveurNfcNodeJsVma405
shell:
cmd: chown -R sysop:sysop /home/sysop/serveurNfcNodeJsVma405
- name: Ajout du dépot nodes js
shell: curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
- name: install "nodejs"
apt:
name: nodejs
state: present
- name: Pour nodejs, installation de "gcc" pour la compilation
apt:
name: gcc
state: present
- name: Pour nodejs, installation de "g++" pour la compilation
apt:
name: g++
state: present
- name: Pour nodejs, installation de "make" pour la compilation
apt:
name: make
state: present
- name: Pour nodejs, installation de "apt-transport-https" pour la compilation
apt:
name: apt-transport-https
state: present
- name: Installer les modules du serveurNfcNodeJsVma405
shell:
cmd: npm i
chdir: /home/sysop/serveurNfcNodeJsVma405/
- name: Création du fichier de configuration
shell: cp chromium_env.exemple .chromium_env
args:
chdir: /home/sysop/serveurNfcNodeJsVma405/
- name: Modification du hostname du fichier de configuration
shell:
cmd: sed -i "s/__hostname__/{{ hostname }}/" /home/sysop/serveurNfcNodeJsVma405/.chromium_env
- name: Modification du mot de passe du fichier de configuration
shell:
cmd: sed -i "s/__mdp__/{{ password }}/" /home/sysop/serveurNfcNodeJsVma405/.chromium_env
- name: Modification du token wifi du fichier de configuration
shell:
cmd: sed -i "s/__token__/{{ token }}/" /home/sysop/serveurNfcNodeJsVma405/.chromium_env
- name: Modification du type de front du fichier de configuration
shell:
cmd: sed -i "s/__frontType__/{{ frontType }}/" /home/sysop/serveurNfcNodeJsVma405/.chromium_env
- name: Modification du protocole(serveur) du fichier de configuration
shell:
cmd: sed -i "s/__protocole__/{{ protocole }}/" /home/sysop/serveurNfcNodeJsVma405/.chromium_env
- name: Modification de l'adresse du serveur du fichier de configuration
shell:
cmd: sed -i "s/__serveur__/{{ serveur }}/" /home/sysop/serveurNfcNodeJsVma405/.chromium_env
- name: Création du dossier repos "7inch-DSI-LCD-C"
file:
path: /home/sysop/7inch-DSI-LCD-C
state: directory
mode: '0775'
- name: Rapatrier le driver de l'écran
git:
repo: https://github.com/waveshare/7inch-DSI-LCD-C.git
dest: /home/sysop/7inch-DSI-LCD-C/
clone: yes
update: no
- name: Installer le driver
shell: /home/sysop/7inch-DSI-LCD-C/32/5.10.103/pi3/WS_7inchDSI1024x600.sh
args:
chdir: /home/sysop/7inch-DSI-LCD-C/32/5.10.103/pi3/
- name: Ajouter la rotation de 90° au fichier de configuration /boot/config.txt
shell:
cmd: echo "#90°" >> /boot/config.txt && echo "dtoverlay=WS_7inchDSI1024x600_Touch,invertedx,swappedxy" >> /boot/config.txt
- name: installe "splash screen"
apt:
name: rpd-plym-splash
state: present
- name: Installation de "fbi", pour visualiser le splash screen(logo)
apt:
name: fbi
state: present
- name: install "xserver-xorg-video-fbturbo"
apt:
name: xserver-xorg-video-fbturbo
state: present
- name: Copie du fichier image splash.png
copy:
src: ./splash.png
dest: /home/sysop/splash.png
owner: sysop
group: sysop
backup: yes
- name: Suppression du logo raspberry pi, modification du fichier /boot/cmdline.txt
shell:
cmd: echo "\nconsoleblank=0 loglevel=1 quiet logo.nologo" >> /boot/cmdline.txt
- name: Autoriser startx
shell:
cmd: sed -i "s/quiet splash plymouth.ignore-serial-consoles//" /boot/cmdline.txt
- name: Copie du fichier du service "splashscreen.service"
copy:
src: ./splashscreen.service
dest: /etc/systemd/system/splashscreen.service
owner: sysop
group: sysop
mode: '0770'
backup: yes
- name: Activer "splashscreen.service"
shell:
cmd: sudo systemctl enable splashscreen.service
- name: Démarrer "splashscreen.service"
shell:
cmd: sudo systemctl start splashscreen.service
- name: Active SPI
shell:
cmd: echo "dtparam=spi=on" >> /boot/config.txt
- name: Auto-login
shell:
cmd: raspi-config nonint do_boot_behaviour B2
- name: Changer le propriétaire et le groupe dupériphérique
shell: chown root:gpio /dev/gpiomem
- name: Configurer les droits du groupe en lecture ecriture
shell: chmod g+rw /dev/gpiomem
- name: Ajout de l'utilisateur au groupe gpio
shell: usermod -a -G gpio $USER
- name: Ajout de l'utilisateur au groupe spi
shell: usermod -a -G spi $USER
- name: Ajout de l'utilisateur au groupe netdev
shell: usermod -a -G netdev $USER
- name: Redémarrage !
reboot:

View File

@ -1,47 +0,0 @@
---
- hosts: testDsiPi
remote_user: sysop
become: yes
tasks:
- name: install "splash screen"
apt:
name: rpd-plym-splash
state: present
- name: Active SPI
shell:
cmd: echo "dtparam=spi=on" >> /boot/config.txt
- name: Ajout du dépot nodes js
shell: curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
- name: install "nodejs"
apt:
name: nodejs
state: present
- name: Pour nodejs, installation de "gcc" pour la compilation
apt:
name: gcc
state: present
- name: Pour nodejs, installation de "g++" pour la compilation
apt:
name: g++
state: present
- name: Pour nodejs, installation de "make" pour la compilation
apt:
name: make
state: present
- name: Pour nodejs, installation de "apt-transport-https" pour la compilation
apt:
name: apt-transport-https
state: present
- name: Installation des modules node js
shell:
cmd: npm i
chdir: /home/sysop/nodeJsVma405/

View File

@ -13,10 +13,10 @@
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td>39</td><td>37</td><td>35</td><td>33</td><td>31</td><td>29</td><td>27</td><td>25</td><td>SCK</td><td>MISO</td><td>MOSI</td><td>17</td><td>15</td><td>13</td><td>11</td><td>GND</td><td>7</td><td>5</td><td>3</td><td>vcc</td> <td>côté usb</td><td>39</td><td>37</td><td>35</td><td>33</td><td>31</td><td>29</td><td>27</td><td>25</td><td>SCK</td><td>MISO</td><td>MOSI</td><td>17</td><td>15</td><td>13</td><td>11</td><td>GND</td><td>7</td><td>5</td><td>3</td><td>vcc</td>
</tr> </tr>
<tr> <tr>
<td>40</td><td>38</td><td>36</td><td>34</td><td>32</td><td>30</td><td>28</td><td>26</td><td>NSS</td><td>RST</td><td>20</td><td>18</td><td>16</td><td>14</td><td>12</td><td>10</td><td>8</td><td>6</td><td>4</td><td>2</td> <td>reseau</td><td>40</td><td>38</td><td>36</td><td>34</td><td>32</td><td>30</td><td>28</td><td>26</td><td>NSS</td><td>RST</td><td>20</td><td>18</td><td>16</td><td>14</td><td>12</td><td>10</td><td>8</td><td>6</td><td>4</td><td>2</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -25,25 +25,26 @@
<table> <table>
<thead> <thead>
<tr> <tr>
<th>VMA405</th><th>PI 3 B+</th><th>Couleur cable</th> <th>RC522 / VMA405</th><th>PI 3 B+</th><th>Couleur cable</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr><td>VCC</td><td>1</td><td>marron</td></tr> <tr><td>3.3v / VCC</td><td>1</td><td>rouge</td></tr>
<tr><td>RST</td><td>22</td><td>rouge</td></tr> <tr><td>RST</td><td>22</td><td>marron</td></tr>
<tr><td>GND</td><td>9</td><td>orange</td></tr> <tr><td>GND</td><td>9</td><td>noir</td></tr>
<tr><td>IRQ</td><td>pas utilisé</td><td></td></tr>
<tr><td>MISO</td><td>21</td><td>jaune</td></tr> <tr><td>MISO</td><td>21</td><td>jaune</td></tr>
<tr><td>MOSI</td><td>19</td><td>vert</td></tr> <tr><td>MOSI</td><td>19</td><td>vert</td></tr>
<tr><td>SCK</td><td>23</td><td>bleu</td></tr> <tr><td>SCK</td><td>23</td><td>bleu</td></tr>
<tr><td>NSS</td><td>24</td><td>violet</td></tr> <tr><td>SDA</td><td>24</td><td>violet</td></tr>
<tr><td>IRQ</td><td>pas utilisé<td></td></tr> <tbody>
</tbody>
</table> </table>
# installation de node js (ansible) # installation de node js (ansible)
node.yml install_1024x600_vma405_chromium.yml
# splash screen (écran de boot = pub) # splash screen (écran de boot = pub)
``` ```

BIN
rfid_rc522.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 KiB

BIN
serveurNfcNodeJsVma405.7z Normal file

Binary file not shown.

View File

@ -1,16 +1,16 @@
#cp chromium_env.exemple .chromium_env #cp chromium_env.exemple .chromium_env
#utilisateur #utilisateur
hostname = testDsiPi hostname = __hostname__
#front #front
front_type = FPI front_type = __frontType__
#url du serveur #url du serveur
url = https://django-local.org:8501/wv/login_hardware url = __protocole__://__serveur__/wv/login_hardware
#mode_nfc = NFCMO #mode_nfc = NFCMO
mode_nfc = NFCLO mode_nfc = NFCLO
password = xxxxxxxxxxxxxxxxxxxxx password = __mdp__
token = xxxxxxxxxxxxxxxxxx token = __token__

View File

@ -7,7 +7,7 @@
// même action pour le fichier sudo nano /usr/lib/pcsc/drivers/ifd-acsccid.bundle/Contents/Info.plist (pour desktop) // même action pour le fichier sudo nano /usr/lib/pcsc/drivers/ifd-acsccid.bundle/Contents/Info.plist (pour desktop)
let script, ip, memSudoMdp = '', etatUrl = 0 let script, ip, memSudoMdp = '', etatUrl = 0
let TAB = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '!', '#', '$', '%', '&', '?','0','1','2','3','4','5','6','7','8','9']; let TAB = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '!', '#', '$', '%', '&', '?', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
let max_TAB = TAB.length - 1 let max_TAB = TAB.length - 1
let donneesFichierConfiguration = {} let donneesFichierConfiguration = {}
// type de lecteur nfc // type de lecteur nfc
@ -19,9 +19,9 @@ let dev = 1
const vma405Emitter = require('./vma405.js') const vma405Emitter = require('./vma405.js')
const os = require('os') const os = require('os')
const hostname= os.hostname() const hostname = os.hostname()
const { spawn, exec } = require('child_process') const {spawn, exec} = require('child_process')
const IP = require('ip') const IP = require('ip')
const path = require('path') const path = require('path')
const fs = require('fs') const fs = require('fs')
@ -42,7 +42,7 @@ let fichier = '', contentType = ''
* @param {String|'ipv4'|'ipv6'} famille * @param {String|'ipv4'|'ipv6'} famille
* @returns {string} * @returns {string}
*/ */
function obtenirIp(typeReseau, famille){ function obtenirIp(typeReseau, famille) {
ip = IP.address(typeReseau, famille) ip = IP.address(typeReseau, famille)
let retour = "erreur" let retour = "erreur"
if (ip !== "127.0.0.1" && ip !== "0.0.0.0") { if (ip !== "127.0.0.1" && ip !== "0.0.0.0") {
@ -53,9 +53,9 @@ function obtenirIp(typeReseau, famille){
// --- nfc --- // --- nfc ---
vma405Emitter.on('tagId', (tagId) => { vma405Emitter.on('tagId', (tagId) => {
if (retour !== null){ if (retour !== null) {
retour['tagId'] = tagId.toUpperCase() retour['tagId'] = tagId.toUpperCase()
client_globale.emit('envoieTagId',retour) client_globale.emit('envoieTagId', retour)
console.log('--> demande carte, envoi tag id = ' + tagId.toUpperCase()) console.log('--> demande carte, envoi tag id = ' + tagId.toUpperCase())
retour = null retour = null
} else { } else {
@ -72,7 +72,6 @@ vma405Emitter.on('msgVma405', (msg) => {
}) })
// --- commandes système --- // --- commandes système ---
/** @function /** @function
* Obtenir ip extérieur (wan/box) * Obtenir ip extérieur (wan/box)
@ -84,7 +83,7 @@ function obtenirIpWan() {
}) })
prog.on('close', (code) => { prog.on('close', (code) => {
if (code === 0 ){ if (code === 0) {
// ok: ip = prog.resultatRequete // ok: ip = prog.resultatRequete
} else { } else {
// erreur // erreur
@ -98,15 +97,15 @@ function obtenirIpWan() {
* @param {String} fichier - nom du fichier à lire * @param {String} fichier - nom du fichier à lire
* @returns {{msg, erreur: number}|{valeurs: {}, erreur: number}} * @returns {{msg, erreur: number}|{valeurs: {}, erreur: number}}
*/ */
function obtenirConfigurationDunFichier(rechercher,fichier) { function obtenirConfigurationDunFichier(rechercher, fichier) {
try { try {
const fic = fs.readFileSync(fichier, {encoding:'utf8', flag:'r'}).split('\n') const fic = fs.readFileSync(fichier, {encoding: 'utf8', flag: 'r'}).split('\n')
let obj = {} let obj = {}
for (let index = 0; index < fic.length; index++) { for (let index = 0; index < fic.length; index++) {
let ligne = fic[index].toString() let ligne = fic[index].toString()
if (ligne.length > 0 && ligne[0] !== '#' && ligne.indexOf('=') !== -1) { if (ligne.length > 0 && ligne[0] !== '#' && ligne.indexOf('=') !== -1) {
let tab = ligne.split('=') let tab = ligne.split('=')
for ( let im in rechercher) { for (let im in rechercher) {
mot = rechercher[im] mot = rechercher[im]
if (mot === (tab[0].trim())) { if (mot === (tab[0].trim())) {
obj[tab[0].trim()] = tab[1].trim() obj[tab[0].trim()] = tab[1].trim()
@ -116,18 +115,18 @@ function obtenirConfigurationDunFichier(rechercher,fichier) {
} }
return {erreur: 0, valeurs: obj} return {erreur: 0, valeurs: obj}
} catch (error) { } catch (error) {
return {erreur:1 , msg: error} return {erreur: 1, msg: error}
} }
} }
function afficherInfoServeur(donnees){ function afficherInfoServeur(donnees) {
// console.log('-> fonction afficherInfoServeur !') // console.log('-> fonction afficherInfoServeur !')
// console.log('donnees = ', donnees) // console.log('donnees = ', donnees)
if (donnees.erreur === 0) { if (donnees.erreur === 0) {
let bruteUrl = donnees.valeurs.url let bruteUrl = donnees.valeurs.url
let posDeuxSlashs = bruteUrl.indexOf('//') + 2 let posDeuxSlashs = bruteUrl.indexOf('//') + 2
let posFinDomaine = bruteUrl.indexOf('/wv/login_hardware') let posFinDomaine = bruteUrl.indexOf('/wv/login_hardware')
let domaine = bruteUrl.substring(posDeuxSlashs,posFinDomaine) let domaine = bruteUrl.substring(posDeuxSlashs, posFinDomaine)
let onclique = '' let onclique = ''
if (donnees.valeurs.front_type === "FPI") { if (donnees.valeurs.front_type === "FPI") {
onclique = `onclick="clavierVirtuel.obtPosition('serveur');clavierVirtuel.afficher('serveur', 'alpahMin')"` onclique = `onclick="clavierVirtuel.obtPosition('serveur');clavierVirtuel.afficher('serveur', 'alpahMin')"`
@ -136,14 +135,14 @@ function afficherInfoServeur(donnees){
let options = '' let options = ''
for (let i = 0; i < fronts.length; i++) { for (let i = 0; i < fronts.length; i++) {
let sel = '' let sel = ''
console.log(`${ i} -> ${ fronts[i] } -- ${ donnees.valeurs.front_type }`) console.log(`${i} -> ${fronts[i]} -- ${donnees.valeurs.front_type}`)
if (fronts[i] === donnees.valeurs.front_type) { if (fronts[i] === donnees.valeurs.front_type) {
sel = 'selected' sel = 'selected'
} }
options += `<option value="${ fronts[i]}" ${ sel }>${ fronts[i]}</option>` options += `<option value="${fronts[i]}" ${sel}>${fronts[i]}</option>`
} }
return ` return `
<div id="info-serveur" class="BF-ligne-deb l100p item-info" data-url-serveur="${ bruteUrl }" data-serveur="${ domaine }">Serveur: ${ domaine }</div> <div id="info-serveur" class="BF-ligne-deb l100p item-info" data-url-serveur="${bruteUrl}" data-serveur="${domaine}">Serveur: ${domaine}</div>
<div class="BF-ligne-deb l100p"> <div class="BF-ligne-deb l100p">
<div id="bt-tester-serveur" class="bt bt-250px fond-ok curseur-action"> <div id="bt-tester-serveur" class="bt bt-250px fond-ok curseur-action">
@ -161,11 +160,11 @@ function afficherInfoServeur(donnees){
<div id="modifier-serveur" class="contenu-form eff p4px fond-header l100p"> <div id="modifier-serveur" class="contenu-form eff p4px fond-header l100p">
<div class="BF-ligne-deb mb8px"> <div class="BF-ligne-deb mb8px">
<label for="serveur" class="serveur-label">Serveur</label> <label for="serveur" class="serveur-label">Serveur</label>
<input type="text" id="serveur" class="input-pour-pi" name="serveur" value="${ domaine }" ${ onclique } required> <input type="text" id="serveur" class="input-pour-pi" name="serveur" value="${domaine}" ${onclique} required>
</div> </div>
<div class="BF-ligne-deb mb8px"> <div class="BF-ligne-deb mb8px">
<label for="nom-appareil" class="mod-wifi-label">APPAREIL</label> <label for="nom-appareil" class="mod-wifi-label">APPAREIL</label>
<input type="text" id="nom-appareil" class="input-pour-pi" name="nom-appareil" value="${ os.hostname() }" disabled> <input type="text" id="nom-appareil" class="input-pour-pi" name="nom-appareil" value="${os.hostname()}" disabled>
</div> </div>
<div class="BF-ligne-deb mb8px"> <div class="BF-ligne-deb mb8px">
<label for="passe" class="mod-wifi-label">GENERER MOT DE PASSE</label> <label for="passe" class="mod-wifi-label">GENERER MOT DE PASSE</label>
@ -173,7 +172,7 @@ function afficherInfoServeur(donnees){
</div> </div>
<div class="BF-ligne-deb mb8px"> <div class="BF-ligne-deb mb8px">
<label for="type-front" class="mod-wifi-label">FRONT</label> <label for="type-front" class="mod-wifi-label">FRONT</label>
<select id="type-front" class="input-pour-pi">${ options }</select> <select id="type-front" class="input-pour-pi">${options}</select>
</div> </div>
<div class="BF-ligne"> <div class="BF-ligne">
<div id="bt-valider-modifier-serveur" class="bt bt-valider fond-ok coulBlanc curseur-action">Valider</div> <div id="bt-valider-modifier-serveur" class="bt bt-valider fond-ok coulBlanc curseur-action">Valider</div>
@ -194,7 +193,7 @@ function afficherInfoServeur(donnees){
* @param {Number} nbMaxStderr - nombre maxi d'évènement Stderr avant de sortir de la fonction * @param {Number} nbMaxStderr - nombre maxi d'évènement Stderr avant de sortir de la fonction
*/ */
function testUrl(url, nbMaxStderr) { function testUrl(url, nbMaxStderr) {
console.log(`-> fonction testUrl, url = ->${ url }<-`) console.log(`-> fonction testUrl, url = ->${url}<-`)
const prog = spawn('curl', ['-I', url]) const prog = spawn('curl', ['-I', url])
prog.nbMaxStderr = nbMaxStderr prog.nbMaxStderr = nbMaxStderr
prog.nbStderr = 0 prog.nbStderr = 0
@ -206,8 +205,8 @@ function testUrl(url, nbMaxStderr) {
}) })
prog.stderr.on('data', (data) => { prog.stderr.on('data', (data) => {
prog.nbStderr ++ prog.nbStderr++
if(prog.nbStderr === prog.nbMaxStderr) { if (prog.nbStderr === prog.nbMaxStderr) {
prog.kill() prog.kill()
} }
}) })
@ -216,7 +215,7 @@ function testUrl(url, nbMaxStderr) {
// header 307 = redirection temporaire // header 307 = redirection temporaire
// header 308 = redirection permanente // header 308 = redirection permanente
console.log('réponse test serveur = ', prog.resultatRequete) console.log('réponse test serveur = ', prog.resultatRequete)
if(prog.resultatRequete === '200' || prog.resultatRequete === '307' || prog.resultatRequete === '308') { if (prog.resultatRequete === '200' || prog.resultatRequete === '307' || prog.resultatRequete === '308') {
etatUrl = 1 etatUrl = 1
} }
client_globale.emit('etatUrlServeur', prog.resultatRequete) client_globale.emit('etatUrlServeur', prog.resultatRequete)
@ -231,8 +230,8 @@ function modifierConfigurationWifi(data) {
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1 update_config=1
network={ network={
ssid="${ data.essid }" ssid="${data.essid}"
psk="${ data.passePhrase }" psk="${data.passePhrase}"
scan_ssid=1 scan_ssid=1
} }
` `
@ -243,7 +242,7 @@ network={
msg: ` msg: `
<div class="l100p h100p BF-col"> <div class="l100p h100p BF-col">
<h1>Modification wifi effectuée,</h1> <h1>Modification wifi effectuée,</h1>
<h1>réseau = ${ data.essid }</h1> <h1>réseau = ${data.essid}</h1>
<h1>Redémmarer l'appareil ! </h1> <h1>Redémmarer l'appareil ! </h1>
</div> </div>
` `
@ -253,7 +252,7 @@ network={
erreur: 1, erreur: 1,
msg: ` msg: `
<h1>Erreur configuration wifi</h1> <h1>Erreur configuration wifi</h1>
<h2>${ erreur }</h2> <h2>${erreur}</h2>
` `
}) })
} }
@ -270,7 +269,7 @@ function afficherInfosWifi() {
let tmpData = ligne.split(':') let tmpData = ligne.split(':')
let etatWifi = 'on' let etatWifi = 'on'
let essid = '' let essid = ''
if (tmpData[1].includes('off')){ if (tmpData[1].includes('off')) {
etatWifi = 'off' etatWifi = 'off'
} else { } else {
essid = tmpData[1].trim().replace(/"/g, '') essid = tmpData[1].trim().replace(/"/g, '')
@ -295,7 +294,7 @@ function afficherInfosWifi() {
// } // }
let fragHtml = ` let fragHtml = `
<div id="info-essid" class="BF-ligne-deb item-info l100p">Ssid: ${ prog.resultat.essid }</div> <div id="info-essid" class="BF-ligne-deb item-info l100p">Ssid: ${prog.resultat.essid}</div>
<div class="BF-ligne-deb item-info l100p"> <div class="BF-ligne-deb item-info l100p">
<div id="bt-modifier-wifi" class="bt bt-250px fond-alerte curseur-action"> <div id="bt-modifier-wifi" class="bt bt-250px fond-alerte curseur-action">
<div class="md4px">Modifier Wifi</div> <div class="md4px">Modifier Wifi</div>
@ -305,11 +304,11 @@ function afficherInfosWifi() {
<div id="modifier-wifi" class="contenu-form eff p4px fond-header l100p"> <div id="modifier-wifi" class="contenu-form eff p4px fond-header l100p">
<div class="BF-ligne-deb mb8px"> <div class="BF-ligne-deb mb8px">
<label for="essid" class="mod-wifi-label">RESEAU:</label> <label for="essid" class="mod-wifi-label">RESEAU:</label>
<input type="text" id="essid" class="input-pour-pi" name="essid" ${ oncliqueEssid } required> <input type="text" id="essid" class="input-pour-pi" name="essid" ${oncliqueEssid} required>
</div> </div>
<div class="BF-ligne-deb mb8px"> <div class="BF-ligne-deb mb8px">
<label for="pp" class="mod-wifi-label">MOT DE PASSE:</label> <label for="pp" class="mod-wifi-label">MOT DE PASSE:</label>
<input type="password" id="pp" class="input-pour-pi" name="pp" ${ oncliquePasse } required> <input type="password" id="pp" class="input-pour-pi" name="pp" ${oncliquePasse} required>
</div> </div>
<div class="BF-ligne"> <div class="BF-ligne">
<div id="bt-valider-modifier-wifi" class="bt bt-valider fond-ok coulBlanc curseur-action">Valider</div> <div id="bt-valider-modifier-wifi" class="bt bt-valider fond-ok coulBlanc curseur-action">Valider</div>
@ -394,7 +393,7 @@ function lancerChromium(etape, dataFichier) {
} }
} }
function lancerApplication(){ function lancerApplication() {
console.log('-> fonction lancerApplication !') console.log('-> fonction lancerApplication !')
const dataConf = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env') const dataConf = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env')
if (dataConf.erreur === 0) { if (dataConf.erreur === 0) {
@ -434,17 +433,18 @@ function afficherFrontType() {
return 'inconnu' return 'inconnu'
} }
} }
function rnd(min, max) { function rnd(min, max) {
return Math.round(Math.random() * ((max+1) - min) + min,0); return Math.round(Math.random() * ((max + 1) - min) + min, 0);
} }
function generer_mot_de_passe(longueur) { function generer_mot_de_passe(longueur) {
let mot = ''; let mot = '';
let lettre = TAB[rnd(0,max_TAB)]; let lettre = TAB[rnd(0, max_TAB)];
for(let i=0;i<(longueur);i++){ for (let i = 0; i < (longueur); i++) {
while (mot.indexOf(lettre)!=-1) { while (mot.indexOf(lettre) != -1) {
lettre = TAB[rnd(0,59)]; lettre = TAB[rnd(0, 59)];
} }
mot += lettre; mot += lettre;
} }
@ -457,9 +457,9 @@ function modifierConfigurationServeur(data) {
// Développement serveur = "#serveur.com#", donne un protocol http et serveur = "serveur.com" // Développement serveur = "#serveur.com#", donne un protocol http et serveur = "serveur.com"
let serveur = data.serveurDomaine.toString() let serveur = data.serveurDomaine.toString()
// console.log('0 = ',serveur[0], ' -- dernier = ',serveur[(serveur.length-1)]) // console.log('0 = ',serveur[0], ' -- dernier = ',serveur[(serveur.length-1)])
if (serveur[0] === '#' && serveur[(serveur.length-1)] === '#') { if (serveur[0] === '#' && serveur[(serveur.length - 1)] === '#') {
proto = 'http' proto = 'http'
serveur = data.serveurDomaine.toString().substring(1,(serveur.length-1)) serveur = data.serveurDomaine.toString().substring(1, (serveur.length - 1))
} }
donnees = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env') donnees = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env')
@ -480,10 +480,10 @@ front_type = ${data.typeFront}
url = ${proto}://${serveur}/wv/login_hardware url = ${proto}://${serveur}/wv/login_hardware
#mode_nfc = NFCMO #mode_nfc = NFCMO
mode_nfc = ${ donnees.valeurs.mode_nfc } mode_nfc = ${donnees.valeurs.mode_nfc}
password = ${ motDePasse } password = ${motDePasse}
token = ${ donnees.valeurs.token } token = ${donnees.valeurs.token}
` `
try { try {
fs.writeFileSync(".chromium_env", template) fs.writeFileSync(".chromium_env", template)
@ -500,26 +500,78 @@ token = ${ donnees.valeurs.token }
// --- serveur http --- // --- serveur http ---
let typeMime = { let typeMime = {
"aac":"audio/aac","abw":"application/x-abiword","arc":"application/octet-stream","avi":"video/x-msvideo","azw":"application/vnd.amazon.ebook", "aac": "audio/aac",
"bin":"application/octet-stream","bz":"application/x-bzip","bz2":"application/x-bzip2","csh":"application/x-csh","css":"text/css","csv":"text/csv", "abw": "application/x-abiword",
"doc":"application/msword","docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","eot":"application/vnd.ms-fontobject", "arc": "application/octet-stream",
"epub":"application/epub+zip","gif":"image/gif","htm":"text/html","html":"text/html","ico":"image/x-icon","ics":"text/calendar","jar":"application/java-archive", "avi": "video/x-msvideo",
"jpeg":"image/jpeg","jpeg":"image/jpeg","js":"application/javascript","json":"application/json","mid":"audio/midi","midi":"audio/midi","mpeg":"video/mpeg", "azw": "application/vnd.amazon.ebook",
"mpkg":"application/vnd.apple.installer+xml","odp":"application/vnd.oasis.opendocument.presentation","ods":"application/vnd.oasis.opendocument.spreadsheet", "bin": "application/octet-stream",
"odt":"application/vnd.oasis.opendocument.text","oga":"audio/ogg","ogv":"video/ogg","ogx":"application/ogg","otf":"font/otf","png":"image/png","pdf":"application/pdf", "bz": "application/x-bzip",
"ppt":"application/vnd.ms-powerpoint","pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation","rar":"application/x-rar-compressed", "bz2": "application/x-bzip2",
"rtf":"application/rtf","sh":"application/x-sh","svg":"image/svg+xml","swf":"application/x-shockwave-flash","tar":"application/x-tar","tif":"image/tiff", "csh": "application/x-csh",
"tiff":"image/tiff","ts":"application/typescript","ttf":"font/ttf","vsd":"application/vnd.visio","wav":"audio/x-wav","weba":"audio/webm","webm":"video/webm", "css": "text/css",
"webp":"image/webp","woff":"font/woff","woff2":"font/woff2","xhtml":"application/xhtml+xml","xls":"application/vnd.ms-excel", "csv": "text/csv",
"xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","xml":"application/xml","xul":"application/vnd.mozilla.xul+xml","zip":"application/zip", "doc": "application/msword",
"3gp":"video/3gpp audio/3gpp","3g2":"video/3gpp2 audio/3gpp2", "docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"7z":"application/x-7z-compressed" "eot": "application/vnd.ms-fontobject",
"epub": "application/epub+zip",
"gif": "images/gif",
"htm": "text/html",
"html": "text/html",
"ico": "images/x-icon",
"ics": "text/calendar",
"jar": "application/java-archive",
"jpeg": "images/jpeg",
"jpeg": "images/jpeg",
"js": "application/javascript",
"json": "application/json",
"mid": "audio/midi",
"midi": "audio/midi",
"mpeg": "video/mpeg",
"mpkg": "application/vnd.apple.installer+xml",
"odp": "application/vnd.oasis.opendocument.presentation",
"ods": "application/vnd.oasis.opendocument.spreadsheet",
"odt": "application/vnd.oasis.opendocument.text",
"oga": "audio/ogg",
"ogv": "video/ogg",
"ogx": "application/ogg",
"otf": "font/otf",
"png": "images/png",
"pdf": "application/pdf",
"ppt": "application/vnd.ms-powerpoint",
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"rar": "application/x-rar-compressed",
"rtf": "application/rtf",
"sh": "application/x-sh",
"svg": "images/svg+xml",
"swf": "application/x-shockwave-flash",
"tar": "application/x-tar",
"tif": "images/tiff",
"tiff": "images/tiff",
"ts": "application/typescript",
"ttf": "font/ttf",
"vsd": "application/vnd.visio",
"wav": "audio/x-wav",
"weba": "audio/webm",
"webm": "video/webm",
"webp": "images/webp",
"woff": "font/woff",
"woff2": "font/woff2",
"xhtml": "application/xhtml+xml",
"xls": "application/vnd.ms-excel",
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"xml": "application/xml",
"xul": "application/vnd.mozilla.xul+xml",
"zip": "application/zip",
"3gp": "video/3gpp audio/3gpp",
"3g2": "video/3gpp2 audio/3gpp2",
"7z": "application/x-7z-compressed"
} }
let www = process.cwd() + '/www/' let www = process.cwd() + '/www/'
console.log('www = ', www) console.log('www = ', www)
function retour404(res){ function retour404(res) {
res.writeHead(404, {'Content-Type': 'text/html'}); res.writeHead(404, {'Content-Type': 'text/html'});
res.write('Page inconnue !'); res.write('Page inconnue !');
res.end(); res.end();
@ -528,8 +580,8 @@ function retour404(res){
function renderHtml(contenu, ctx) { function renderHtml(contenu, ctx) {
// let contenuTp1, contenuTp2, contenuTp3, contenuTp4 // let contenuTp1, contenuTp2, contenuTp3, contenuTp4
contenu = contenu.toString() contenu = contenu.toString()
let rendu = contenu.toString().replace(/{{\s*[\w\.]+\s*}}/g, function(match, token) { let rendu = contenu.toString().replace(/{{\s*[\w\.]+\s*}}/g, function (match, token) {
let clef = match.replace(/ /g,'').replace('{{','').replace('}}','') let clef = match.replace(/ /g, '').replace('{{', '').replace('}}', '')
console.log('-> match = ', match, ' -- clef = ', clef) console.log('-> match = ', match, ' -- clef = ', clef)
return ctx[clef] return ctx[clef]
}) })
@ -540,34 +592,34 @@ function renderHtml(contenu, ctx) {
// lire la conf. dans le fichier .chromium_env // lire la conf. dans le fichier .chromium_env
donneesFichierConfiguration = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env') donneesFichierConfiguration = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env')
const serveur = http.createServer(function(req, res){ const serveur = http.createServer(function (req, res) {
let url = req.url; let url = req.url;
// routes // routes
let ctx = {} let ctx = {}
if(url=='/') { if (url == '/') {
url = 'index.html' url = 'index.html'
ctx = { ctx = {
fontType: afficherFrontType(), fontType: afficherFrontType(),
nomAppareil: os.hostname(), nomAppareil: os.hostname(),
afficherInfoServeur: afficherInfoServeur(donneesFichierConfiguration), afficherInfoServeur: afficherInfoServeur(donneesFichierConfiguration),
urlServeur: donneesFichierConfiguration.url, urlServeur: donneesFichierConfiguration.url,
ip: obtenirIp('public','ipv4'), ip: obtenirIp('public', 'ipv4'),
typeLecteurNfc: typeLecteurNfc, typeLecteurNfc: typeLecteurNfc,
typeserveurNfc: 'nodejs' typeserveurNfc: 'nodejs'
} }
} }
if(url=='/favicon.ico') url = 'img/favicon2.ico' if (url == '/favicon.ico') url = 'img/favicon2.ico'
fichier = www + url.substring(0,url.length); fichier = www + url.substring(0, url.length);
//assets //assets
let posDerPoint = url.lastIndexOf('.') let posDerPoint = url.lastIndexOf('.')
let extention = '' let extention = ''
if(posDerPoint != -1){ if (posDerPoint != -1) {
extention = url.substring(posDerPoint+1,url.length); extention = url.substring(posDerPoint + 1, url.length);
if(extention.toLowerCase() == 'css') contentType = 'text/css'; if (extention.toLowerCase() == 'css') contentType = 'text/css';
contentType = typeMime[extention.toLowerCase()]; contentType = typeMime[extention.toLowerCase()];
} }
@ -582,7 +634,7 @@ const serveur = http.createServer(function(req, res){
res.writeHead(200, {"Content-Type": contentType}) res.writeHead(200, {"Content-Type": contentType})
res.write(contenuFichier) res.write(contenuFichier)
res.end(); res.end();
console.log('-> url = '+url+' -- fichier :'+fichier+' -- contentType = '+contentType+' -> chargé !'); console.log('-> url = ' + url + ' -- fichier :' + fichier + ' -- contentType = ' + contentType + ' -> chargé !');
} catch (err) { } catch (err) {
console.log('-> url = ' + url + ' -- Erreur: ' + err) console.log('-> url = ' + url + ' -- Erreur: ' + err)
retour404(res); retour404(res);
@ -598,13 +650,13 @@ const options = {
methods: ["PUT", "GET", "POST"] methods: ["PUT", "GET", "POST"]
} }
} }
const IO = require('socket.io')(serveur,options) const IO = require('socket.io')(serveur, options)
// middleware // middleware
IO.use(function(socket, next){ IO.use(function (socket, next) {
let token = socket.handshake.query.token let token = socket.handshake.query.token
// console.log('token reçu = '+token+' -- TOKEN = '+TOKEN) // console.log('token reçu = '+token+' -- TOKEN = '+TOKEN)
if (token === TOKEN){ if (token === TOKEN) {
return next() return next()
} else { } else {
next(new Error("ERREUR d'autentification !")) next(new Error("ERREUR d'autentification !"))
@ -615,7 +667,7 @@ IO.on('connection', client => {
client_globale = client; client_globale = client;
client_globale.on('demandeTagId', (data) => { client_globale.on('demandeTagId', (data) => {
retour = data; retour = data;
console.log('-> demandeTagIdg = '+JSON.stringify(retour)) console.log('-> demandeTagIdg = ' + JSON.stringify(retour))
}) })
client_globale.on('AnnuleDemandeTagId', () => { client_globale.on('AnnuleDemandeTagId', () => {
@ -636,7 +688,7 @@ IO.on('connection', client => {
client_globale.on('testerUrlServeur', (urlATester) => { client_globale.on('testerUrlServeur', (urlATester) => {
console.log('-> test url serveur = ',urlATester) console.log('-> test url serveur = ', urlATester)
testUrl(urlATester, 12) testUrl(urlATester, 12)
}) })
@ -656,4 +708,4 @@ serveur.listen(PORT, ADR, () => {
}) })
const dataConf = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env') const dataConf = obtenirConfigurationDunFichier(['hostname', 'token', 'password', 'front_type', 'url', 'mode_nfc'], './.chromium_env')
lancerChromium(1,dataConf) lancerChromium(1, dataConf)

View File

@ -1,7 +1,6 @@
// si problême de droit // si problême de droit
// sudo chown root:gpio /dev/gpiomem // sudo chown root:gpio /dev/gpiomem
// sudo chmod g+rw /dev/gpiomem // sudo chmod g+rw /dev/gpiomem
// sudo chmod g+rw /dev/gpiomem
// sudo usermod -a -G gpio $USER // sudo usermod -a -G gpio $USER
// sudo usermod -a -G spi $USER // sudo usermod -a -G spi $USER
// sudo usermod -a -G netdev $USER // sudo usermod -a -G netdev $USER

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -10,7 +10,7 @@
<header class="l100p fond-header"> <header class="l100p fond-header">
<nav class="navbar-horizontal"> <nav class="navbar-horizontal">
<div class="navbar-img BF-col curseur-action" onclick="window.location.reload();"> <div class="navbar-img BF-col curseur-action" onclick="window.location.reload();">
<img alt="TiBillet" src="images/logo_115x46.png"/> <img alt="TiBillet" src="images/logo.png"/>
</div> </div>
<div class="navbar-nom BF-ligne"> <div class="navbar-nom BF-ligne">
<h1>{{ nomAppareil }}</h1> <h1>{{ nomAppareil }}</h1>

10
splashscreen.service Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Splash screen
DefaultDependencies=no
After=local-fs.target
[Service]
ExecStart=/usr/bin/fbi -d /dev/fb0 --noverbose -a /home/sysop/splash.png
StandardInput=tty
StandardOutput=tty
[Install]
WantedBy=sysinit.target

Binary file not shown.

Before

Width:  |  Height:  |  Size: 592 KiB

After

Width:  |  Height:  |  Size: 796 KiB

View File

@ -1,7 +1,6 @@
// si problême de droit // si problême de droit
// sudo chown root:gpio /dev/gpiomem // sudo chown root:gpio /dev/gpiomem
// sudo chmod g+rw /dev/gpiomem // sudo chmod g+rw /dev/gpiomem
// sudo chmod g+rw /dev/gpiomem
// sudo usermod -a -G gpio $USER // sudo usermod -a -G gpio $USER
// sudo usermod -a -G spi $USER // sudo usermod -a -G spi $USER
// sudo usermod -a -G netdev $USER // sudo usermod -a -G netdev $USER