Add local and chroot backends.
[matthijs/upstream/backupninja.git] / lib / backends / chroot.in
1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2 # vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
3
4 getconf CHROOT "`which chroot`"
5
6 function backend_chroot_init () {
7         # Is the changeroot command available?
8     [ -x "$CHROOT" ]
9 }
10
11 function backend_chroot_host_available () {
12    if [ -d "$1" ]; then
13       # The root exists and is a directory, everything ok
14       return 0
15    else
16       if [ ! -e "$1" ]; then
17          # The root does not exist?
18          eval "$2=\"No such file or directory: '\$1'\""
19       else
20          # The root exists, so is not a directory
21          eval "$2=\"Not a directory: '\$1'\""
22       fi
23       return 1
24    fi
25 }
26
27 function backend_chroot_host_root () {
28    # The host part is the root, but strip any trailing slashes
29    echo "$1" | sed 's/\/*$//'
30 }
31
32 function backend_chroot_run () {
33    # Run the command using the chroot command
34    "$CHROOT" "$root" "$@"
35 }
36
37 function backend_chroot_interpolate_vars () {
38    echo ""
39 }
40
41 function backend_chroot_interpolate_value () {
42 }