Mein kleines EDV Logbuch

Kategorie: Linux Seite 1 von 5

MediaTek USB WLAN unter Debian

USB WLAN-Adapter haben unter Linux oft Probleme mit den Energieeinstellungen.

Zuerst prüfen, ob die Treiber geladen sind:

sudo lsmod | grep mt76
mt76x0u                20480  0
mt76x0_common          49152  1 mt76x0u
mt76x02_usb            24576  1 mt76x0u
mt76_usb               49152  2 mt76x02_usb,mt76x0u
mt76x02_lib           102400  3 mt76x02_usb,mt76x0_common,mt76x0u
mt76                  139264  5 mt76_usb,mt76x02_lib,mt76x02_usb,mt76x0_common,mt76x0u
mac80211             1454080  5 mt76,mt76x02_lib,mt76x02_usb,mt76x0_common,mt76x0u
cfg80211             1404928  5 mt76,mt76x02_lib,mac80211,mt76x02_usb,mt76x0_common
usbcore               409600  9 xhci_hcd,ehci_pci,mt76_usb,usb_storage,ehci_hcd,xhci_pci,mt76x02_usb,uas,mt76x0u

Passt so.
Bei meinem Adapter kam es zu folgendem Fehler:

sudo dmesg | grep mt76
[   10.554910] mt76x0u 3-10:1.0: ASIC revision: 76100002 MAC revision: 76502000
[   11.656688] mt76x0u 3-10:1.0: EEPROM ver:02 fae:04
[   11.675365] usbcore: registered new interface driver mt76x0u
[   11.707733] mt76x0u 3-10:1.0 wlx00c0cababac5: renamed from wlan0
[11268.427437] mt76x0u 3-10:1.0: timed out waiting for pending tx
[11273.106872] mt76x0u 3-10:1.0: ASIC revision: 76100002 MAC revision: 76502000
[11274.067163] mt76x0u 3-10:1.0: EEPROM ver:02 fae:04
[11274.092906] mt76x0u 3-10:1.0 wlx00c0cababac5: renamed from wlan0

Die Meldung „timed out waiting for pending tx“ ist auf das USB-Autosuspend zurückzuführen.

Zum Testen kann folgende Befehl ausgeführt werden, dann das USB-Gerät raus ziehen und neu einstecken.

sudo sh -c 'echo -1 > /sys/module/usbcore/parameters/autosuspend'

Das Setting bleibt bis zum Neustart aktiv.

Bei mir stand vorher eine 2 drin. Das bedeutet USB-Autosuspend ist aktiv und Geräte dürfen nach 2 Sekunden Inaktivität in den Energiesparmodus gehen.

Permanent kann man die Sache machen, indem man in der Grub-Konfig den entsprechenden Eintrag setzt (usbcore.autosuspend=-1):

GRUB_CMDLINE_LINUX_DEFAULT="quiet usbcore.autosuspend=-1"

Dann Grub updaten und rebooten:

sudo update-grub
sudo reboot

Debian Linux – Zeichenkodierung einstellen

dpkg-reconfigure locales

Wenn das Kommando nicht auf Anhieb funktioniert (weil die Pakete bereits installiert sind), dann folgende Pakete nachinstallieren:

apt-get install locales language-env

Ob es geklappt hat sieht man mit dem Kommando

locale

In der Ausgabe müsste nun der neue Zeichensatz hinterlegt sein.

Wenn das nicht funktioniert, bitte vor der Konfiguration der locales noch die ENV Variable LC_ALL exportieren, mit der gewünschten locale:

export LC_ALL="de_DE.UTF-8"
dpkg-reconfigure locales

Debian Linux – Mails über Terminal senden

Es gibt hierzu mehrere Methoden. Ich konzentriere mich hierbei auf die wohl gängiste Methode per mailutils.

Ubuntu LTS Update 22.04 DNS Probleme

Zuerst einmal muss ich loswerden, dass mich Ubuntu langsam richtig aufregt. Ich rate davon ab sowas als Produktivserver zu nutzen. Da gibt es meiner Meinung nach bessere Alternativen, wie Debian oder CentOS, die weitaus stabiler laufen.

PostgresSQL Superuser Passwort zurücksetzen

Der Superuser für Postgres heißt postgres. Das Passwort kann zurückgesetzt werden, indem man die Authentifizierungsmethode in der Konfigdatei ändert.

Nginx unter MotionEyeOS installieren

Nginx von Raspbian kopieren

https://wiki.satria.de/index.php?title=MotionEyeOS

Da MotionEyeOs gut gegen Schreibzugriffe gesichert ist und auch kein apt nutzt, muss man etwas kreativ werden. Glücklicherweise ist Nginx nur ein kleines Paket und kann leicht von Raspbian kopiert werden.

Folgende Dateien werden benötigt:

/etc/nginx/nginx.conf
/etc/nginx/*
/usr/lib/libpcre.so.3.13.3 plus Symlink auf /usr/lib/libpcre.so.3
/usr/sbin/nginx
/var/lib/nginx/ (Ordner muss nur angelegt werden. Berechtigung muss für www-data vergeben werden, damit nginx dort temporäre Dateien speichern kann. Mit chown www-data:root /var/lib/nginx/)
/var/log/nginx/ (Ordner muss nur angelegt werden)

Schreibzugriff auf das Dateisystem

Dateisystem:

mount -o remount,rw / 

Bootpartition:

mount -o remount,rw /boot

Nginx Konfiguration

server {
  listen 80;
  listen [::]:80;

  listen              443 ssl;
  ssl_certificate     /etc/nginx/ssl/example.crt;
  ssl_certificate_key /etc/nginx/ssl/example.key;
  ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers         HIGH:!aNULL:!MD5;

  server_name example.com;

  location / {
      proxy_pass http://localhost:8080/;
      proxy_cache off;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
  }
}

SSL Zertifikat mit OpenSSL erzeugen

Siehe OpenSSL Befehlsübersicht

Init.d Script anlegen

Das mit Raspbian gelieferte Bootscript ist zu komplex, daher nutzen wir für MotionEyeOs das folgende.

/etc/init.d/S89nginx

case "$1" in
  start)
    echo Starting nginx...
    /usr/sbin/nginx
    ;;
  stop)
    echo Terminating all nginx instances...
    killall nginx
    ;;
  *)
    echo "Usage: /etc/init.d/nginx {start|stop}"
    exit 1
    ;;
esac

exit 0

Nginx als ReverseProxy

Basiskonfiguration

server {
  listen 80;
  listen [::]:80;

  server_name example.com;

  location / {
      proxy_pass http://localhost:8080/;
  }
}

SSL

server {
    listen              443 ssl;
    server_name         www.example.com;
    ssl_certificate     www.example.com.crt;
    ssl_certificate_key www.example.com.key;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;
    ...
}

Websockets

https://www.nginx.com/blog/websocket-nginx/

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;

Linux Zeitzone ändern

Die Systemzeit wird konfiguriert, indem der Symlink /etc/localtime gegen eine Binärdatei mit dem Zeitzonen-Indentifier im Verzeichnis /usr/share/zoneinfo erzeugt wird. Also einfach auf eine andere Datei linken.

Initd startup script template

Folgendes Template nehme ich normalerweise als Vorlage für ein Initd Script. Habe das irgendwann mal so im Internet gefunden, weiß nicht mehr genau wo. Dürfte selbsterklärend sein.

#!/bin/bash
# chkconfig: 2345 20 80
# description: Description comes here....

# Source function library.
. /etc/init.d/functions

start() {
    # code to start app comes here 
    # example: daemon program_name &
}

stop() {
    # code to stop app comes here 
    # example: killproc program_name
}

case "$1" in 
    start)
       start
       ;;
    stop)
       stop
       ;;
    restart)
       stop
       start
       ;;
    status)
       # code to check status of app comes here 
       # example: status program_name
       ;;
    *)
       echo "Usage: $0 {start|stop|status|restart}"
esac

exit 0 

The format is pretty standard and you can view existing scripts in /etc/init.d. You can then use the script like so /etc/init.d/myscript start or chkconfig myscript start. The ckconfig man page explains the header of the script:

 > This says that the script should be started in levels 2,  3,  4, and
 > 5, that its start priority should be 20, and that its stop priority
 > should be 80.

The example start, stop and status code uses helper functions defined in /etc/init.d/functions

  1. Enable the script $ chkconfig --add myscript $ chkconfig --level 2345 myscript on
  2. Check the script is indeed enabled – you should see „on“ for the levels you selected. $ chkconfig --list | grep myscript

Raspi Notizen

Lichter Abschalten

sudo vi /boot/config.txt


#LinkLED 
dtparam=eth_led0=14
dtparam=eth_led1=14

#PiCam
disable_camera_led=1

Rote und Grüne LED ausschalten am Raspi

For the Raspberry Pi 3b you can add the following lines to /etc/rc.local:

sudo sh -c 'echo none > /sys/class/leds/led0/trigger'
sudo sh -c 'echo none > /sys/class/leds/led1/trigger'
sudo sh -c 'echo 0 > /sys/class/leds/led0/brightness'
sudo sh -c 'echo 0 > /sys/class/leds/led1/brightness'

Seite 1 von 5

Präsentiert von WordPress & Theme erstellt von Anders Norén