mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-04-29 20:56:26 +00:00
Add distro config file /etc/lxc/lxc.conf
This allows a distro to put the distro specific default network configuration (for example bridge device, link type), or other lxc configuration in the case that -f is not passed by the user to lxc-create, in which case lxc-create will use the distro conf file as the basis for the containers config. Signed-off-by: Dwight Engen <dwight.engen@oracle.com> Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
b1dc05fde9
commit
6f75ba0bda
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
ACLOCAL_AMFLAGS = -I config
|
ACLOCAL_AMFLAGS = -I config
|
||||||
|
|
||||||
SUBDIRS = src templates doc
|
SUBDIRS = config src templates doc
|
||||||
DIST_SUBDIRS = config src templates doc
|
DIST_SUBDIRS = config src templates doc
|
||||||
EXTRA_DIST = autogen.sh lxc.spec CONTRIBUTING MAINTAINERS ChangeLog
|
EXTRA_DIST = autogen.sh lxc.spec CONTRIBUTING MAINTAINERS ChangeLog
|
||||||
|
|
||||||
|
@ -1,2 +1,11 @@
|
|||||||
|
configdir = $(sysconfdir)/lxc
|
||||||
|
config_DATA = lxc.conf
|
||||||
|
conffile = @LXC_CONFFILE@
|
||||||
|
|
||||||
|
EXTRA_DIST = lxc.conf.ubuntu lxc.conf.libvirt lxc.conf.unknown
|
||||||
|
|
||||||
|
lxc.conf:
|
||||||
|
cp $(conffile) $@
|
||||||
|
|
||||||
distclean:
|
distclean:
|
||||||
@$(RM) -f compile config.guess config.sub depcomp install-sh ltmain.sh missing Makefile.in Makefile
|
@$(RM) -f compile config.guess config.sub depcomp install-sh ltmain.sh missing Makefile.in Makefile
|
||||||
|
3
config/lxc.conf.libvirt
Normal file
3
config/lxc.conf.libvirt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
lxc.network.type=veth
|
||||||
|
lxc.network.link=virbr0
|
||||||
|
lxc.network.flags=up
|
3
config/lxc.conf.ubuntu
Normal file
3
config/lxc.conf.ubuntu
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
lxc.network.type=veth
|
||||||
|
lxc.network.link=lxcbr0
|
||||||
|
lxc.network.flags=up
|
1
config/lxc.conf.unknown
Normal file
1
config/lxc.conf.unknown
Normal file
@ -0,0 +1 @@
|
|||||||
|
lxc.network.type=empty
|
42
configure.ac
42
configure.ac
@ -12,10 +12,45 @@ AM_PROG_CC_C_O
|
|||||||
AC_GNU_SOURCE
|
AC_GNU_SOURCE
|
||||||
AC_CHECK_PROG(SETCAP, setcap, yes, no, $PATH$PATH_SEPARATOR/sbin)
|
AC_CHECK_PROG(SETCAP, setcap, yes, no, $PATH$PATH_SEPARATOR/sbin)
|
||||||
|
|
||||||
if test -f /etc/debian_version; then
|
AC_MSG_CHECKING([host distribution])
|
||||||
osname="debian"
|
AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, oracle, fedora, suse, gentoo, debian, arch, slackware, paldo, mandriva or pardus]))
|
||||||
|
if test "z$with_distro" = "z"; then
|
||||||
|
with_distro=`lsb_release -is`
|
||||||
fi
|
fi
|
||||||
AM_CONDITIONAL([HAVE_DEBIAN], [test x"$osname" == xdebian])
|
if test "z$with_distro" = "z"; then
|
||||||
|
AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
|
||||||
|
AC_CHECK_FILE(/etc/oracle-release,with_distro="oracle")
|
||||||
|
AC_CHECK_FILE(/etc/fedora-release,with_distro="fedora")
|
||||||
|
AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
|
||||||
|
AC_CHECK_FILE(/etc/gentoo-release,with_distro="gentoo")
|
||||||
|
AC_CHECK_FILE(/etc/debian_version,with_distro="debian")
|
||||||
|
AC_CHECK_FILE(/etc/arch-release,with_distro="arch")
|
||||||
|
AC_CHECK_FILE(/etc/slackware-version,with_distro="slackware")
|
||||||
|
AC_CHECK_FILE(/etc/frugalware-release,with_distro="frugalware")
|
||||||
|
AC_CHECK_FILE(/etc/mandrakelinux-release, with_distro="mandriva")
|
||||||
|
AC_CHECK_FILE(/etc/mandriva-release,with_distro="mandriva")
|
||||||
|
AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
|
||||||
|
fi
|
||||||
|
with_distro=`echo ${with_distro} | tr '[[:upper:]]' '[[:lower:]]'`
|
||||||
|
|
||||||
|
if test "z$with_distro" = "z"; then
|
||||||
|
with_distro="unknown"
|
||||||
|
fi
|
||||||
|
case $with_distro in
|
||||||
|
ubuntu)
|
||||||
|
conffile=lxc.conf.ubuntu
|
||||||
|
;;
|
||||||
|
redhat|fedora|oracle|oracleserver)
|
||||||
|
conffile=lxc.conf.libvirt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo -n "Linux distribution network config unknown, defaulting to lxc.network.type = empty"
|
||||||
|
conffile=lxc.conf.unknown
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
AC_MSG_RESULT([$with_distro])
|
||||||
|
|
||||||
|
AM_CONDITIONAL([HAVE_DEBIAN], [test x"$with_distro" = "xdebian" -o x"$with_distro" = "xubuntu"])
|
||||||
|
|
||||||
AC_ARG_ENABLE([rpath],
|
AC_ARG_ENABLE([rpath],
|
||||||
[AC_HELP_STRING([--disable-rpath], [do not set rpath in executables])],
|
[AC_HELP_STRING([--disable-rpath], [do not set rpath in executables])],
|
||||||
@ -111,6 +146,7 @@ AC_ARG_WITH([rootfs-path],
|
|||||||
[lxc rootfs mount point]
|
[lxc rootfs mount point]
|
||||||
)], [], [with_rootfs_path=['${libdir}/lxc/rootfs']])
|
)], [], [with_rootfs_path=['${libdir}/lxc/rootfs']])
|
||||||
|
|
||||||
|
AS_AC_EXPAND(LXC_CONFFILE, $conffile)
|
||||||
AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date)")
|
AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date)")
|
||||||
AS_AC_EXPAND(LXCPATH, "${with_config_path}")
|
AS_AC_EXPAND(LXCPATH, "${with_config_path}")
|
||||||
AS_AC_EXPAND(LXCROOTFSMOUNT, "${with_rootfs_path}")
|
AS_AC_EXPAND(LXCROOTFSMOUNT, "${with_rootfs_path}")
|
||||||
|
@ -91,6 +91,7 @@ rm -rf %{buildroot}
|
|||||||
%{_mandir}/*
|
%{_mandir}/*
|
||||||
%{_datadir}/doc/*
|
%{_datadir}/doc/*
|
||||||
%{_datadir}/lxc/*
|
%{_datadir}/lxc/*
|
||||||
|
%{_sysconfdir}/lxc/*
|
||||||
|
|
||||||
%files libs
|
%files libs
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
|
@ -260,16 +260,18 @@ trap cleanup HUP INT TERM
|
|||||||
mkdir -p $lxc_path/$lxc_name
|
mkdir -p $lxc_path/$lxc_name
|
||||||
|
|
||||||
if [ -z "$lxc_config" ]; then
|
if [ -z "$lxc_config" ]; then
|
||||||
touch $lxc_path/$lxc_name/config
|
lxc_config="@SYSCONFDIR@/lxc/lxc.conf"
|
||||||
else
|
echo
|
||||||
if [ ! -r "$lxc_config" ]; then
|
echo "$(basename $0): No config file specified, using the default config $lxc_config"
|
||||||
echo "$(basename $0): '$lxc_config' configuration file not found" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp $lxc_config $lxc_path/$lxc_name/config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -r "$lxc_config" ]; then
|
||||||
|
echo "$(basename $0): '$lxc_config' configuration file not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp $lxc_config $lxc_path/$lxc_name/config
|
||||||
|
|
||||||
if [ -n "$custom_rootfs" ]; then
|
if [ -n "$custom_rootfs" ]; then
|
||||||
if grep -q "lxc.rootfs" $lxc_path/$lxc_name/config ; then
|
if grep -q "lxc.rootfs" $lxc_path/$lxc_name/config ; then
|
||||||
echo "configuration file already specifies a lxc.rootfs"
|
echo "configuration file already specifies a lxc.rootfs"
|
||||||
@ -295,13 +297,6 @@ if [ ! -z $lxc_template ]; then
|
|||||||
cleanup
|
cleanup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$lxc_config" ]; then
|
|
||||||
echo "Note: Usually the template option is called with a configuration"
|
|
||||||
echo "file option too, mostly to configure the network."
|
|
||||||
echo "For more information look at lxc.conf (5)"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
${templatedir}/lxc-$lxc_template --path=$lxc_path/$lxc_name --name=$lxc_name $*
|
${templatedir}/lxc-$lxc_template --path=$lxc_path/$lxc_name --name=$lxc_name $*
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "$(basename $0): failed to execute template '$lxc_template'" >&2
|
echo "$(basename $0): failed to execute template '$lxc_template'" >&2
|
||||||
|
Loading…
Reference in New Issue
Block a user