Update 'install.sh'

This commit is contained in:
jarjar 2023-06-02 15:43:33 +00:00
parent 104211b810
commit 30e5983273

View File

@ -1,66 +1,71 @@
#!/bin/sh #!/bin/sh
set -e
cd ~ install_packages() {
# 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; } command -v git >/dev/null 2>&1 || { echo >&2 "Git n'est pas installé. Installation..."; sudo apt-get install git; }
# Installation des packages requis
sudo apt-get update sudo apt-get update
sudo apt-get install libusb-dev autoconf libpcsclite-dev -y sudo apt-get install libusb-dev autoconf libpcsclite-dev -y
}
# Tableau des URL de dépôts à cloner clone_repos() {
repos=( local repos=(
"https://gitea.jarodcajna.fr/jarjar/BadgeCloner.git" "https://gitea.jarodcajna.fr/jarjar/BadgeCloner.git"
"https://gitea.jarodcajna.fr/jarjar/libnfc.git" "https://gitea.jarodcajna.fr/jarjar/libnfc.git"
"https://gitea.jarodcajna.fr/jarjar/mfoc.git" "https://gitea.jarodcajna.fr/jarjar/mfoc.git"
"https://gitea.jarodcajna.fr/jarjar/LCD-show.git" "https://gitea.jarodcajna.fr/jarjar/LCD-show.git"
) )
# Boucle pour cloner chaque dépôt
for repo in "${repos[@]}" for repo in "${repos[@]}"
do do
git clone $repo git clone $repo
done done
}
echo "Tous les dépôts ont été clonés avec succès." compile_libnfc() {
cd ~/libnfc
# Compilation de libnfc
cd libnfc
autoreconf -is --force autoreconf -is --force
./configure ./configure
make distclean make distclean
sudo make install sudo make install
# Retourner au répertoire d'origine
cd ~ cd ~
}
# Compilation de mfoc compile_mfoc() {
cd mfoc cd ~/mfoc
autoreconf -is autoreconf -is
./configure ./configure
make && sudo make install make && sudo make install
# Retourner au répertoire d'origine
cd ~ cd ~
}
sudo ldconfig update_autostart() {
# Commenter les trois premières lignes de /etc/xdg/lxsession/LXDE-pi/autostart
sudo sed -i '1,3s/^/@#/' /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 "@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 "@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." create_launcher() {
# Créer le fichier launcher.sh
echo "cd /home/$USER/BadgeCloner/BadgeCloner" > ~/launcher.sh echo "cd /home/$USER/BadgeCloner/BadgeCloner" > ~/launcher.sh
echo "python3 server.py" >> ~/launcher.sh echo "python3 server.py" >> ~/launcher.sh
echo "Le fichier launcher.sh a été créé." chmod +x ~/launcher.sh
}
# Installation des drivers pour l'écran LCD install_lcd_drivers() {
cd LCD-show cd ~/LCD-show
sudo chmod +x LCD35-show sudo chmod +x LCD35-show
sudo 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 "$@"