summaryrefslogtreecommitdiff
path: root/btrfs-receive-root.sh
diff options
context:
space:
mode:
Diffstat (limited to 'btrfs-receive-root.sh')
-rw-r--r--btrfs-receive-root.sh55
1 files changed, 0 insertions, 55 deletions
diff --git a/btrfs-receive-root.sh b/btrfs-receive-root.sh
deleted file mode 100644
index f553c2c..0000000
--- a/btrfs-receive-root.sh
+++ /dev/null
@@ -1,55 +0,0 @@
1#!/bin/sh
2
3. sami/btrfs-functions.sh
4. sami/var.sh
5
6disable_stdout() { exec 3>&1; exec >&2; }
7enable_stdout() { exec >&3; }
8
9with_stdout() { enable_stdout; "$@"; disable_stdout; }
10
11create_layer_filesystem()
12{
13 [ ! -e "$layer_file" ] || return
14 ! mountpoint "$mountpoint" || return
15 mkdir -p "$mountpoint" &&
16 sex dd if=/dev/zero of="$layer_file" bs=1M count="$layer_size" &&
17 sex mount -o subvol=/,compress "$seed_file" "$mountpoint" &&
18 layer_dev=$(losetup -f --show "$layer_file") &&
19 sex btrfs device add "$layer_dev" "$mountpoint" &&
20 mount -o rw,remount "$mountpoint"
21}
22
23finish()
24{
25 local subv_id
26 sex mv "$mountpoint"/ROOT "$mountpoint"/ROOT.old || return
27 sex btrfs subvolume snapshot "$mountpoint"/"$receive_subv" "$mountpoint"/ROOT || return
28 subv_id=$(btrfs_show_subvolume_id "$mountpoint"/ROOT) || return
29 sex btrfs subvolume set-default "$subv_id" "$mountpoint" || return
30 sex btrfs subvolume delete "$mountpoint"/ROOT.old || return
31 umount "$mountpoint" || return
32 sex btrfstune -S1 "$layer_file" || return
33 losetup -d "$layer_dev"
34}
35
36set -e
37disable_stdout
38
39receive_dest=$1
40receive_subv=$2
41
42[ "$receive_subv" ]
43[ "$receive_dest" ]
44
45mountpoint=$(realpath -m --relative-base=. "$receive_dest")
46
47seed_file=sami/debian-live-8.4.0-amd64-standard.btrfs
48layer_file_FINAL=sami/debian-live-8.4.0-amd64-standard.layer.$receive_subv.btrfs
49layer_file=$layer_file_FINAL.part
50layer_size=1000
51
52create_layer_filesystem
53with_stdout sex btrfs receive "$mountpoint"
54finish
55mv "$layer_file" "$layer_file_FINAL"