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
doc:raspi_tools [2022/03/05 10:52] – [tmp in ram] admindoc:raspi_tools [2023/09/05 00:13] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
 +<php>  if ($_SERVER['PHP_AUTH_USER'] != 'jeff' && $_SERVER['PHP_AUTH_USER'] != 'marina' && 
 +           $_SERVER['PHP_AUTH_USER'] != 'jflemay@hotmail.com' && $_SERVER['PHP_AUTH_USER'] != 'marina.lemay@hotmail.com'
 +    die('no rights to read this page'); }  </php>
 +
 ====== Raspberry pi tools ====== ====== Raspberry pi tools ======
 x x
   * long life for SD card   * long life for SD card
-    * Disable swap : \\ cat /proc/swaps  \\ sudo swapoff --all  \\  sudo swapoff -a \\ rm /swapfile \\ rm /var/swapfile +    * Disable swap : \\ free -m \\ cat /proc/swaps  \\ sudo swapoff --all  \\  sudo swapoff -a \\ rm /swapfile \\ rm /var/swapfile 
-    * dphys-swapfile swapoff+    * __dphys-swapfile swapoff__ 
 +    * You can set this in /etc/systemd/journald.conf like so: \\ SystemMaxUse=100M
     * Assign the __noatime__ mount flag to partitions residing on the SD card by adding it to the options section of the partition in /etc/fstab.      * Assign the __noatime__ mount flag to partitions residing on the SD card by adding it to the options section of the partition in /etc/fstab. 
     * Highly used directories such as /var/tmp/ and possibly /var/log can be relocated to RAM in /etc/fstab like this: \\ tmpfs /var/tmp tmpfs nodev,nosuid,size=50M 0 0     * Highly used directories such as /var/tmp/ and possibly /var/log can be relocated to RAM in /etc/fstab like this: \\ tmpfs /var/tmp tmpfs nodev,nosuid,size=50M 0 0
Ligne 348: Ligne 353:
  
  
-===== tmp in ram =====+===== Improved (=reliable) Wait for Network =====
  
 +  systemctl enable network-wait-online.service
 +  systemctl list-dependencies --before dhcpcd
 +  systemctl list-dependencies mnt-video.mount
 + 
 +<sxh bash;  title: network-wait-online.service> 
 +#
 +# Uses 'hostname --all-fqdns' to confirm that both: IP address[es] assigned, and DNS operational
 +#
 +
 +[Unit]
 +Description=Wait for Network to be Online
 +Documentation=man:systemd.service(5) man:systemd.special(7)
 +Conflicts=shutdown.target
 +After=network.target
 +Before=network-online.target
 +
 +[Service]
 +Type=oneshot
 +ExecStart= \
 +    /bin/bash -c ' \
 +    if [ -e /etc/systemd/system/dhcpcd.service.d/wait.conf ]; \
 +    then \
 +        echo Wait for Network: enabled; \
 +        while [ -z $(hostname --all-fqdns) ]; \
 +        do \
 +            sleep 1; \
 +        done; \
 +    else \
 +        echo Wait for Network: disabled; \
 +        exit 0; \
 +    fi'
 +TimeoutStartSec=1min 30s
 +
 +[Install]
 +WantedBy=network-online.target
 +</sxh>
 +
 +
 +===== tmp in ram =====
  
   tmpfs /tmp     tmpfs defaults,noatime,nosuid,size=10m 0 0   tmpfs /tmp     tmpfs defaults,noatime,nosuid,size=10m 0 0
Ligne 550: Ligne 594:
  
   apt install ifstat   apt install ifstat
 +
 +<sxh bash;  title: ssh on nas>
 +chmod 755 /volume1/homes/backup
 +
 +ls -Al /volume1/homes/  |  grep backup
 +# drwxr-xr-x   6 backup       users  4096 Mar  5 17:04 backup
 +
 +ls -Al ~ | grep ssh
 +# drwxr-xr-x  2 backup users 4096 Mar  5 17:05 .ssh
 +
 +ls -Al ~/.ssh
 +total 16
 +-rw------- 1 backup users 1875 Mar  5 07:10 authorized_keys
 +-rw------- 1 backup users 3243 Mar  5 17:04 id_rsa
 +-rw-r----- 1 backup users  736 Mar  5 17:04 id_rsa.pub
 +
 +mcedit  /etc/ssh/sshd_config
 +# PubkeyAuthentication yes
 +# RSAAuthentication yes
 +
 +</sxh>
  
 ===== install wireguard  ===== ===== install wireguard  =====
Ligne 559: Ligne 624:
 # #### server side #### # #### server side ####
 # curl -L https://install.pivpn.io | bash # curl -L https://install.pivpn.io | bash
-sudo -u pi pivpn -a+sudo -u pi pivpn -a    # to add a new device
 sudo -u pi pivpn -l sudo -u pi pivpn -l
 #sudo -u pi pivpn -qr #sudo -u pi pivpn -qr
Ligne 580: Ligne 645:
 ping 10.6.0.1 ping 10.6.0.1
 # start at boot # start at boot
 +sudo wg-quick down wg0
 +sudo systemctl start wg-quick@wg0
 sudo systemctl enable wg-quick@wg0 sudo systemctl enable wg-quick@wg0
 </sxh> </sxh>
 +
 +<sxh bash;  title: inst_wireguard_client.bash>
 +#!/bin/bash
 +sudo apt install wireguard
 +mcedit /etc/wireguard/wg0.conf
 +</sxh>
 +
 +<sxh bash;  title: Redirection de port via 10.6.0.1>
 +ssh -L  2222:192.168.1.100:22 -N  10.6.0.1
 +ssh -p 2222 localhost
 +
 +ssh -L  44443:192.168.1.77:44443 -N  10.6.0.1
 +firefox  https://localhost:44443/
 +</sxh>
 +
  
 ===== install  letsencrypt  ===== ===== install  letsencrypt  =====
Ligne 632: Ligne 714:
 </sxh> </sxh>
  
 +
 +<sxh bash; title:send_mail.bash>
 +#!/bin/bash
 +
 +if [ -z "$1" ];  then
 +    echo "Usage :"
 +    echo "$0  \"subject\"  \"message\"  "
 +    exit 0
 +fi
 +
 +#### message ######
 +###################
 +mail_rcpt='jflemay@hotmail.com'
 +mail_sbjt="$1"
 +mail_text="$2"
 +
 +##### sender #####
 +##################
 +mail_from='marinajflemay@gmail.com'
 +mail_pass="password"
 +mail_smtp='smtps://smtp.gmail.com:465'
 +header="MIME-Version: 1.0\nContent-Transfer-Encoding: 8bit\nContent-Type: text/plain;charset=utf-8\n"
 +
 +curl --url "${mail_smtp}"  --ssl-reqd \
 +     --user "${mail_from}:${mail_pass}" \
 +     --mail-from "${mail_from}" \
 +     --mail-rcpt "${mail_rcpt}" \
 +     -T -    <<< $( echo -e "From: ${mail_from}\nTo: ${mail_rcpt}\nSubject: ${mail_sbjt}\n${header}\n\n${mail_text}" )
 +</sxh>
 ===== install server ===== ===== install server =====
  
Ligne 818: Ligne 929:
 #raspi.local:/home/share    /mnt/share       nfs  defaults 0 0 #raspi.local:/home/share    /mnt/share       nfs  defaults 0 0
 </sxh> </sxh>
 +
 +
 +<sxh bash;  title: samba_server>
 +smbpasswd -a utilisateur1
 +usermod -a -G sambashare utilisateur1
 +id utilisateur1
 +systemctl restart smbd
 +systemctl status smbd
 +</sxh>
 +
  
 ===== install wait for network ===== ===== install wait for network =====
  • doc/raspi_tools.1646473961.txt
  • Dernière modification : 2022/03/05 10:52
  • de admin