}
/* if rootfs->path is a blockdev path, allow container fstab to
- * use /var/lib/lxc/CN/rootfs as the target prefix */
- r = snprintf(path, MAXPATHLEN, "/var/lib/lxc/%s/rootfs", lxc_name);
+ * use $LXCPATH/CN/rootfs as the target prefix */
+ r = snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", lxc_name);
if (r < 0 || r >= MAXPATHLEN)
goto skipvarlib;
goto out;
}
str = c->config_file_name(c);
-#define CONFIGFNAM "/var/lib/lxc/" MYNAME "/config"
+#define CONFIGFNAM LXCPATH "/" MYNAME "/config"
if (!str || strcmp(str, CONFIGFNAM)) {
fprintf(stderr, "%d: got wrong config file name (%s, not %s)\n", __LINE__, str, CONFIGFNAM);
goto out;
fprintf(stderr, "%d: failed writing config file /tmp/lxctest1\n", __LINE__);
goto out;
}
- rename("/var/lib/lxc/" MYNAME "/config", "/var/lib/lxc/" MYNAME "/config.bak");
+ rename(LXCPATH "/" MYNAME "/config", LXCPATH "/" MYNAME "/config.bak");
if (!c->save_config(c, NULL)) {
fprintf(stderr, "%d: failed writing config file\n", __LINE__);
goto out;
goto out;
c->stop(c);
- ret = system("mkdir -p /var/lib/lxc/lxctest1/rootfs//usr/local/libexec/lxc");
+ ret = system("mkdir -p " LXCPATH "/lxctest1/rootfs//usr/local/libexec/lxc");
if (!ret)
- ret = system("mkdir -p /var/lib/lxc/lxctest1/rootfs/usr/lib/lxc/");
+ ret = system("mkdir -p " LXCPATH "/lxctest1/rootfs/usr/lib/lxc/");
if (!ret)
- ret = system("cp src/lxc/lxc-init /var/lib/lxc/lxctest1/rootfs//usr/local/libexec/lxc");
+ ret = system("cp src/lxc/lxc-init " LXCPATH "/lxctest1/rootfs//usr/local/libexec/lxc");
if (!ret)
- ret = system("cp src/lxc/liblxc.so /var/lib/lxc/lxctest1/rootfs/usr/lib/lxc");
+ ret = system("cp src/lxc/liblxc.so " LXCPATH "/lxctest1/rootfs/usr/lib/lxc");
if (!ret)
- ret = system("cp src/lxc/liblxc.so /var/lib/lxc/lxctest1/rootfs/usr/lib/lxc/liblxc.so.0");
+ ret = system("cp src/lxc/liblxc.so " LXCPATH "/lxctest1/rootfs/usr/lib/lxc/liblxc.so.0");
if (!ret)
- ret = system("cp src/lxc/liblxc.so /var/lib/lxc/lxctest1/rootfs/usr/lib");
+ ret = system("cp src/lxc/liblxc.so " LXCPATH "/lxctest1/rootfs/usr/lib");
if (!ret)
- ret = system("mkdir -p /var/lib/lxc/lxctest1/rootfs/dev/shm");
+ ret = system("mkdir -p " LXCPATH "/lxctest1/rootfs/dev/shm");
if (!ret)
- ret = system("chroot /var/lib/lxc/lxctest1/rootfs apt-get install --no-install-recommends lxc");
+ ret = system("chroot " LXCPATH "/lxctest1/rootfs apt-get install --no-install-recommends lxc");
if (ret) {
fprintf(stderr, "%d: failed to installing lxc-init in container\n", __LINE__);
goto out;
#Configurations
arch=$(arch)
-cache_base=/var/cache/lxc/altlinux/$arch
+cache_base=@LOCALSTATEDIR@/cache/lxc/altlinux/$arch
default_path=@LXCPATH@
default_profile=default
profile_dir=/etc/lxc/profiles
install_altlinux()
{
- mkdir -p /var/lock/subsys/
+ mkdir -p @LOCALSTATEDIR@/lock/subsys/
(
flock -x 200
if [ $? -ne 0 ]; then
return 0
- ) 200>/var/lock/subsys/lxc
+ ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
return $?
}
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
- ) 200>/var/lock/subsys/lxc
+ ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
}
usage()
Mandatory args:
-n,--name container name, used to as an identifier for that container from now on
Optional args:
- -p,--path path to where the container rootfs will be created, defaults to /var/lib/lxc. The container config will go under /var/lib/lxc in and case
+ -p,--path path to where the container rootfs will be created, defaults to @LXCPATH@. The container config will go under @LXCPATH@ in that case
-c,--clean clean the cache
-R,--release ALTLinux release for the new container. if the host is ALTLinux, then it will defaultto the host's release.
-4,--ipv4 specify the ipv4 address to assign to the virtualized interface, eg. 192.168.1.123/24
#Configurations
arch=$(arch)
-cache_base=/var/cache/lxc/fedora/$arch
-default_path=/var/lib/lxc
+cache_base=@LOCALSTATEDIR@/cache/lxc/fedora/$arch
+default_path=@LXCPATH@
root_password=root
# is this fedora?
install_fedora()
{
- mkdir -p /var/lock/subsys/
+ mkdir -p @LOCALSTATEDIR@/lock/subsys/
(
flock -x 200
if [ $? -ne 0 ]; then
return 0
- ) 200>/var/lock/subsys/lxc
+ ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
return $?
}
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
- ) 200>/var/lock/subsys/lxc
+ ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
}
usage()
Mandatory args:
-n,--name container name, used to as an identifier for that container from now on
Optional args:
- -p,--path path to where the container rootfs will be created, defaults to /var/lib/lxc. The container config will go under /var/lib/lxc in that case
+ -p,--path path to where the container rootfs will be created, defaults to @LXCPATH@. The container config will go under @LXCPATH@ in that case
-c,--clean clean the cache
-R,--release Fedora release for the new container. if the host is Fedora, then it will defaultto the host's release.
-A,--arch NOT USED YET. Define what arch the container will be [i686,x86_64]
install_opensuse()
{
- cache="/var/cache/lxc/opensuse"
+ cache="@LOCALSTATEDIR@/cache/lxc/opensuse"
rootfs=$1
- mkdir -p /var/lock/subsys/
+ mkdir -p @LOCALSTATEDIR@/lock/subsys/
(
flock -x 200
if [ $? -ne 0 ]; then
return 0
- ) 200>/var/lock/subsys/lxc
+ ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
return $?
}
clean()
{
- cache="/var/cache/lxc/opensuse"
+ cache="@LOCALSTATEDIR@/cache/lxc/opensuse"
if [ ! -e $cache ]; then
exit 0
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
- ) 200>/var/lock/subsys/lxc
+ ) 200>@LOCALSTATEDIR@/lock/subsys/lxc
}
usage()
# determine the url, tarball, and directory names
# download if needed
-cache="/var/cache/lxc/cloud-$release"
+cache="@LOCALSTATEDIR@/cache/lxc/cloud-$release"
mkdir -p $cache
trap SIGTERM
}
-mkdir -p /var/lock/subsys/
+mkdir -p @LOCALSTATEDIR@/lock/subsys/
(
flock -x 200
echo "If you do not have a meta-data service, this container will likely be useless."
fi
-) 200>/var/lock/subsys/lxc-ubucloud
+) 200>@LOCALSTATEDIR@/lock/subsys/lxc-ubucloud
copy_configuration $path $rootfs $name $arch $release