aboutsummaryrefslogtreecommitdiff
path: root/beggar
blob: 6dad71d07f2dacab297978ec321161596df53459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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 <http://www.gnu.org/licenses/>.
#

# 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