Outils pour utilisateurs

Outils du site


blog

Éditer un PDF grâce à LibreOffice Draw

Créer un fichier PDF hybride éditable

PDFimport

Manipuler des fichiers PDF avec Libre-office Draw

Sous Debian installez le paquet “libreoffice-pdfimport”

http://extensions.services.openoffice.org/project/pdfimport

Génération de PDF

libreoffice --headless --convert-to pdf --outdir plop.pdf plop.odt 2>&1
2025/03/24 15:06

E2guardian - dansguardian - Filtrer le web de site porno - Contrôle parentale

Voir :

Liste blanche

cat >> /etc/e2guardian/lists/exceptionsitelist <<EOF
e2guardian.org
www.e2guardian.org
EOF
 
systemctl restart e2guardian
2025/03/24 15:06

Dynamic hostname based on ip address - dhcp hook

- name: set dynamic hostname based on ip address - use dhcp hook
  copy: src=hostname dest=/etc/dhcp/dhclient-exit-hooks.d/hostname owner=root group=root
  when: ansible_os_family == 'Debian'

- name: set dynamic hostname based on ip address - use dhcp hook
  copy: src=hostname dest=/etc/dhcp/dhclient.d/hostname.sh owner=root group=root mode="0755"
  when: ansible_os_family == 'RedHat'
 
# Raspberry
#- name: set dynamic hostname based on ip address - use dhcp hook
#  copy: src=hostname dest=/lib/dhcpcd/dhcpcd-hooks/30-hostname owner=root group=root

hostname

#!/bin/bash
 
set_hostname() {
        local new_hostname
        local strip_simple_hostname=$(hostname -s |sed -e 's/-.*$//')
        new_hostname="$strip_simple_hostname-$(hostname -I |awk '{print $1}' |tr . -)"
        hostname "$new_hostname"
        sed -i -e "s/^127.0.1.1\\t.*/127.0.1.1\\t$new_hostname/" /etc/hosts
        # Delete duplicate lines
        perl -i -ne 'print unless $a{$_}++' /etc/hosts
}
 
if $if_up; then
        set_hostname
fi
2025/03/24 15:06

Notes Dynamic DNS DDNS avec DHCP

Hack DHCP ne veux pas faire du DDNS sous RedHat 8

/etc/dhcp/dhclient-exit-hooks.d/update-dns.sh

#! /bin/bash
 
NAME_FQDN="$(hostname -s).acme.local"
IP=$(hostname -I |tr " " "\n" |egrep "192\.168\.1\.")
#IP=$(ip a | grep wlan0 | grep "inet " | awk '{print $2}' | cut -d '/' -f 1)
 
if [ ! -z "$IP" ]
then
nsupdate -k /root/rndc.key <<EOF
update del ${NAME_FQDN} A
update add ${NAME_FQDN} 86400 A ${IP}
send
EOF
fi
chmod +x /etc/dhcp/dhclient-exit-hooks.d/update-dns.sh
Ce hack n'est pas nécessaire

Il faut avoir le paquet isc-dhcp-client d'installé avec la configuration :

/etc/dhcp/dhclient.conf

send host-name = gethostname();

Exemple nsupdate

nsupdate -k /etc/rndc.key <<EOF
update del plop.acme.local A
update add plop.acme.local 86400 A 192.168.1.4
show
send
EOF

Autres

Voir :

Vérif syntax

dhcpd -t -cf /etc/dhcp/dhcpd.conf

Rafraichir la conf

> /var/lib/dhcpd/dhcpd.leases
systemctl restart dhcpd
2025/03/24 15:06

VM disques à chaud

Voir vm_creation_fs_lvm_a_chaud

Quelques commandes bien pratiques pour prendre en compte les manipulations à chaud des disques SCSI sous Linux :

La commande suivante permet de rescanner un disque SCSI dont la taille a été modifiée à chaud dans la console Vmware. Il est alors possible d'agrandir une partition existante ou d'en créer une nouvelle sur un disque qui était plein.

# Obsolète ?
echo "1" > /sys/class/scsi_device/<device>/device/rescan

La commande suivante permet d'ajouter un disque à chaud dans une machine virtuelle. Attention, le numéro de device change en fonction de l'emplacement du disque dans la chaine (ici, le 1 indique que l'on a ajouté un deuxième disque, ce numéro sera à incrémenter en fonction du nombre de disque déjà présent)

# Obsolète ?  
#echo "scsi add-single-device" 0 0 1 0 > /proc/scsi/scsi 
#echo "scsi add-single-device" 0 0 3 0 > /proc/scsi/scsi 
 
echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan
  1. lvmdiskscan |grep sd

/dev/sda1 [ 509.84 MB]

    /dev/sda2                 [       19.50 GB] LVM physical volume
    /dev/sdb                  [       20.00 GB] LVM physical volume
    /dev/sdc                  [       20.00 GB] LVM physical volume
    /dev/sdd                  [       20.00 GB] LVM physical volume
    /dev/sde                  [       20.00 GB] LVM physical volume
  
  #echo "scsi add-single-device" 0 0 5 0 > /proc/scsi/scsi
  
  #lvmdiskscan |grep sd
    /dev/sda1                 [      509.84 MB]
    /dev/sda2                 [       19.50 GB] LVM physical volume
    /dev/sdb                  [       20.00 GB] LVM physical volume
    /dev/sdc                  [       20.00 GB] LVM physical volume
    /dev/sdd                  [       20.00 GB] LVM physical volume
    /dev/sde                  [       20.00 GB] LVM physical volume
    /dev/sdf                  [       40.00 GB]

Voir http://www.tldp.org/HOWTO/archived/SCSI-Programming-HOWTO/SCSI-Programming-HOWTO-4.html

Device Mapping

These device files are dynamically mapped to SCSI id/LUNs on your SCSI bus (LUN = logical unit). The mapping allocates devices consecutively for each LUN of each device on each SCSI bus found at time of the SCSI scan, beginning at the lower LUNs/ids/buses. It starts with the first SCSI controller and continues without interruption with all following controllers. This is currently done in the initialisation of the SCSI driver.

For example, assuming you had three SCSI devices hooked up with ids 1, 3, and 5 on the first SCSI bus (each having one LUN), then the following mapping would be in effect:

  /dev/sga -> SCSI id 1
  /dev/sgb -> SCSI id 3
  /dev/sgc -> SCSI id 5

If you now add a new device with id 4, then the mapping (after the next rescan) will be:

  /dev/sga -> SCSI id 1
  /dev/sgb -> SCSI id 3
  /dev/sgc -> SCSI id 4
  /dev/sgd -> SCSI id 5

Notice the change for id 5 -- the corresponding device is no longer mapped to /dev/sgc but is now under /dev/sgd.

Luckily newer kernels allow for changing this order.

Dynamically insert and remove SCSI devices

If a newer kernel and the /proc file system is running, a non-busy device can be removed and installed 'on the fly'.

To remove a SCSI device:

  echo "scsi remove-single-device a b c d" > /proc/scsi/scsi

and similar, to add a SCSI device, do

  echo "scsi add-single-device a b c d" > /proc/scsi/scsi

where

        a == hostadapter id (first one being 0)
        b == SCSI channel on hostadapter (first one being 0)
        c == ID
        d == LUN (first one being 0)

So in order to swap the /dev/sgc and /dev/sgd mappings from the previous example, we could do

  echo "scsi remove-single-device 0 0 4 0" > /proc/scsi/scsi
  echo "scsi remove-single-device 0 0 5 0" > /proc/scsi/scsi
  echo "scsi add-single-device 0 0 5 0" > /proc/scsi/scsi
  echo "scsi add-single-device 0 0 4 0" > /proc/scsi/scsi

since generic devices are mapped in the order of their insertion.

When adding more devices to the scsi bus keep in mind there are limited spare entries for new devices. The memory has been allocated at boot time and has room for 2 more devices.

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki