Added Setup-RootlessPodmanLXC HowTo-Linux-AllowHass-PowerCTL
This commit is contained in:
2 files changed
+104
No files matched your search
@@ -0,0 +1,32 @@
|
|||||||
|
Create user automation as system user
|
||||||
|
Get pub ssh key from hass instance and put here `/home/automation/.ssh/authorized_keys`
|
||||||
|
|
||||||
|
/etc/sudoers.d/hass-automation
|
||||||
|
```
|
||||||
|
automation ALL=NOPASSWD:/usr/sbin/poweroff
|
||||||
|
automation ALL=NOPASSWD:/usr/sbin/reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
/etc/polkit-1/rules.d/00-hass.rules
|
||||||
|
```
|
||||||
|
polkit.addRule(function(action, subject) {
|
||||||
|
if (action.id == "org.freedesktop.login1.suspend-multiple-sessions" && subject.user == "automation"){
|
||||||
|
return polkit.Result.YES;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
polkit.addRule(function(action, subject) {
|
||||||
|
if (action.id == "org.freedesktop.login1.hibernate-multiple-sessions" && subject.user == "automation"){
|
||||||
|
return polkit.Result.YES;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
/srv/HomeAssistant/data/shellcmd.yaml
|
||||||
|
```
|
||||||
|
<SystemName>_stby: "timeout 5s ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no automation@<ip or hostname> '/usr/bin/dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 'org.freedesktop.login1.Manager.Suspend' boolean:true'"
|
||||||
|
<SystemName>_off: "timeout 5s ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no automation@<ip or hostname> 'sudo /usr/sbin/poweroff'"
|
||||||
|
```
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
# Rootless Podman in unpriviliged LXC
|
||||||
|
add to LXC config
|
||||||
|
```
|
||||||
|
lxc.idmap: u 0 100000 200000
|
||||||
|
lxc.idmap: g 0 100000 200000
|
||||||
|
lxc.cgroup2.devices.allow: c 10:200 rwm
|
||||||
|
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
|
||||||
|
```
|
||||||
|
Up the Sub User/Group ID's for root
|
||||||
|
/etc/subuid
|
||||||
|
```
|
||||||
|
root:100000:200000
|
||||||
|
```
|
||||||
|
/etc/subgid
|
||||||
|
```
|
||||||
|
root:100000:200000
|
||||||
|
```
|
||||||
|
|
||||||
|
# in the LXC
|
||||||
|
## Podman install
|
||||||
|
```
|
||||||
|
newuser=<UserName>
|
||||||
|
adduser <USERAME>
|
||||||
|
apt install podman podman-docker podman-compose ca-certificates passt libpam-systemd dbus-user-session catatonit nftables aardvark-dns uidmap
|
||||||
|
cp /usr/lib/tmpfiles.d/podman.conf /etc/tmpfiles.d/podman.conf
|
||||||
|
echo 'R! /tmp/storage-run-*/containers/' >> /etc/tmpfiles.d/podman.conf
|
||||||
|
echo 'R! /tmp/storage-run-*/libpod/tmp/' >> /etc/tmpfiles.d/podman.conf
|
||||||
|
loginctl enable-linger bram
|
||||||
|
```
|
||||||
|
Reboot the LXC
|
||||||
|
## Admin interface
|
||||||
|
### Use Cockpit
|
||||||
|
```
|
||||||
|
. /etc/os-release
|
||||||
|
echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > /etc/apt/sources.list.d/backports.list
|
||||||
|
apt update
|
||||||
|
apt install -t ${VERSION_CODENAME}-backports cockpit cockpit-podman
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Use Dockhand
|
||||||
|
As the created user
|
||||||
|
```
|
||||||
|
systemctl --user --now enable podman.socket
|
||||||
|
poedman run -d \
|
||||||
|
--name dockhand \
|
||||||
|
--restart unless-stopped \
|
||||||
|
-p 3000:3000 \
|
||||||
|
-v /run/user/1000/podman/podman.sock:/var/run/docker.sock \
|
||||||
|
-v dockhand_data:/app/data \
|
||||||
|
docker.io/fnsys/dockhand:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### Use as remote for Dockhand (podman socket over IP)
|
||||||
|
As the created user
|
||||||
|
```
|
||||||
|
systemctl --user --now enable podman.socket
|
||||||
|
```
|
||||||
|
|
||||||
|
Edit `/usr/lib/systemd/user/podman.socket` as root
|
||||||
|
Replace
|
||||||
|
```
|
||||||
|
[Socket]
|
||||||
|
ListenStream=%t/podman/podman.sock
|
||||||
|
SocketMode=0660
|
||||||
|
```
|
||||||
|
with
|
||||||
|
```
|
||||||
|
[Socket]
|
||||||
|
ListenStream=0.0.0.0:2375
|
||||||
|
```
|
||||||
|
You can now add the enviroment as direct connection in dockhand
|
||||||
Reference in new issue
Block a user