deploy.sh 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #!/bin/bash
  2. ##################################################################
  3. # #
  4. # Fichier de déploiement d'une interface Kiosk #
  5. # à partir d'une image Raspbian 10 #
  6. # #
  7. ##################################################################
  8. VERSION="master"
  9. # parser les arguments
  10. while getopts v:ckud option; do
  11. case "${option}"
  12. in
  13. v) VERSION=${OPTARG};;
  14. c) CLEAN=1;;
  15. u) UPGRADE=1;;
  16. d) DEV=1;;
  17. esac
  18. done
  19. # Variables
  20. CURENTDIR=$PWD
  21. KUSER="edkuser"
  22. PIPWD="edkuser"
  23. EDKPW="edkuser"
  24. NEWHOSTNAME=easydigitalkey
  25. GRPSADMIN="adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio,bluetooth"
  26. GRPSREST="dialout,cdrom,audio,video,games,users,input,netdev,gpio,bluetooth"
  27. INFOS=$(curl http://deploy.ioconstellation.com/infos/infos.txt)
  28. eval $INFOS
  29. GITURL=$(git config --get remote.origin.url)
  30. GITURL="${GITURL%/*}"
  31. eval "$INFOS"
  32. echo "Version = " "$VERSION"
  33. # Vérification du modèle
  34. TESTMODEL=$( cat /proc/device-tree/model | cut -c-22 )
  35. echo "$TESTMODEL"
  36. if test "$TESTMODEL" = "Raspberry Pi 3 Model A"; then
  37. MODEL="aplus"
  38. elif test "$TESTMODEL" = "Raspberry Pi 4 Model B"; then
  39. MODEL="4modelB"
  40. else
  41. MODEL="autre"
  42. fi
  43. # Nettoyage de edkuser et flaskinterface si option -c
  44. if [ $CLEAN ]; then
  45. echo "Suppression de l'utilisateur 'edkuser' et du dossier 'flaskinterface'"
  46. userdel -r -f edkuser
  47. rm -R /home/edkuser
  48. rm -r /opt/flaskinterface
  49. fi
  50. ############## PAQUETS, BIBLIOTEQUE, ETC, #####################
  51. # Mise à jour si option -u
  52. apt update
  53. if [ $UPGRADE ]; then
  54. apt upgrade -y
  55. fi
  56. # Installation des paquest utiles
  57. apt install accountsservice unclutter matchbox feh ecryptfs-utils libreoffice libreoffice-l10n-fr supervisor -y
  58. # Suppression des paquets inutiles
  59. apt remove geany geany-common -y
  60. # ######### SCRIPTS ET MODIFICATION SYSTEM (LOOK, ETC...)
  61. # Changer le hostname
  62. /bin/sed -i "s/raspberrypi/easydigitalkey/g" /etc/hostname
  63. sudo sed -i "s/raspberrypi/easydigitalkey/g" /etc/hosts
  64. # Installation des scripts utilisateurs et système
  65. cp -f ./alluserscripts/* /usr/local/sbin
  66. # Copie des fichier partagés par ts les utilisateurs
  67. cp -Rf ./usersshare/* /usr/share
  68. # Annuler la demande de confirmation des launchers bureau
  69. /bin/sed -i '/\[config\]/a quick_exec=1' /etc/xdg/libfm/libfm.conf
  70. # Passer la mémoire swap à 500M
  71. /bin/sed -i 's/SWAPSIZE=100/SWAPSIZE=500/g' /etc/dphys-swapfile
  72. ########## CRÉATION ET CONFIGURATION DES UTILISATEURS ###########
  73. # Créations des utilisateurs
  74. if ! id edkuser > /dev/null 2>&1; then
  75. echo "création de l'utilisateur edkuser"
  76. useradd -d /home/edkuser -G $GRPSREST -m -p "$(echo "$EDKPW" | openssl passwd -1 -stdin)" edkuser
  77. fi
  78. if ! id edkstf > /dev/null 2>&1; then
  79. echo "création de l'utilisateur edkstf"
  80. useradd -d /home/edkstf -G $GRPSADMIN -m -p "$(echo "$EDKSPW" | openssl passwd -1 -stdin)" edkstf
  81. fi
  82. # Modifier les droits sudoer
  83. echo "edkstf ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/020_edkstf-nopasswd
  84. echo "edkuser ALL=(ALL) NOPASSWD: /sbin/reboot,/sbin/shutdown,/usr/sbin/service,/sbin/ifconfig,/usr/sbin/rfkill,/usr/bin/anydesk" > /etc/sudoers.d/020_edkuser-nopasswd
  85. # Changer l'utilisateur "par defaut"
  86. /bin/sed -i "s/autologin-user=pi/autologin-user=edkuser/g" /etc/lightdm/lightdm.conf
  87. # Copier les fichiers/dossiers home par defaut des utilisateurs
  88. for luser in pi edkuser edkstf
  89. do
  90. cp -Rf ./"$luser"home -T /home/$luser
  91. chown -R $luser:$luser /home/$luser
  92. done
  93. # Modification des droits sur clé ssh
  94. chmod 600 /home/"$KUSER"/.ssh/rs_rsa
  95. ############ Réseau & Bluetooth ######################
  96. apt install nginx bluez-tools -y
  97. rsync -av ./reseau/nginx/ /etc/nginx/sites-available/
  98. rsync -av ./reseau/systemd/ /etc/systemd/
  99. systemctl enable systemd-networkd
  100. systemctl enable bt-agent
  101. systemctl enable bt-network
  102. systemctl start systemd-networkd
  103. systemctl start bt-agent
  104. systemctl start bt-network
  105. bt-adapter --set Discoverable 1
  106. bt-adapter --set DiscoverableTimeout 0
  107. ##################### CHROMIUM #######################
  108. #installtion de libwidevine pour lecture des drm
  109. cp ./chromium/libwidevinecdm.so /usr/lib/chromium-browser
  110. # Installation des plugins Chromium
  111. rsync -a ./chromium/policies/ /etc/chromium-browser/policies/managed/
  112. # Installation du plugin 'totemhome'
  113. rm -r /home/"$KUSER"/.config/chromium/Extensionsio/totemhome
  114. git clone -b $VERSION "$GITURL"/totemhome.git /home/"$KUSER"/.config/chromium/Extensionsio/totemhome
  115. ##################### Anydesk #######################
  116. if ! dpkg -s anydesk >/dev/null 2>&1; then
  117. apt install libpango1.0-0 libegl1-mesa -y
  118. wget https://download.anydesk.com/rpi/anydesk_5.1.1-1_armhf.deb
  119. dpkg -i anydesk_5.1.1-1_armhf.deb
  120. rm anydesk_5.1.1-1_armhf.deb
  121. echo 'ad.security.interactive_access=0' | sudo tee -a /etc/anydesk/system.conf
  122. echo 'ad.security.file_manager=false' | sudo tee -a /etc/anydesk/system.conf
  123. echo 'ad.security.clipboard.files=false' | sudo tee -a /etc/anydesk/system.conf
  124. echo 'ad.security.hear_audio=false' | sudo tee -a /etc/anydesk/system.conf
  125. sudo systemctl daemon-reload
  126. fi
  127. ##################### Flaskinterface #######################
  128. rm -r /opt/flaskinterface
  129. git clone -b "$VERSION" "$GITURL"/flaskinterface.git /opt/flaskinterface
  130. /bin/sh /opt/flaskinterface/run.sh
  131. ##################### Boot #######################
  132. cp ./boot/$MODEL/* /boot/
  133. cp -fv ./divers/splash.png /usr/share/plymouth/themes/pix/splash.png
  134. # configuration pour le développement
  135. if [ $DEV ]; then
  136. /bin/sh ./devconf.sh
  137. ln -sf /etc/nginx/sites-enabled/default /etc/nginx/sites-available/debug
  138. else
  139. rm -R /opt/flaskinterface/.git
  140. rm -R /home/"$KUSER"/.config/chromium/Extensionsio/totemhome/.git
  141. ln -sf /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default
  142. cp -f ./supervisor/interface.conf /etc/supervisor/conf.d/
  143. fi
  144. # Nettoyer le cache apt
  145. apt autoremove -y
  146. apt autoclean
  147. # Redémarage des services liés
  148. service nginx restart
  149. /usr/bin/supervisorctl reload
  150. # Fermeture et nettoyage des fichiers de déploiement
  151. cd "$CURENTDIR"/..
  152. # Reboot