From 276f7954afcc68d517b6e2fc22dcc7c642cf4794 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 31 Dec 2017 18:27:55 -0200 Subject: Initial code and notes, but still not working --- beggar | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 beggar (limited to 'beggar') diff --git a/beggar b/beggar new file mode 100755 index 0000000..6dad71d --- /dev/null +++ b/beggar @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# +# beggar containerization assistant +# +# Copyright (C) 2017 Silvio Rhatto - rhatto at riseup.net +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# Basic parameters +VERSION="0.1.0" +BASENAME="`basename $0`" +DIRNAME="`dirname $0`" +ACTION="$1" +VM="$2" +GLOBAL_USER_CONFIG_FOLDER="$HOME/.config/beggar" +GLOBAL_USER_CONFIG_FILE="$HOME/.config/beggarconfig" + +function beggar_startup { + mkdir -p $HOME/.config/lxc + #mkdir -p $HOME/.local/share/{lxc,lxcsnaps} + #mkdir -p $HOME/.cache/lxc + #touch $HOME/.config/lxc/{lxc,default}.conf + + if [ ! -e "$HOME/.config/lxc/default.conf" ]; then + echo \ +"# Include system-wide settings +lxc.include = /etc/lxc/default.conf + +# Subuids and subgids mapping +$(cat /etc/subuid | grep $USER | sed -e "s/^$USER:/lxc.id_map = u 0 /" -e 's/:/ /') +$(cat /etc/subgid | grep $USER | sed -e "s/^$USER:/lxc.id_map = g 0 /" -e 's/:/ /') + +# "Secure" mounting +lxc.mount.auto = proc:mixed sys:ro cgroup:mixed + +# Network configuration +lxc.network.type = veth +lxc.network.link = lxcbr0 +lxc.network.flags = up +lxc.network.hwaddr = 00:FF:xx:xx:xx:xx" > $HOME/.config/lxc/default.conf + fi +} + +# Main +beggar_startup -- cgit v1.2.3