понедельник, 4 ноября 2019 г.

Ubuntu 16.04 lxc привилегированные контейнеры

LXC USB Passthrough (Proxmox)
LXC USB Device Passthrough
$ ip a
192.168.1.179

$ sudo nano /etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto enp0s3
#iface enp0s3 inet dhcp

##Bridge  Name ###
auto br0

### Bridge Information
iface br0 inet static
bridge_ports enp0s3
bridge_stp off
bridge_fd 9


### Bridge IP ###
address 192.168.1.179
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8

Сохранить.

$ sudo apt-get install lxc lxc-templates wget bridge-utils -y

Disable the default bridge “lxcbr0“,  got created as part of LXC installation

$ sudo nano /etc/default/lxc-net

USE_LXC_BRIDGE="false"

Сохранить.

$ sudo nano /etc/lxc/default.conf

lxc.network.type = veth
lxc.network.link = br0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx

Сохранить.

$ sudo nano /etc/dnsmasq.d/lxc

# Tell any system-wide dnsmasq instance to make sure to bind to interfaces
# instead of listening on 0.0.0.0
# WARNING: changes to this file will get lost if lxc is removed.
bind-interfaces
except-interface=br0

Сохранить.

$ sudo reboot




#$ sudo lxc-create  -t ubuntu -n bionic_lxc -- -r bionic -a amd64
$ sudo lxc-create -t download -n bionic_lxc
Distribution:
ubuntu
Release:
bionic
Architecture:
amd64
Downloading the image index
Downloading the rootfs
Downloading the metadata
The image cache is now ready
Unpacking the rootfs

---
You just created an Ubuntu bionic amd64 (20191104_07:42) container.

To enable SSH, run: apt install openssh-server
No default root or user password are set by LXC.

Посмотреть контейнеры:

$ sudo lxc-ls
bionic_lxc







Клонировать контейнер:

$ sudo lxc-copy -n bionic_lxc -N bionic_lxc_clone

$ sudo lxc-ls
bionic_lxc       bionic_lxc_clone


Запустить контейнер:

$ sudo lxc-start -n bionic_lxc_clone 


$ sudo lxc-attach -n bionic_lxc_clone
root@bionic_lxc_clone:/# passwd
# passwd ubuntu
Задать пароль.
Добавить пользователей:
# adduser user
# usermod -aG sudo user
# exit
 
Запустить консоль:
$ sudo lxc-console -n bionic_lxc_clone

$ sudo apt-get install usbutils
$ lsusb
$ usb-devices
$ sudo apt install samba mc git curl wget
$ git clone https://github.com/renbuar/setup-1c.git
$ cd setup-1c
$ sh downloadpg.sh
$ sudo apt install libxslt1.1
$ sudo sh setup_pg11_1c.sh
$ sh download.sh
$ sudo sh setup-1c.sh
$ sudo sh setup-2c.sh 

На хосте:
$ lsusb
Bus 001 Device 003: ID 0529:0001 Aladdin Knowledge Systems HASP copy protection dongle



$ ls -l /dev/bus/usb/001/003
crw-rw-r-- 1 root root 189, 2 ноя  4 16:22 /dev/bus/usb/001/003


$ sudo nano /var/lib/lxc/bionic_lxc_clone/config

lxc.cgroup.devices.allow = c 189:* rwm
lxc.mount.entry = /dev/bus/usb/001/003 dev/bus/usb/001/003 none bind,optional,create=file



Удаление контейнера:


$ sudo lxc-destroy -n hasp


$ sudo systemctl stop apparmor
$ sudo systemctl disable apparmor
$ sudo lxc-copy -n bionic_lxc -N hasp

$ sudo nano /var/lib/lxc/hasp/config

lxc.cgroup.devices.allow = c 189:* rwm
lxc.mount.entry = /dev/bus/usb/001/003 dev/bus/usb/001/003 none bind,optional

Сохранить.

Запустить контейнер:

$ sudo lxc-start -n hasp


$ sudo lxc-attach -n hasp
root@hasp:/# passwd
# passwd ubuntu
Задать пароль.
Добавить пользователей:
# adduser user
# usermod -aG sudo user
# exit
 
Запустить консоль:
$ sudo lxc-console -n hasp

$ sudo apt-get install usbutils samba ssh
$ lsusb
$ usb-devices
$ sudo apt install samba mc git curl wget libxslt1.1 nano
$ sudo  apt install -y libc6-i386 make
$ git clone https://github.com/renbuar/setup-1c.git
$ cd setup-1c
#$ sudo dpkg -i dist/haspd_7.90-eter2ubuntu_amd64.deb
#$ sudo dpkg -i dist/haspd-modules_7.90-eter2ubuntu_amd64.deb
#$ sudo apt-get install -f -y
#$ sudo service haspd start
#$ sudo service haspd status

$ sh downloadpg.sh
#$ sudo apt install libxslt1.1
$ sudo locale-gen ru_RU.UTF-8
$ sudo sh setup_pg11_1c.sh
$ sh download.sh
$ sudo sh setup-1c.sh
$ sudo sh setup-2c.sh
$ usbkeytest --list
ID: 0529:0001, Bus: 001, Device: 003, Can't locate /dev/bus/usb/001/003
$ usbkeytest --detect
aladdin

#$ time sudo su postgres -c "pg_dump -Fc demo"  > ~/demo.dump
$ sudo su postgres -c "createdb --username postgres -T template0 demo"
$ time sudo su postgres -c "pg_restore -d demo1 /home/user/demo.dump"
$ sudo -u postgres pg_probackup-11 backup -B /backup --instance main -b FULL --stream --compress --delete-wal --expired -j 4
$ sudo sh backup/restore_beta.sh
$ sudo sh backup/restore_main.sh

$ sudo lxc-stop -n hasp

$ sudo mkdir -p  /var/lib/lxc/hasp/rootfs/dev/bus/usb/001
$ sudo mount --bind /dev/bus/usb/001 /var/lib/lxc/hasp/rootfs/dev/bus/usb/001

sudo systemctl status aksusbd.service
sudo systemctl status hasplmd.service













Комментариев нет:

Отправить комментарий