Update lxc-archlinux template to work with systemd

Use arch-install-scripts for installation.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-netstat: improve finding fs mountpoint of hierarchy

We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
legacy/lxc-ls: improve finding fs mountpoint of hierarchy

We cannot assume that the mount source name always starts with 'cgroup'
so we check the filesystem type instead.

Use 'awk' instead of 'grep -E' and  as it is a better tool for this job.

This fixes the tool on systems using openrc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
cleanup: use lxc-info --state-is

We now have the possibility to test for a given state. Use this feature
instead of parsing output with grep or awk

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
fix open check (0 is a valid fd)

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-shutdown: use posix shell instead of bash

- avoid getopt --longoptions
- use 'which' instead of 'type' to detect existance of tools
- specify -s SIG<signame> with kill

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-ps: use posix shell and awk instead of bash

Use awk to parse the output pf 'ps' and the tasks files for the
containers.

Use awk fields to find PID column rather than assume that the PID field
is exactly 5 chars wide and has a leading space ' PID'. This works as
long as the PID field is before the command or other field that include
spaces. This also makes it work with busybox 'ps'.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
templates: install lxc-alpine

Make sure we actually install lxc-alpine

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-alpine: indent fixes

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-alpine: add --repository option

This allows specifying what repository to use for the container.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-alpine: add support for setting arch from command line

This allows us to lxc-create 32 bit guests on x86_64 hosts.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
lxc-alpine: add support for installing optional packages

Let users append a list of packages they want install in the container

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
kill -s expects the signal name without SIG

The previous lxc-shutdown change replaced 'kill SIG<name>' by
'kill -s SIG<name>'. Although this works with busybox where it was tested,
this doesn't actually work with all kill implementations. Some requiring just
the signal name without the prefix.

This changes "-s SIG<name>" by just "-s <name>". Tested with busybox and
standard kill.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
separate console device from console log

lxc-start -c makes the named file/device the container's console, but using
this with a regular file in order to get a log of the console output does
not work very well if you also want to login on the console. This change
implements an additional option (-L) to simply log the console's output to
a file.

Both options can be used separately or together. For example to get a usable
console and log: lxc-start -n name -c /dev/tty8 -L console.log

The console state is cleaned up more when lxc_delete_console is called, and
some of the clean up paths in lxc_create_console were fixed.

The lxc_priv and lxc_unpriv macros were modified to make use of gcc's local
label feature so they can be expanded more than once in the same function.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
configure.ac: Add code to detect bionic C library

This adds a new IS_BIONIC define that can be used to detect whether we are
building with eglibc or with bionic.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
configure.ac: Cleanup, comments, indent, ...

This commit doesn't do any functional change to configure.ac but does a fair
amount of cleaning up.

It re-orders the various blocks by type (options, checks, expands, ...).
It also consistently uses tabs for indents and moves all user visible strings
between double-quotes (makes my syntax highlighter much happier).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Replace all reference to ushort by unsigned short

ushort appears to be a glibc specific type which doesn't exist in
bionic, this commit simply replace all occurences by the equivalent
unsigned short type.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Support both getline and fgetln

Some libc implementations don't have the getline function but instead
have an equivalent fgetln function.

Add code to detect both and use whatever is available.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
No need to link against rt and util on bionic

When building on bionic, -lrt and -lutil only cause a build failure.
Dropping those fixes the build, so it appears that the symbols are defined
in the main library.

This commit moves -lrt and -lutil under a !IS_BIONIC check.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Replace get_current_dir_name by getcwd

get_current_dir_name appears to be specific to glibc. Replace that call
by an equivalent getcwd call.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>