Closed fmadio closed 5 years ago
added as
/mnt/store0/etc/network.boot /mnt/store0/etc/disk.boot
Both run if they exists before network is configured, or disks are mounted
Example network configuration script running on FMAD20v2
print("network boot script")
-- remove any previous config
os.execute("rm /mnt/store0/etc/network.lua")
-- get MAC of the system
local f = io.open("/sys/devices/pci0000:00/0000:00:02.2/0000:04:00.0/net/phy0/address", "r")
local MAC = f:read("*line")
f:close()
-- set network configuration based on MAC address
print("Found MAC["..tostring(MAC).."]")
if (MAC == "00:24:ec:f1:49:91") then
print("Matching Config 0\n")
os.execute("ln -s /mnt/store0/etc/network_0.lua /mnt/store0/etc/network.lua")
end
Example disk.boot script. script is called after drivers have been loaded and disk enumerated
fmadio@fmadio80v1-095:/mnt/store0/etc$ cat disk.boot
--
-- NOTE: this is run *AFTER* any HBA and RAID drivers are loaded
-- drives should have been enumerated or in the process of being enumerated
function string:split( inSplitPattern, outResults )
if not outResults then
outResults = { }
end
local theStart = 1
local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
while theSplitStart do
table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
theStart = theSplitEnd + 1
theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
end
table.insert( outResults, string.sub( self, theStart ) )
return outResults
end
print("boot disk script")
local f = io.popen("lsblk | grep -v loop | grep disk", "r")
for l in f:lines() do
local s = l:split("%s")
--for a,b in ipairs(s) do print(a,b) end
local Drive = s[1]
-- run smartctl on all drives
print(Drive)
os.execute("sudo /usr/local/sbin/smartctl -a /dev/"..Drive.."")
end
f:close()
-- select a disk mapping
os.execute("rm /mnt/store0/etc/disk.lua")
os.execute("ln -s /mnt/store0/etc/disk_0.lua /mnt/store0/etc/disk.lua")
closing
optional pre-boot script that can set disk and network configuration files