Ici, de la documentation admin sys qui a pu servir au projet tout au long de sa vie, un peu en vrac.

SSH

ssh \-L 8000:localhost:8888 user@serveur \# redirige le port distant 8888 sur le port local 8000

Bash utils

  • Commandes en vrac :
rsync \-a /path/to/source/ /path/to/destination/ \# copy source to destination with overwrite
rsync \-au /path/to/source/ /path/to/destination/ \# ... with older files only overwrite
rsync \-a \--ignore-existing /path/to/source/ /path/to/destination/ \# ... with no overwrite

openssl x509 \-noout \-text \-in /etc/ssl/cert.pem \# voir le contenu d'un certificat X.509 (HTTPS)

Docker

  • Script mettant à jour le fichier /etc/hosts avec les adresses et noms des conteneurs Docker :
#!/bin/bash
\# Depuis https://github.com/dr-co/docker-resolver/blob/master/docker-hosts.sh
 
if ! test \-z "$1"; then
    exec "$@"
fi
 
set \-e
 
MARKER\='##- container.resolver -##'
TEMPFILE\=\`tempfile\`
 
cleanup() {
   grep \-v "$MARKER" /etc/hosts \> $TEMPFILE
   cat $TEMPFILE \> /etc/hosts
   rm \-f $TEMPFILE
}
 
trap "cleanup; exit" EXIT INT TERM
 
while true; do
    grep \-v "$MARKER" /etc/hosts \> $TEMPFILE
 
    docker ps| while read line; do
        id\=\`echo $line|awk '{print $1}'\`
        name\=\`echo $line|awk '{print $NF}'\`
        ip\=\`docker inspect \-f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 2\>/dev/null $id || true\`
 
        if test \-z "$ip"; then
            continue
        fi
 
        printf  "%-15s %s %-25s $MARKER\\n" $ip    $id $name \>> $TEMPFILE
    done
 
    EXISTS\=\`md5sum /etc/hosts|awk '{print $1}'\`
    NEW\=\`md5sum $TEMPFILE|awk '{print $1}'\`
 
    if ! test $NEW = $EXISTS; then
        cat $TEMPFILE \> /etc/hosts
    fi
 
    sleep ${REFRESH\_INTERVAL-10}
done
docker compose up \--force-recreate \--build \-d

Divers

  • Maintenance MariaDB/MySQL :
ALTER DATABASE databasename CHARACTER SET utf8mb4 COLLATE utf8mb4\_unicode\_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4\_unicode\_ci;
  • Systemctl :
systemctl list-units \--failed
systemctl reset-failed
  • Pilote Wi-Fi pour Ubuntu Oracular : Broadcom BCM43xx
apt-get install broadcom-sta-dkms
modprobe wl

Services

MantisBT