Let’s Encrypt a chyba Segmentation fault

Po nějakém čase mi přestalo fungovat vystavování certifikátů v operačním systému Debian (viz můj dřívější příspěvek), když se mi po spuštění letsencrypt-auto začala zobrazovat tato chyba:

Updating letsencrypt and virtual environment dependencies...Segmentation fault

Vše se mi postupně povedlo rozchodit, pojďme si nyní ukázat jak.

Identifikace problému

Nejdříve bylo potřeba zjistit co přesně ve skriptu způsobuje problém. V souboru letsencrypt-auto jsem tak změnil:

#!/bin/sh -e

Na:

#!/bin/sh -xe

Problém s pip

Po znovuspuštění letsencrypt-auto jsem tedy zjistil, že to skončí u příkazu pip:

./letsencrypt-auto
+ XDG_DATA_HOME=/root/.local/share
+ VENV_NAME=letsencrypt
+ VENV_PATH=/root/.local/share/letsencrypt
+ VENV_BIN=/root/.local/share/letsencrypt/bin
+ dirname ./letsencrypt-auto
+ LEA_PATH=.
+ BOOTSTRAP=./bootstrap
+ id -u
+ test 0 -ne 0
+ SUDO=
+ [ ! -d /root/.local/share/letsencrypt ]
+ DeterminePythonVersion
+ command -v python2.7
+ export LE_PYTHON=python2.7
+ python2.7 --version
+ cut -d  -f 2
+ sed s/\.//
+ cut -d. -f1,2
+ PYVER=27
+ [ 27 -eq 26 ]
+ [ 27 -lt 26 ]
+ printf Updating letsencrypt and virtual environment dependencies...
Updating letsencrypt and virtual environment dependencies...+ [  = 1 ]
+ /root/.local/share/letsencrypt/bin/pip install -U setuptools
Segmentation fault

Špatně uvedené cesty

Z nějakého důvodu tedy jsou u příkazů pip špatně uvedeny cesty, proto jsem v souboru letsencrypt-auto změnil kód:

if [ "$VERBOSE" = 1 ]  ; then
  echo
  $VENV_BIN/pip install -U setuptools
  $VENV_BIN/pip install -U pip
  $VENV_BIN/pip install -U letsencrypt letsencrypt-apache
  # nginx is buggy / disabled for now, but upgrade it if the user has
  # installed it manually
  if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
    $VENV_BIN/pip install -U letsencrypt letsencrypt-nginx
  fi
else
  $VENV_BIN/pip install -U setuptools > /dev/null
  printf .
  $VENV_BIN/pip install -U pip > /dev/null
  printf .
  # nginx is buggy / disabled for now...
  $VENV_BIN/pip install -U letsencrypt > /dev/null
  printf .
  $VENV_BIN/pip install -U letsencrypt-apache > /dev/null
  if $VENV_BIN/pip freeze | grep -q letsencrypt-nginx ; then
    printf .
    $VENV_BIN/pip install -U letsencrypt-nginx > /dev/null
  fi
  echo
fi

# Explain what's about to happen, for the benefit of those getting sudo
# password prompts...
echo "Requesting root privileges to run with virtualenv:" $SUDO $VENV_BIN/letsencrypt "$@"
$SUDO $VENV_BIN/letsencrypt "$@"

Na:

if [ "$VERBOSE" = 1 ]  ; then
  echo
  pip install -U setuptools
  pip install -U pip
  pip install -U letsencrypt letsencrypt-apache
  # nginx is buggy / disabled for now, but upgrade it if the user has
  # installed it manually
  if pip freeze | grep -q letsencrypt-nginx ; then
    pip install -U letsencrypt letsencrypt-nginx
  fi
else
  pip install -U setuptools > /dev/null
  printf .
  pip install -U pip > /dev/null
  printf .
  # nginx is buggy / disabled for now...
  pip install -U letsencrypt > /dev/null
  printf .
  pip install -U letsencrypt-apache > /dev/null
  if pip freeze | grep -q letsencrypt-nginx ; then
    printf .
    pip install -U letsencrypt-nginx > /dev/null
  fi
  echo
fi

# Explain what's about to happen, for the benefit of those getting sudo
# password prompts...
echo "Requesting root privileges to run with virtualenv:" $SUDO letsencrypt "$@"
$SUDO letsencrypt "$@"

V podstatě jsem tedy ve skriptu jen odstranil proměnnou $VENV_BIN.

python-dialog

Po této úpravě mi to ale stále nefungovalo a odkazovalo mě to na letsencrypt.log, kde to zobrazovalo chybu:

Traceback (most recent call last):
  File "/usr/local/bin/letsencrypt", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/letsencrypt/cli.py", line 1366, in main
    setup_logging(args, _cli_log_handler, logfile='letsencrypt.log')
  File "/usr/local/lib/python2.7/dist-packages/letsencrypt/cli.py", line 1280, in setup_logging
    cli_handler = cli_handler_factory(args, level, fmt)
  File "/usr/local/lib/python2.7/dist-packages/letsencrypt/cli.py", line 1267, in _cli_log_handler
    handler = log.DialogHandler()
  File "/usr/local/lib/python2.7/dist-packages/letsencrypt/log.py", line 29, in __init__
    self.d = dialog.Dialog() if d is None else d
  File "/usr/local/lib/python2.7/dist-packages/dialog.py", line 1013, in __init__
    self._dialog_prg = _path_to_executable(dialog)
  File "/usr/local/lib/python2.7/dist-packages/dialog.py", line 477, in _path_to_executable
    "can't find the executable for the dialog-like "
ExecutableNotFound

Tady už jen stačilo doinstalovat python-dialog:

aptitude install python-dialog

Publikováno 16.1.2016 v 11:53 | Kategorie: Letsencrypt

Jak v Debianu přes terminál editovat ID3 tagy

Pokud chcete u .mp3 souborů editovat/změnit ID3 tag přímo ve vašem terminále, tak si ukážeme jak toho jednoduše docílit.

ID3v1

První verzi ID3 lze editovat přes program id3tool:

aptitude install id3tool

V manuálu programu samozřejmě nalezneme jak přesně program používat, ale ukažme si alespoň názorný příklad:

id3tool -t "Bohemian Rhapsody" -a "Queen" -r "Greatest Hits" -y "1981" -c 1 01.mp3
id3tool -t "Another One Bites The Dust" -a "Queen" -r "Greatest Hits" -y "1981" -c 2 02.mp3
id3tool -t "Killer Queen" -a "Queen" -r "Greatest Hits" -y "1981" -c 3 03.mp3
id3tool -t "Fat Bottomed Girls" -a "Queen" -r "Greatest Hits" -y "1981" -c 4 04.mp3
id3tool -t "Bicycle Race" -a "Queen" -r "Greatest Hits" -y "1981"-c 5 05.mp3
id3tool -t "You're My Best Friend" -a "Queen" -r "Greatest Hits" -y "1981" -c 6 06.mp3
id3tool -t "Don't Stop Me Now" -a "Queen" -r "Greatest Hits" -y "1981" -c 7 07.mp3
id3tool -t "Save Me" -a "Queen" -r "Greatest Hits" -y "1981" -c 8 08.mp3
id3tool -t "Crazy Little Thing Called Love" -a "Queen" -r "Greatest Hits" -y "1981" -c 9 09.mp3
id3tool -t "Somebody To Love" -a "Queen" -r "Greatest Hits" -y "1981" -c 10 10.mp3
id3tool -t "Now I'm Here" -a "Queen" -r "Greatest Hits" -y "1981" -c 11 11.mp3
id3tool -t "Good Old Fashioned Lover Boy" -a "Queen" -r "Greatest Hits" -y "1981" -c 12 12.mp3
id3tool -t "Play The Game" -a "Queen" -r "Greatest Hits"-y "1981" -c 13 13.mp3
id3tool -t "Flash" -a "Queen" -r "Greatest Hits"-y "1981" -c 14 14.mp3
id3tool -t "Seven Seas Of Rhye" -a "Queen" -r "Greatest Hits"-y "1981" -c 15 15.mp3
id3tool -t "We Will Rock You" -a "Queen" -r "Greatest Hits"-y "1981" -c 16 16.mp3
id3tool -t "We Are The Champions" -a "Queen" -r "Greatest Hits"-y "1981" -c 17 17.mp3

ID3v2

Druhou verzi ID3 lze editovat přes program id3v2:

aptitude install id3v2

V manuálu programu samozřejmě nalezneme jak přesně program používat, ale ukažme si alespoň názorný příklad:

id3v2 -t "Bohemian Rhapsody" -a "Queen" -A "Greatest Hits" -y "1981" -T 1 01.mp3
id3v2 -t "Another One Bites The Dust" -a "Queen" -A "Greatest Hits" -y "1981" -T 2 02.mp3
id3v2 -t "Killer Queen" -a "Queen" -A "Greatest Hits" -y "1981" -T 3 03.mp3
id3v2 -t "Fat Bottomed Girls" -a "Queen" -A "Greatest Hits" -y "1981" -T 4 04.mp3
id3v2 -t "Bicycle Race" -a "Queen" -A "Greatest Hits" -y "1981" -T 5 05.mp3
id3v2 -t "You're My Best Friend" -a "Queen" -A "Greatest Hits" -y "1981" -T 6 06.mp3
id3v2 -t "Don't Stop Me Now" -a "Queen" -A "Greatest Hits" -y "1981" -T 7 07.mp3
id3v2 -t "Save Me" -a "Queen" -A "Greatest Hits" -y "1981" -T 8 08.mp3
id3v2 -t "Crazy Little Thing Called Love" -a "Queen" -A "Greatest Hits" -y "1981" -T 9 09.mp3
id3v2 -t "Somebody To Love" -a "Queen" -A "Greatest Hits" -y "1981" -T 10 10.mp3
id3v2 -t "Now I'm Here" -a "Queen" -A "Greatest Hits" -y "1981" -T 11 11.mp3
id3v2 -t "Good Old Fashioned Lover Boy" -a "Queen" -A "Greatest Hits" -y "1981" -T 12 12.mp3
id3v2 -t "Play The Game" -a "Queen" -A "Greatest Hits"-y "1981" -T 13 13.mp3
id3v2 -t "Flash" -a "Queen" -A "Greatest Hits"-y "1981" -T 14 14.mp3
id3v2 -t "Seven Seas Of Rhye" -a "Queen" -A "Greatest Hits"-y "1981" -T 15 15.mp3
id3v2 -t "We Will Rock You" -a "Queen" -A "Greatest Hits"-y "1981" -T 16 16.mp3
id3v2 -t "We Are The Champions" -a "Queen" -A "Greatest Hits"-y "1981" -T 17 17.mp3

Publikováno 9.1.2016 v 19:55 | Kategorie: Debian