From c7c53f847c8e70fd330804a27a2ed1430fa9b333 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Fri, 10 May 2024 00:40:25 +0200 Subject: [PATCH] chore(turris): try and fail to create a gitea lxc container --- knowledge base/dhcpcd.md | 34 ++++++++++++++ knowledge base/lxc.md | 4 ++ knowledge base/uci.md | 9 +++- snippets/turris-os.create-container.sh | 11 ----- snippets/turris-os.sh | 45 +++++++++++++++++++ snippets/turris-os.start-container-at-boot.sh | 7 --- 6 files changed, 90 insertions(+), 20 deletions(-) create mode 100644 knowledge base/dhcpcd.md delete mode 100644 snippets/turris-os.create-container.sh create mode 100644 snippets/turris-os.sh delete mode 100644 snippets/turris-os.start-container-at-boot.sh diff --git a/knowledge base/dhcpcd.md b/knowledge base/dhcpcd.md new file mode 100644 index 0000000..372a036 --- /dev/null +++ b/knowledge base/dhcpcd.md @@ -0,0 +1,34 @@ +# dhcpcd + +1. [TL;DR](#tldr) + +## TL;DR + +
+ Usage + +```sh +# Start on specific interfaces. +dhcpcd 'eth0' + +# Release the current IP address. +dhcpcd -k 'eth0' +dhcpcd --release 'eth0' + +# Stop +dhcpcd -x +dhcpcd --exit +``` + +
+ + + + + + + + diff --git a/knowledge base/lxc.md b/knowledge base/lxc.md index e06743b..50f9395 100644 --- a/knowledge base/lxc.md +++ b/knowledge base/lxc.md @@ -19,6 +19,10 @@ ls '/usr/share/lxc/templates' # List the options supported by templates. lxc-create -t 'download' -h +# List the available images. +lxc-create -t 'download' -- -l +lxc-create -t 'download' -- --list + # Create containers. # Use the 'download' template to choose from a list of distribution. lxc-create -n 'nas' -t 'download' diff --git a/knowledge base/uci.md b/knowledge base/uci.md index fdd7c97..3a2f7f7 100644 --- a/knowledge base/uci.md +++ b/knowledge base/uci.md @@ -18,7 +18,7 @@ uci show 'dhcp' # Show what interface is the WAN. uci show network.wan.device | cut -d "'" -f 2 -# Configure a static IP address lease. +# Configure static IP address leases. uci add dhcp host uci set dhcp.@host[-1].name='hostname' uci set dhcp.@host[-1].mac='11:22:33:44:55:66' @@ -26,7 +26,12 @@ uci set dhcp.@host[-1].ip='192.168.1.2' uci commit 'dhcp' reload_config -# Use a different port as WAN switching it with one in LAN. +# Delete list elements. +uci del 'dhcp.@host[12]' +uci commit 'dhcp' +reload_config + +# Use a different port as WAN by swapping the default one with another one in LAN. uci set network.wan.device='lan4' uci del_list network.br_lan.ports='lan4' uci add_list network.br_lan.ports='eth2' diff --git a/snippets/turris-os.create-container.sh b/snippets/turris-os.create-container.sh deleted file mode 100644 index 92925ee..0000000 --- a/snippets/turris-os.create-container.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -lxc-create -n 'alpine' -t 'download' -- -d 'Alpine' -r '3.18' -a 'armv7l' - -uci add dhcp 'host' -uci set dhcp.@host[-1].name='alpine' -uci set dhcp.@host[-1].mac="$(grep 'hwaddr' '/srv/lxc/alpine/config' | sed 's/.*= //')" -uci set dhcp.@host[-1].ip='192.168.111.2' -uci commit 'dhcp' -reload_config -luci-reload diff --git a/snippets/turris-os.sh b/snippets/turris-os.sh new file mode 100644 index 0000000..f8cdf7d --- /dev/null +++ b/snippets/turris-os.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env sh + +# Create alpine-based containers. +lxc-create -n 'alpine' -t 'download' -- -d 'Alpine' -r '3.18' -a 'armv7l' + +# Set static leases. +uci add dhcp 'host' +uci set dhcp.@host[-1].name='alpine' +uci set dhcp.@host[-1].mac="$(grep 'hwaddr' '/srv/lxc/alpine/config' | sed 's/.*= //')" +uci set dhcp.@host[-1].ip='192.168.111.2' +uci commit 'dhcp' +reload_config +luci-reload + +# Start containers at boot. +cat <