1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-12-16 11:43:21 +03:00
mobile-nixos/boot/init/main.rb

59 lines
1.4 KiB
Ruby
Raw Normal View History

2019-12-21 08:38:27 +03:00
def pp(x)
puts(x.inspect)
end
def prepare_environment()
rules = File.read("/etc/udev/rules.d/00-env.rules").strip.split("\n")
rules.each do |r|
name, value = r.split("=", 2)
name = name.match(/^ENV{(.*)}$/)[1]
value = value.sub(/^"/, "").sub(/"$/, "")
ENV[name] = value
end
end
def prepare_mounts()
# FIXME : porcelain around mkdir and mount
system("mkdir", "-p", "/proc", "/sys", "/dev")
system("mount", "-t", "devtmpfs", "devtmpfs", "/dev")
system("mount", "-t", "proc", "proc", "/proc")
system("mount", "-t", "sysfs", "sysfs", "/sys")
end
def prepare_framebuffer()
# [ -e "/sys/class/graphics/fb0/modes" ] || return
# [ -z "$(cat /sys/class/graphics/fb0/mode)" ] || return
# _mode="$(cat /sys/class/graphics/fb0/modes)"
# echo "Setting framebuffer mode to: $_mode"
# echo "$_mode" > /sys/class/graphics/fb0/mode
mode = File.read("/sys/class/graphics/fb0/modes")
puts "Setting framebuffer mode to: #{mode}"
File.open("/sys/class/graphics/fb0/mode", "w") do |f|
f.write(mode)
end
end
prepare_environment
puts "----"
puts "Environment:"
pp ENV
puts "----"
prepare_mounts
system("ls", "-l", "/sys")
system("ls", "-l", "/sys/class")
system("ls", "-l", "/sys/class/graphics")
system("ls", "-l", "/sys/class/graphics/fb0")
system("ls", "-l", "/sys/class/graphics/fb0/modes")
prepare_framebuffer
system("ply-image", "/splash.stage-0.png")
while true do
puts("Hello from this init!")
sleep(1)
end