LXD with OpenvSwitch network

# create bridge
ovs-vsctl add-br mybridge
# ifconfig mybridge up
ip link set mybridge up
ovs-vsctl show
 
# connect ovs bridge to external network
ovs-vsctl add-port mybridge eno1
ifconfig eno1 0
dhclient mybridge -v
ip a show mybridge
route -n
 
# create LXD container
lxc profile create disk-only
lxc storage create pool1 dir
lxc profile device add disk-only root disk path=/ pool=pool1
lxc profile show disk-only
lxc launch ubuntu:18.04 ovs1 -p disk-only
lxc config device add ovs1 eth0 nic nictype=bridged parent=mybridge host_name=vport11
lxc launch ubuntu:18.04 ovs2 -p disk-only
lxc config device add ovs2 eth0 nic nictype=bridged parent=mybridge host_name=vport12
lxc network list

LXD: Network

Configure default profile

lxc network create lxdbr0
lxc network create lxdbr0 ipv4.address=10.0.33.1/24 ipv4.nat=true ipv6.address=none
lxc profile device add default eth0 nic nictype=bridged parent=lxdbr0 name=eth0
 
# disable IPv6 inside of container
lxc network set lxdbr0 ipv6.address none

Configure static IP address

lxc stop c1
lxc network attach lxdbr0 c1 eth0 eth0
lxc config device set c1 eth0 ipv4.address 10.0.0.12
lxc start c1
 
# add NICs
lxc config device add vm-dhcp1-dev dev-mgmt-new nic name=dev-mgmt nictype=macvlan parent=dev-mgmt

ipv6

lxc network set lxdbr0 ipv6.dhcp.stateful true

ovs network

lxc profile create disk-only
lxc storage create pool1 dir
lxc profile device add disk-only root disk path=/ pool=pool1
lxc profile show disk-only
lxc launch ubuntu:18.04 ovs1 -p disk-only
lxc config device add ovs1 eth0 nic nictype=bridged parent=ovsbridge host_name=vport11
lxc network list
# test static ip
lxc launch redis r
lxc config device override r
lxc config device set r eth0 ipv4.address 10.100.0.100

Links
https://stgraber.org/2016/03/15/lxd-2-0-installing-and-configuring-lxd-212/
https://thomas-leister.de/en/container-overlay-network-openvswitch-linux/
https://stgraber.org/2016/10/27/network-management-with-lxd-2-3/

Gitea

Install as Docker container
http://www.panticz.de/docker/container/gitea

APT packages
https://gitlab.com/packaging/gitea

Download archive
https://dl.gitea.io/gitea/

Migrate from gogs
https://docs.gitea.io/en-us/upgrade-from-gogs/

Backup
https://docs.gitea.io/en-us/backup-and-restore/

Install gitea on Kubernetes
https://docs.gitea.com/installation/install-on-kubernetes

helm repo add gitea-charts https://dl.gitea.com/charts/
helm install gitea gitea-charts/gitea

Links
https://gitea.io/

Install: tinyproxy

sudo apt-get install -y tinyproxy
 
sed -i 's|#Allow 192.168.0.0/16|Allow 192.168.0.0/16|g' /etc/tinyproxy.conf
sed -i 's|Port 8888|Port 8080|g' /etc/tinyproxy.conf
 
Port 80
Allow 10.0.0.0/8
 
FilterExtended On
FilterURLs On
FilterDefaultDeny Yes
Filter "/etc/tinyproxy/whitelist"
#Filter "/etc/tinyproxy/filter"
 
 
service tinyproxy restart

KVM: Create Windows 7 VM

Virtio driver
https://fedorapeople.org/groups/virt/virtio-win/deprecated-isos/stable/virtio-win-0.1-81.iso

Create VM

DISKIMG=win7.img
WIN7IMG=../iso/de_windows_7_professional_with_sp1_x64_dvd_u_676919.iso
VIRTIMG=../iso/virtio-win-0.1-81.iso
 
sudo qemu-system-x86_64 \
    --enable-kvm \
    -m 4096 \
    -smp cores=2 \
    -drive file=${DISKIMG},if=virtio \
    -net nic,model=virtio \
    -net user \
    -rtc base=localtime,clock=host \
    -usbdevice tablet \
    -soundhw ac97 \
    -cpu host \
    -vga std
 
    -vga qxl \
 
    -drive file=${VIRTIMG},index=3,media=cdrom \
    -cdrom ${WIN7IMG} \
 
    -vga vmware

Docker: HAProxy

Container
https://hub.docker.com/_/haproxy

Configuration
/tmp/haproxy/haproxy.cfg

global
  maxconn 4096
  #stats timeout 30s
  #debug
 
defaults
  log global
  mode http
  option httplog
  option dontlognull
  timeout connect 5000
  timeout client 50000
  timeout server 50000
  log 127.0.0.1 local0
  #option httpchk
 
frontend frontend1
  bind :80
  mode http
  use_backend backend1
 
backend backend1
  mode http
  balance roundrobin
  option httpchk GET / HTTP/1.1
  http-check expect status 400
  server www1 172.17.0.2:80 check
  server www2 172.17.0.4:80 check
  server www3 172.17.0.6:80 check
 
listen stats 
  bind :9000
  mode http
  stats enable
  stats hide-version
  stats realm Haproxy\ Statistics
  stats refresh 60s
  stats show-node
  stats auth haproxy:password
  stats uri /

Deploy

docker run -d --name haproxy -v /tmp/haproxy:/usr/local/etc/haproxy:ro -p 8080:80 -p 9000:9000 haproxy:latest
docker logs -f  haproxy

YouTube download and convert to mp3

https://yt-dl.org/update
https://github.com/ytdl-org/youtube-dl/releases

Installation
https://github.com/ytdl-org/youtube-dl#installation

wget -q https://yt-dl.org/downloads/latest/youtube-dl -O ~/.local/bin/youtube-dl
sudo chmod a+x ~/.local/bin/youtube-dl
# download audio (mp3) only
youtube-dl --extract-audio --audio-format mp3 -o "%(uploader)s/%(title)s.%(ext)s" https://www.youtube.com/watch?v=XXX
 
# download whole channel starting from 3 months
youtube-dl --extract-audio --audio-format mp3 -o "%(uploader)s/%(upload_date)s_%(title)s.%(ext)s" --dateafter now-3months -v https://www.youtube.com/user/OpenStackFoundation/videos
 
# update
sudo youtube-dl -U

# output template
https://github.com/ytdl-org/youtube-dl/blob/master/README.md#output-template