Allow using a different data path for container setup

This commit is contained in:
Simon Fels 2017-01-26 07:35:46 +01:00
commit e0091c764b
3 changed files with 15 additions and 3 deletions

View file

@ -6,7 +6,7 @@ set -x
# Other than that nothing should ever modify the content of the
# rootfs.
DATA_PATH=$SNAP_COMMON/var/lib/anbox
DATA_PATH=$SNAP_COMMON/
ROOTFS_PATH=$DATA_PATH/rootfs
ANDROID_IMG=$SNAP/android.img
CONTAINER_BASE_UID=100000
@ -62,7 +62,7 @@ start() {
# Ensure FUSE support for user namespaces is enabled
echo Y | sudo tee /sys/module/fuse/parameters/userns_mounts || echo "WARNING: kernel doesn't support fuse in user namespaces"
exec $SNAP/usr/sbin/aa-exec -p unconfined -- $SNAP/bin/anbox-wrapper.sh container-manager
exec $SNAP/usr/sbin/aa-exec -p unconfined -- $SNAP/bin/anbox-wrapper.sh container-manager --data-path=$DATA_PATH
}
stop() {

View file

@ -19,6 +19,7 @@
#include "anbox/container/service.h"
#include "anbox/logger.h"
#include "anbox/runtime.h"
#include "anbox/config.h"
#include "core/posix/signal.h"
@ -26,7 +27,12 @@ anbox::cmds::ContainerManager::ContainerManager()
: CommandWithFlagsAndAction{
cli::Name{"container-manager"}, cli::Usage{"container-manager"},
cli::Description{"Start the container manager service"}} {
action([](const cli::Command::Context&) {
flag(cli::make_flag(cli::Name{"data-path"},
cli::Description{"Path where the container and its data is stored"},
data_path_));
action([&](const cli::Command::Context&) {
auto trap = core::posix::trap_signals_for_process(
{core::posix::Signal::sig_term, core::posix::Signal::sig_int});
trap->signal_raised().connect([trap](const core::posix::Signal& signal) {
@ -34,6 +40,9 @@ anbox::cmds::ContainerManager::ContainerManager()
trap->stop();
});
if (!data_path_.empty())
SystemConfiguration::instance().set_data_path(data_path_);
auto rt = Runtime::create();
auto service = container::Service::create(rt);

View file

@ -29,6 +29,9 @@ namespace cmds {
class ContainerManager : public cli::CommandWithFlagsAndAction {
public:
ContainerManager();
private:
std::string data_path_;
};
} // namespace cmds
} // namespace anbox