#!/bin/sh

set -e
set -x

cat >/etc/rozofs/storage.conf <<END
listen = (
    {addr = "127.0.0.1"; port = 41001; }
);

storages = (
    {cid = 1; sid = 1; root = "/srv/rozofs/c1_s1"; device-total = 6; device-mapper = 3; device-redundancy = 3;}
);
END

mkdir -p /srv/rozofs/c1_s1
systemctl restart rozofs-storaged.service

cat >/etc/rozofs/exportd.conf <<END
layout = 0; # Default layout 

volumes =   # List of volumes
(
    {
        # First volume using default layout
        vid    = 1; # Volume identifier
        cids=       # List of clusters of the volume
        (
            {
                # First cluster of the volume
                cid = 1; # Cluster identifier
                sids =   # List of storages of the cluster
                (
                    {sid = 1; host = "localhost";}
                );
            }
        );
    }
);

filters = ();

exports = ( # List of exported filesystem
    # exported file systems on volume 1
    {eid = 1; bsize="4K"; root = "/srv/rozofs/e1"; vid=1;}
);
END

mkdir -p /srv/rozofs/e1
systemctl restart rozofs-exportd.service

# Mount the filesystem
rozofsmount -H 127.0.0.1 -E /srv/rozofs/e1 /mnt

# Ensure it's a mount point
mountpoint /mnt

