From 30e5983273bd9173bb0ea8e69186e9e957fd98ab Mon Sep 17 00:00:00 2001 From: jarjar Date: Fri, 2 Jun 2023 15:43:33 +0000 Subject: [PATCH] Update 'install.sh' --- install.sh | 115 ++++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/install.sh b/install.sh index 26b5f6e..954dec6 100644 --- a/install.sh +++ b/install.sh @@ -1,66 +1,71 @@ #!/bin/sh +set -e -cd ~ +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 +} -# Installer git si ce n'est pas déjà fait -command -v git >/dev/null 2>&1 || { echo >&2 "Git n'est pas installé. Installation..."; sudo apt-get install git; } +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" + ) -# Installation des packages requis -sudo apt-get update -sudo apt-get install libusb-dev autoconf libpcsclite-dev -y + for repo in "${repos[@]}" + do + git clone $repo + done +} -# Tableau des URL de dépôts à cloner -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" -) +compile_libnfc() { + cd ~/libnfc + autoreconf -is --force + ./configure + make distclean + sudo make install + cd ~ +} -# Boucle pour cloner chaque dépôt -for repo in "${repos[@]}" -do - git clone $repo -done +compile_mfoc() { + cd ~/mfoc + autoreconf -is + ./configure + make && sudo make install + cd ~ +} -echo "Tous les dépôts ont été clonés avec succès." +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 +} -# Compilation de libnfc -cd libnfc -autoreconf -is --force -./configure -make distclean -sudo make install +create_launcher() { + echo "cd /home/$USER/BadgeCloner/BadgeCloner" > ~/launcher.sh + echo "python3 server.py" >> ~/launcher.sh + chmod +x ~/launcher.sh +} -# Retourner au répertoire d'origine -cd ~ +install_lcd_drivers() { + cd ~/LCD-show + sudo chmod +x LCD35-show + sudo ./LCD35-show +} -# Compilation de mfoc -cd mfoc -autoreconf -is -./configure -make && sudo make install +main() { + cd ~ + install_packages + clone_repos + compile_libnfc + compile_mfoc + sudo ldconfig + update_autostart + create_launcher + install_lcd_drivers +} -# Retourner au répertoire d'origine -cd ~ - -sudo ldconfig - -# Commenter les trois premières lignes de /etc/xdg/lxsession/LXDE-pi/autostart -sudo sed -i '1,3s/^/@#/' /etc/xdg/lxsession/LXDE-pi/autostart - -# Ajout des lignes nécessaires à /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 - -echo "Les lignes ont été ajoutées à /etc/xdg/lxsession/LXDE-pi/autostart." - -# Créer le fichier launcher.sh -echo "cd /home/$USER/BadgeCloner/BadgeCloner" > ~/launcher.sh -echo "python3 server.py" >> ~/launcher.sh -echo "Le fichier launcher.sh a été créé." - -# Installation des drivers pour l'écran LCD -cd LCD-show -sudo chmod +x LCD35-show -sudo LCD35-show \ No newline at end of file +main "$@" \ No newline at end of file