Compare commits
13 Commits
master
...
feature-lx
Author | SHA1 | Date | |
---|---|---|---|
2ffe939f5c | |||
268e327351 | |||
f5a2ddb0c4 | |||
27b9155cd9 | |||
|
226c2567d9 | ||
|
fb524720f4 | ||
|
adc9f4f7b5 | ||
|
edfeec5868 | ||
|
a5de57abb7 | ||
|
127d682cfb | ||
|
d4b7654769 | ||
|
a45c267641 | ||
|
76fc7b342f |
@ -5,7 +5,7 @@
|
||||
#check_dependency
|
||||
# -> 0 | -> 16
|
||||
function check_dependency() {
|
||||
for packet in squashfs-tools xorriso wget sed sendemail; do
|
||||
for packet in squashfs-tools xorriso lxc wget sed sendemail; do
|
||||
[ "`dpkg -l $packet 2>&1`" == "dpkg-query: Kein Paket gefunden, das auf $packet passt" ] && {
|
||||
echo "### ERROR ### Packet $packet not installed"
|
||||
return 16
|
||||
|
32
src/func/chroot
Executable file
32
src/func/chroot
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
#remaster lib
|
||||
[ -d "<LIBDIR>" ] || { echo "LIBDIR not exist"; exit 1; }
|
||||
|
||||
## overload chroot with lxc
|
||||
function chroot() {
|
||||
lxc-attach -n _remaster_ -- "$2" "$3" "$4" "$5" "$6" "$7"
|
||||
}
|
||||
|
||||
## create lxc config
|
||||
|
||||
#chroot_config [chroot_dir]
|
||||
function chroot_config() {
|
||||
|
||||
chroot_dir="$1"
|
||||
|
||||
# Container specific configuration
|
||||
echo "lxc.rootfs = $chroot_dir"
|
||||
echo "lxc.rootfs.backend = dir"
|
||||
echo "lxc.utsname = _remaster_"
|
||||
|
||||
# Network configuration
|
||||
echo "lxc.network.type = veth"
|
||||
echo "lxc.network.link = lxcbr0"
|
||||
echo "lxc.network.flags = up"
|
||||
echo "lxc.network.hwaddr = 00:16:3e:5a:ba:1e"
|
||||
}
|
||||
|
||||
[ -n "$1" ] && {
|
||||
echo param
|
||||
$1
|
||||
}
|
@ -13,11 +13,13 @@ function chroot_initial() {
|
||||
return 12
|
||||
}
|
||||
|
||||
#mount virus definitions
|
||||
mount -t tmpfs tmpfs "$chroot_dir/tmp"
|
||||
mount -t tmpfs tmpfs "$chroot_dir/root"
|
||||
mount --bind /dev "$chroot_dir/dev"
|
||||
mount --bind /proc "$chroot_dir/proc"
|
||||
[ -d "/var/lib/lxc/_remaster_/" ] && {
|
||||
echo "### Warning ### chroot_initial: lxc container exists"
|
||||
[ -f "/var/lib/lxc/_remaster_/config" ] && {
|
||||
mv -f "/var/lib/lxc/_remaster_/config" "/var/lib/lxc/_remaster_/config.old"
|
||||
}
|
||||
}
|
||||
mkdir -p "/var/lib/lxc/_remaster_/"
|
||||
|
||||
rm "$chroot_dir/etc/resolv.conf"
|
||||
cp "/etc/resolv.conf" "$chroot_dir/etc/resolv.conf"
|
||||
|
@ -7,12 +7,15 @@
|
||||
function chroot_is_mounted() {
|
||||
#$1 = chroot directory
|
||||
|
||||
if [ "`mount | grep "$1"`" != "" ] ; then
|
||||
#ther is smething mounted
|
||||
echo "true"
|
||||
else
|
||||
#nothing mounted
|
||||
#get state of _remaster from lxc
|
||||
STATE=`lxc-ls _remaster_ -f -F STATE | tail -n 1 | sed 's/ //g'`
|
||||
|
||||
if [ "#$STATE#" == "#STOPPED#" ] ; then
|
||||
#nothing running
|
||||
echo "false"
|
||||
else
|
||||
#container is running
|
||||
echo "true"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,9 @@ function workspace_erase() {
|
||||
[ -d "$dir" ] && rm -r -f "$dir"
|
||||
done
|
||||
|
||||
#lxc
|
||||
[ -d /var/lib/lxc/_remaster_/ ] && rm -R /var/lib/lxc/_remaster_/
|
||||
|
||||
echo "done"
|
||||
}
|
||||
|
||||
|
@ -261,3 +261,22 @@ function project_mods-desinfect.17() {
|
||||
}
|
||||
}
|
||||
function project_mods() { project_mods-desinfect.17 $@; }
|
||||
|
||||
function chroot_initial-desinfect2017() {
|
||||
#$1 = chroot dir
|
||||
|
||||
<LIBDIR>/func/chroot_initial "$1"
|
||||
|
||||
#LXC Start
|
||||
config="/var/lib/lxc/_remaster_/config"
|
||||
|
||||
#special conf for distros:
|
||||
echo "lxc.include = /usr/share/lxc/config/nesting.conf" > $config
|
||||
echo "lxc.include = /usr/share/lxc/config/ubuntu.common.conf" >> $config
|
||||
echo "lxc.arch = x86_64" >> $config
|
||||
|
||||
#normal config
|
||||
chroot_config "$chroot_dir" >> $config
|
||||
#LXC End
|
||||
}
|
||||
function chroot_initial() { chroot_initial-desinfect.17 $@; }
|
||||
|
@ -96,6 +96,9 @@ source <LIBDIR>/func/iso_create
|
||||
|
||||
### chroot ###
|
||||
|
||||
## overload chroot with lxc
|
||||
source <LIBDIR>/func/chroot
|
||||
|
||||
#chroot_initial [chroot_dir]
|
||||
source <LIBDIR>/func/chroot_initial
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user