Skip to content

Instantly share code, notes, and snippets.

View iAnatoly's full-sized avatar

Anatoly Ivanov iAnatoly

View GitHub Profile
@iAnatoly
iAnatoly / change_luks.md
Last active May 12, 2022 21:08
Change Luks password

First, find out which is the encrypted LVM partition

cat /etc/crypttab

To add a new password, use luksAddKey:

sudo cryptsetup luksAddKey /dev/sda3

To remove an existing password, use luksRemoveKey:

@iAnatoly
iAnatoly / sip_ping.py
Last active May 13, 2022 15:34
SIP ping
#!/usr/bin/env python3
import socket
import time
userid = "trivial_sip_pinger"
domain = "<sip server to test>"
port = 5060
timeout_ms = 1000
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  1. Create a file with json request, for example:
$ cat > TTS.json <<END
{
  "audioConfig": {
    "audioEncoding": "LINEAR16",
    "pitch": 0,
    "speakingRate": 1
 },
@iAnatoly
iAnatoly / TELEGRAM.md
Last active May 24, 2022 01:19
send alert messages to a telegram channel.
  1. create bot by messaging @botfather (/newbot)
  2. save a token in env var: export token="yourtokenfrombotfather". If you need to re-issue a token, use /revoke command to botfather.
  3. add your bot to a channel you intend for alerts
  4. Send some message into that channel using telegram client. A simple "test" will do.
  5. get chat id: curl https://api.telegram.org/bot${token}/getUpdates | grep test
  6. send a test message: curl https://api.telegram.org/bot${token}/sendMessage --data '{"chat_id":${chat_id},"text": "message"}' -H "Content-type: application/json"
  7. codify the above experience.
#!/bin/bash
set -eu -o pipefail