Modularizar fstab
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Cat /dev/Nulo 2022-06-17 23:34:30 -03:00
parent 4533a6c3bf
commit 4b071f0253
3 changed files with 15 additions and 9 deletions

13
modules/fstab.lua Normal file
View file

@ -0,0 +1,13 @@
local utils = require "../utils"
local mounts = {
"tmpfs /tmp tmpfs defaults 0 0",
}
local function add_mount(mount)
table.insert(mounts, mount)
add_file("/etc/fstab", utils.join_table(mounts, "\n"))
end
modules.fstab = {
add_mount = add_mount,
}

View file

@ -23,7 +23,7 @@ modules.runit = {
add_service = add_service, add_service = add_service,
} }
add_mount("tmpfs /var/log tmpfs defaults 0 0") modules.fstab.add_mount("tmpfs /var/log tmpfs defaults 0 0")
-- Estos scripts fueron robados de Void Linux -- Estos scripts fueron robados de Void Linux
add_executable("/etc/runit/functions", [[ add_executable("/etc/runit/functions", [[

View file

@ -10,9 +10,6 @@ local packages = {
"libc-utils", "libc-utils",
"alpine-keys", "alpine-keys",
} }
local mounts = {
"tmpfs /tmp tmpfs defaults 0 0",
}
modules = {} modules = {}
local root = "./root" local root = "./root"
@ -20,9 +17,6 @@ local root = "./root"
function add_packages(new_packages) function add_packages(new_packages)
utils.table_concat(packages, new_packages) utils.table_concat(packages, new_packages)
end end
function add_mount(new_mount)
table.insert(mounts, new_mount)
end
function add_file(path, content) function add_file(path, content)
utils.expect_nil(alpine.write_file(root, path, content)) utils.expect_nil(alpine.write_file(root, path, content))
end end
@ -43,13 +37,12 @@ local function module(name)
print("=> Module: " .. name) print("=> Module: " .. name)
require("modules/" .. name) require("modules/" .. name)
end end
module "fstab"
module "kernel" module "kernel"
module "runit" module "runit"
module "hostname" module "hostname"
module "dhcpcd" module "dhcpcd"
print("=> Writing fstab...")
add_file("/etc/fstab", utils.join_table(mounts, "\n"))
print("=> Installing and upgrading packages...") print("=> Installing and upgrading packages...")
utils.expect_nil(alpine.make_world(root, packages)) utils.expect_nil(alpine.make_world(root, packages))
print("=> Setting password...") print("=> Setting password...")