local t = require "../utils/templater" local dirs = {} local function generate_mount_data() local string = "#!/bin/sh\n" for i=1,#dirs do local dir = dirs[i] if dir.type == "file" then touch(dir.mountpoint) string = string .. t([[ touch -a '{{path}}' || exit 1 mount '{{path}}' '{{mountpoint}}' -o bind,umask=100,uid={{uid}},gid={{gid}} || exit 1 ]], dir ) elseif dir.type == "dir" then mkdir(dir.mountpoint) string = string .. t([[ mkdir -p '{{path}}' || exit 1 mount '{{path}}' '{{mountpoint}}' -o bind,umask=100,uid={{uid}},gid={{gid}} || exit 1 ]], dir ) end end add_file("/usr/local/bin/mount-data", string) chmod("/usr/local/bin/mount-data", 700) end local function add_data_dir(path, mountpoint, uid, gid) table.insert(dirs, { type = "dir", path = path, mountpoint = mountpoint, uid = uid, gid = gid }) generate_mount_data() end local function add_data_file(path, mountpoint, uid, gid) table.insert(dirs, { type = "file", path = path, mountpoint = mountpoint, uid = uid, gid = gid }) generate_mount_data() end modules.data = { add_data_dir = add_data_dir, add_data_file = add_data_file, } mkdir("/data") -- XXX: hardcodeado modules.fstab.add_mount("/dev/sdb /data ext4 defaults 0 0")