#!/bin/sh set -e install_packages() { command -v git >/dev/null 2>&1 || { echo >&2 "Git n'est pas installé. Installation..."; sudo apt-get install git; } sudo apt-get update sudo apt-get install libusb-dev autoconf libpcsclite-dev -y } clone_repos() { local repos=( "https://gitea.jarodcajna.fr/jarjar/BadgeCloner.git" "https://gitea.jarodcajna.fr/jarjar/libnfc.git" "https://gitea.jarodcajna.fr/jarjar/mfoc.git" "https://gitea.jarodcajna.fr/jarjar/LCD-show.git" ) for repo in "${repos[@]}" do git clone $repo done } compile_libnfc() { cd ~/libnfc autoreconf -is --force ./configure make distclean sudo make install cd ~ } compile_mfoc() { cd ~/mfoc autoreconf -is ./configure make && sudo make install cd ~ } update_autostart() { sudo sed -i '1,3s/^/@#/' /etc/xdg/lxsession/LXDE-pi/autostart echo "@sh /home/$USER/launcher.sh &" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart echo "@chromium-browser --incognito --kiosk http://localhost:5000" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart } create_launcher() { echo "cd /home/$USER/BadgeCloner/BadgeCloner" > ~/launcher.sh echo "python3 server.py" >> ~/launcher.sh chmod +x ~/launcher.sh } install_lcd_drivers() { cd ~/LCD-show sudo chmod +x LCD35-show sudo ./LCD35-show } main() { cd ~ install_packages clone_repos compile_libnfc compile_mfoc sudo ldconfig update_autostart create_launcher install_lcd_drivers } main "$@"