merge diff
This commit is contained in:
parent
49901e1f32
commit
76fc7b342f
@ -5,7 +5,7 @@
|
|||||||
#check_dependency
|
#check_dependency
|
||||||
# -> 0 | -> 16
|
# -> 0 | -> 16
|
||||||
function check_dependency() {
|
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" ] && {
|
[ "`dpkg -l $packet 2>&1`" == "dpkg-query: Kein Paket gefunden, das auf $packet passt" ] && {
|
||||||
echo "### ERROR ### Packet $packet not installed"
|
echo "### ERROR ### Packet $packet not installed"
|
||||||
return 16
|
return 16
|
||||||
|
23
src/func/chroot
Normal file
23
src/func/chroot
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
## 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"
|
||||||
|
}
|
@ -13,11 +13,13 @@ function chroot_initial() {
|
|||||||
return 12
|
return 12
|
||||||
}
|
}
|
||||||
|
|
||||||
#mount virus definitions
|
[ -d "/var/lib/lxc/_remaster_/" ] && {
|
||||||
mount -t tmpfs tmpfs "$chroot_dir/tmp"
|
echo "### Warning ### chroot_initial: lxc container exists"
|
||||||
mount -t tmpfs tmpfs "$chroot_dir/root"
|
[ -f "/var/lib/lxc/_remaster_/config" ] && {
|
||||||
mount --bind /dev "$chroot_dir/dev"
|
mv -f "/var/lib/lxc/_remaster_/config" "/var/lib/lxc/_remaster_/config.old"
|
||||||
mount --bind /proc "$chroot_dir/proc"
|
}
|
||||||
|
}
|
||||||
|
mkdir -p "/var/lib/lxc/_remaster_/"
|
||||||
|
|
||||||
rm "$chroot_dir/etc/resolv.conf"
|
rm "$chroot_dir/etc/resolv.conf"
|
||||||
cp "/etc/resolv.conf" "$chroot_dir/etc/resolv.conf"
|
cp "/etc/resolv.conf" "$chroot_dir/etc/resolv.conf"
|
||||||
|
@ -7,11 +7,14 @@
|
|||||||
function chroot_is_mounted() {
|
function chroot_is_mounted() {
|
||||||
#$1 = chroot directory
|
#$1 = chroot directory
|
||||||
|
|
||||||
if [ "`mount | grep "$1"`" != "" ] ; then
|
#get state of _remaster from lxc
|
||||||
#ther is smething mounted
|
STATE=`lxc-ls _remaster_ -f -F STATE | tail -n 1 | sed 's/ //g'`
|
||||||
echo "true"
|
|
||||||
else
|
if [ "#$STATE#" == "#STOPPED#" ] ; then
|
||||||
#nothing mounted
|
#nothing running
|
||||||
echo "false"
|
echo "false"
|
||||||
|
else
|
||||||
|
#container is running
|
||||||
|
echo "true"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,8 @@ function workspace_erase() {
|
|||||||
[ -d "$dir" ] && rm -r -f "$dir"
|
[ -d "$dir" ] && rm -r -f "$dir"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
#lxc
|
||||||
|
[ -d /var/lib/lxc/_remaster_/ ] && rm -R /var/lib/lxc/_remaster_/
|
||||||
|
|
||||||
echo "done"
|
echo "done"
|
||||||
}
|
}
|
||||||
|
@ -619,6 +619,18 @@ function chroot_initial_desinfect2017() {
|
|||||||
|
|
||||||
chroot_initial "$1"
|
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
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
1680
src/remaster_lxc.sh
Normal file
1680
src/remaster_lxc.sh
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user