floss:config_ubuntu_server_rpi3

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
floss:config_ubuntu_server_rpi3 [2020/08/03 23:44] – [Compléments d'installation du serveur] villersdfloss:config_ubuntu_server_rpi3 [2024/01/23 02:53] (Version actuelle) villersd
Ligne 7: Ligne 7:
   * [[https://www.raspberrypi.org/documentation/installation/installing-images/README.md|Installing operating system images]] (cf. balenaEtcher, a graphical SD card writing tool)   * [[https://www.raspberrypi.org/documentation/installation/installing-images/README.md|Installing operating system images]] (cf. balenaEtcher, a graphical SD card writing tool)
   * [[https://ubuntu.com/download/raspberry-pi|Ubuntu Server on a Raspberry Pi 2, 3 or 4]]   * [[https://ubuntu.com/download/raspberry-pi|Ubuntu Server on a Raspberry Pi 2, 3 or 4]]
 +    * janvier 2024 : The simplest way is to use the [[https://www.raspberrypi.com/software/|Raspberry Pi Imager]] which enables you to select an Ubuntu image when flashing your SD card.  If you are on Ubuntu, run: <code>sudo snap install rpi-imager</code>
 +      * [[https://ubuntu.com/tutorials/how-to-install-ubuntu-on-your-raspberry-pi|How to install Ubuntu Server on your Raspberry Pi]]
     * [[https://ubuntu.com/server/docs/installation|Documentation Ubuntu]]     * [[https://ubuntu.com/server/docs/installation|Documentation Ubuntu]]
     * [[https://pimylifeup.com/ubuntu-server-raspberry-pi/|Installing Ubuntu Server to the Raspberry Pi]], en particulier, "Setting up SSH for Ubuntu Server", si ce n'est pas fonctionnel par défaut     * [[https://pimylifeup.com/ubuntu-server-raspberry-pi/|Installing Ubuntu Server to the Raspberry Pi]], en particulier, "Setting up SSH for Ubuntu Server", si ce n'est pas fonctionnel par défaut
     * [[https://linoxide.com/linux-how-to/configure-keyboard-ubuntu/]] config clavier     * [[https://linoxide.com/linux-how-to/configure-keyboard-ubuntu/]] config clavier
     * [[:intra:ubuntu-Rpi-server]] (credentials)     * [[:intra:ubuntu-Rpi-server]] (credentials)
 +    * liens adaptés pour Ubuntu 22.04.3 : 
 +      * [[https://cdimage.ubuntu.com/releases/22.04.3/release/ubuntu-22.04.3-preinstalled-server-arm64+raspi.img.xz]]
  
 ===== Installation ===== ===== Installation =====
Ligne 87: Ligne 91:
   * Paquets additionnels (options) :   * Paquets additionnels (options) :
     * **sudo apt-get install unison** (FIXME : compatibilité avec 18.04)     * **sudo apt-get install unison** (FIXME : compatibilité avec 18.04)
 +
 +==== Ajustement de la timezone ====
 +  * réf : [[https://vitux.com/how-to-change-the-timezone-on-your-ubuntu-system/|How to Change the Timezone on your Ubuntu System]]
 +  * ls -l /etc/localtime
 +  * timedatectl
 +  * sudo unlink /etc/localtime
 +  * sudo ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime
 +  * ls -l /etc/localtime
 +  * timedatectl
  
 ==== Installation type sur un serveur LA(M)P : DokuWiki ===== ==== Installation type sur un serveur LA(M)P : DokuWiki =====
Ligne 124: Ligne 137:
   * Mentionner dans ce dernier cas l’expéditeur des notifications par courriel du wiki (paramètres avancés)   * Mentionner dans ce dernier cas l’expéditeur des notifications par courriel du wiki (paramètres avancés)
  
 +===== Exploitation =====
 +  * mises à jour :
 +    * sudo apt-get update
 +    * sudo apt-get upgrade
 +    * sudo apt-get dist-upgrade
 +  * [[https://www.howtoraspberry.com/2020/04/disable-ipv6-on-raspberry-pi/|How to Really Disable IPv6 on Raspberry PI – How to Raspberry]]] → désactiver IPv6 en cas de trafic visible
 +
 +
 +
 +==== Dispositif USB externe ====
 +  * [[https://gist.github.com/etes/aa76a6e9c80579872e5f]]
 +  * [[https://www.raspberrypi-spy.co.uk/2014/05/how-to-mount-a-usb-flash-disk-on-the-raspberry-pi/]] (OK)
 +  * une clé USB insérée dans un PC → ligne finale de /etc/mtab :
 +    * /dev/sdg1 /media/username/USB\040DISK vfat rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro 0 0
 +    * la commande "ls -l /dev/disk/by-uuid/" donne : lrwxrwxrwx 1 root root 10 mar 15 10:54 0133-98D2 -> ../../sdg1
 +  * La même clé USB dans le Raspberry, permettant de détecter la chaîne "UUID" **0133-98D2** : 
 +    * la commande "ls -l /dev/disk/by-uuid/" donne (à la deuxième ligne) : lrwxrwxrwx 1 root root 10 mars  15 10:17 0133-98D2 -> ../../sda1
 +  * création du point de montage :
 +    * sudo mkdir /media/usb
 +  * propriétaire et droits (ajuster l'utilisateur "pi" si utile) :
 +    * sudo chown -R pi:pi /media/usb
 +  * test du montage et démontage en mode manuel (ajuster l'utilisateur "pi" si utile) :
 +    * sudo mount /dev/sda1 /media/usb -o uid=pi,gid=pi
 +    * cd /media/usb
 +    * ls
 +    * sudo umount /media/usb
 +  * montage récurrent : ajouter une ligne à la fin du fichier /etc/fstab (ajuster l'utilisateur "pi" si utile) :
 +    * sudo nano /etc/fstab
 +    * UUID=0133-98D2 /media/usb vfat auto,nofail,noatime,users,rw,uid=pi,gid=pi 0 0
 +  * redémarrer : sudo reboot
 +
 +==== Script de sauvegarde et automatisation via crontab ====
 +
 +=== Script de sauvegarde ===
 +  * → ajuster l'utilisateur "pi" si utile (ubuntu,...)
 +  * Backup sur l'utilisateur pi, (crontab -e) : 25 4 * * * /home/pi/backups/backup.sh
 +  * Le script bash backup.sh doit être exécutable. Après sa création, il faudra exécuter "chmod +x backup.sh"
 +  * doc :
 +    * [[https://doc.ubuntu-fr.org/cron]]
 +    * [[https://linux-sys-adm.com/how-to-create-script-for-backup-and-use-crontab-on-ubuntu-server-14.04-lts-step-by-step/]]
 +    * [[https://guide.ubuntu-fr.org/server/backup-shellscripts.html]]
 +  * Création d'un lien symbolique :
 +    * ln -s /media/usb/sauvegardes ~/sauvegardes
 +
 +<code backup.sh>
 +#!/bin/bash
 +THESITE="wiki01"
 +THEDB="dbname"
 +THEDBUSER="dbuser"
 +THEDBPW="dbpwd"
 +THEDATE=`date +%F-%T`
 +# backup de la base de données NON UTILISÉ
 +#mysqldump -u $THEDBUSER -p${THEDBPW} $THEDB | gzip > ~/${THESITE}backups/files/dbbackup_${THEDB}_${THEDATE}.bak.gz
 +# backup des fichiers du site
 +#tar -czf ~/${THESITE}backups/files/sitebackup_${THESITE}_${THEDATE}.tar.gz /var/www/html/${THESITE}
 +tar -czf /media/usb/sauvegardes/sitebackup_${THESITE}_${THEDATE}.tar.gz /var/www/html/${THESITE}
 +# éliminer les fichier vieux de plus de 5 jours
 +find ~/backups/files/site* -mtime +5 -exec rm {} \;
 +find ~/backups/files/db* -mtime +5 -exec rm {} \;
 +</code>
 +
 +Version après élimination d'erreurs, et sans effacement :
 +
 +<code backup.sh>
 +#!/bin/sh
 +THESITE="wiki01"
 +THEDATE=`date +%F-%H%M%S`
 +# backup des fichiers du site
 +tar -czf /media/usb/sauvegardes/sitebackup_${THESITE}_${THEDATE}.tar.gz /var/www/html/${THESITE}
 +</code>
 +
 +Test du backup :
 +<code>
 +./backup.sh
 +</code>
 +
 +Part of bash (version >=4.2) script to remove files in a given directory, older than 8 days, but leave files dated the first day of each month :
 +
 +<code>
 +# Set the directory to clean up
 +DIR="~/backups/files/"
 +
 +# Calculate the cutoff date
 +CUTOFF=$(date -d "8 days ago" +%s)
 +
 +# Loop through the files in the directory
 +for FILE in "$DIR"/*
 +do
 +  # Check if the file is older than 8 days
 +  if [[ -f "$FILE" && $(date -r "$FILE" +%s) -lt $CUTOFF ]]
 +  then
 +    # Check if the file's date is the first day of the month
 +    if [[ $(date -r "$FILE" +%d) -eq 01 ]]
 +    then
 +      echo "Skipping $FILE"
 +    else
 +      echo "Deleting $FILE"
 +      rm "$FILE"
 +    fi
 +  fi
 +done
 +
 +</code>
 +
 +Here's how the script works:
 +  - Set the DIR variable to the directory you want to clean up.
 +  - Use the date command to calculate the cutoff date. This will be 8 days ago from today.
 +  - Loop through each file in the directory using a for loop.
 +  - Check if the file is a regular file (-f) and if its modification time is older than the cutoff date. If it is not, then skip to the next file.
 +  - If the file's modification time is older than the cutoff date, check if the file's date is the first day of the month. If it is, then skip to the next file.
 +  - If the file's date is not the first day of the month, then delete the file using the rm command.
 +
 +Références sur les formats de date :
 +  * [[https://www.shell-tips.com/linux/how-to-format-date-and-time-in-linux-macos-and-bash/#gsc.tab=0|How To Format Date and Time in Linux, macOS, and Bash?]]
 +  * [[https://www.cyberciti.biz/faq/linux-unix-formatting-dates-for-display/|How To Format Date For Display or Use In a Shell Script - nixCraft]]
 +  * [[https://stackoverflow.com/questions/1401482/yyyy-mm-dd-format-date-in-shell-script|bash - YYYY-MM-DD format date in shell script - Stack Overflow]]
 +  * [[https://phoenixnap.com/kb/linux-date-command|Date Command in Linux: How to Set, Change, Format and Display Date]]
 +
 +Références sur les scripts de backup
 +  * [[https://iq.opengenus.org/automated-backup-in-linux-using-shell-scripting-and-crontab-scheduler/|Automated Backup in Linux using Shell Scripting and Crontab Scheduler]]
 +  * [[https://medium.com/@fotios.floros/linux-backup-script-1722cc9c2bf6|Linux Backup Script. This tutorial explains how to create a… | by Fotios Floros | Medium]]
 +  * [[https://github.com/gzachos/backup-script/blob/master/backup.sh|backup-script/backup.sh at master · gzachos/backup-script · GitHub]]
 +  * [[https://stackoverflow.com/questions/73658439/how-can-write-bash-script-to-get-backup|linux - how can write bash script to get backup - Stack Overflow]]
 +  * [[https://unix.stackexchange.com/questions/347822/simple-bash-script-for-backing-up-and-deleting-directories|linux - Simple bash script for backing up and deleting directories - Unix & Linux Stack Exchange]]
 +
 +
 +==== Configuration de base du DokuWiki ====
 +  * Extensions et gestion système
 +    * upgrade plugin
  
  
  • floss/config_ubuntu_server_rpi3.1596491063.txt.gz
  • Dernière modification : 2020/08/03 23:44
  • de villersd