Fily system type is not necessarily located in the column number 9.
But look like we can rely on " - " pattern: it's always located immediately
after dash.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Unfortunatelly, autofs doesn't allow to discover it's type. At least without
accessing master process. That means, that stat can be used to determine
whether some other file system is mounted on top of autofs (which we need to
take a decision whether to move restore fs aside or not), because it simply
stuck.
This patch does fs type discovering by parsing CTs mountinfo.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This patch slightly changes the logic on systemd autofs service restart script:
1) It tries to bind-mount the mountpoint on top of autofs (if any) somewhere
before service restart, and replace new mount point on top of autofs (if any)
by the saved one after.
2) It doesn't exit in case of error, trying to recover as much as
possible in case of failure instead and then continue services restarting.
The reason for introducing new logic is that there can be some other,
stateful, file system on top of autofs (say, tmpfs), which state was restore
during migration.
With current script this state will be lost, while this patch allows to
preserve restored mount point after service restart.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Without correct pid namespace systemctl is not able to determine whether
autofs is active or not.
The reason is unaccessible proc due to mount namespace change without pid
namespace change.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This script restarts systemd autofs services to workaround a problem, when
systemd doesn't consider autofs mount as own after restore (alien device ID
problem)
v4:
Environment variable NS_PID was renamed to CRTOOLS_INIT_PID
v2:
1) Added different checks: for process with pid, active service, systemd based
container.
Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>