-- minux main api's
-- recursive listing
function lsr(searchpath) os.run({}, "/etc/minux-main/ls/ls.sys" , searchpath) end
-- login system
function login(login, password) os.run({}, "/bin/login.sh" , login , password) end
function logintype()
	if fs.exists("/etc/auth.cfg") then
		file = fs.open("/etc/auth.cfg" , "r")
		authtype = file.readLine()
		file.close()
	else
		authtype = "disabled"
	end
	return authtype
end
function lock()
	if logintype() ~= "disabled" then
		term.clear()
		term.setCursorPos(1,1)
		print("Minux V:".._G.version)
		print(" ")
		print("This system is currently locked by user:".._G.login)
		local lockactive = true
			while lockactive == true do 
			write("Enter password to unlock:")
			input = read("*")
			if input == _G.masterpass then lockactive = false 
			else print("Wrong password") end
		end
	else
		print("cannot enable lock with users disabled")
		print("hit enter to continue")
		read()
	end
end
-- minux monitorprint
function monitorprint(printstring) os.run({}, "/etc/minux-main/sys/monitorprint.sys" , printstring) end
-- minux configuration
function config(setting, value)
	if setting == "get" and value ~= nil then
		if value == "login" then
			local tempfile = fs.open("/etc/auth.cfg","r")
			local tempdata = tempfile.readLine()
			tempfile.close()
			return tempdata
		elseif value == "ui" then
			local tempfile = fs.open("/usr/minux-main/menu.cfg","r")
			local tempdata = tempfile.readLine()
			tempfile.close()
			return tempdata
		elseif value == "debug" then
			local tempfile = fs.open("/usr/minux-main/debug.cfg","r")
			local tempdata = tempfile.readLine()
			tempfile.close()
			return tempdata
		elseif value == "update" then
			if fs.exists("/usr/apt/update.cfg") == true then
				tempfile = fs.open("/usr/apt/update.cfg","r")
				tempdata = tempfile.readLine()
				tempfile.close()
			else
				tempdata = "disabled"
			end
			return tempdata
		else
			print("invalid data")
			return 0
		end
	else
		os.run({}, "/etc/minux-main/sys/config.sys" , setting, value)
	end
end
--minux halt and restart
function halt() os.run({}, "/bin/halt.sh") end
function restart() os.run({}, "/bin/restart.sh") end
-- minux logging
function debug(printstring, programname) os.run({},"/etc/minux-main/sys/debug.sys" , printstring, programname) end