Advertisement
DOGGYWOOF

Firmware Installer

Apr 1st, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. -- Doggy OS Developer Firmware Installer
  2.  
  3. -- Function to install custom bootloader
  4. local function installCustomBootloader()
  5. print("Enter the path to the custom bootloader file:")
  6. local bootloaderFile = read()
  7.  
  8. print("Enter the directory to install the bootloader:")
  9. local directory = read()
  10.  
  11. -- Check if file and directory exist
  12. if fs.exists(bootloaderFile) and fs.isDir(directory) then
  13. -- Replace the startup program
  14. local startupFile = fs.combine(directory, "startup")
  15. local handle, err = fs.open(startupFile, "w")
  16. if not handle then
  17. print("Error: " .. err)
  18. return
  19. end
  20.  
  21. handle.writeLine('shell.run("/disk/boot/check-recovery")')
  22. handle.writeLine('shell.run("no-os")')
  23. handle.writeLine('print("Unknown Bootloader")')
  24. handle.close()
  25.  
  26. print("Custom bootloader installed successfully.")
  27. else
  28. print("Error: File or directory not found.")
  29. end
  30. end
  31.  
  32. -- Function to install custom recovery
  33. local function installCustomRecovery()
  34. print("Enter the path to the custom recovery file:")
  35. local recoveryFile = read()
  36.  
  37. -- Check if file exists
  38. if fs.exists(recoveryFile) then
  39. -- Replace the Recovery.lua file
  40. fs.copy(recoveryFile, "/disk/boot/Recovery.lua")
  41. print("Custom recovery installed successfully.")
  42. else
  43. print("Error: File not found.")
  44. end
  45. end
  46.  
  47. -- Function to install custom boot error message
  48. local function installCustomBootErrorMessage()
  49. print("Enter the path to the custom boot error message file:")
  50. local errorMessageFile = read()
  51.  
  52. -- Check if file exists
  53. if fs.exists(errorMessageFile) then
  54. -- Read the content of the file to check for security risk
  55. local handle = fs.open(errorMessageFile, "r")
  56. local content = handle.readAll()
  57. handle.close()
  58.  
  59. -- Check if the content contains security risk
  60. if content:find("read()") and content:find("os.reboot") then
  61. print("Are you sure you want to replace Boot error message with this program?")
  62. print("It is unsecure and is a security risk. Please choose another program or proceed with caution.")
  63. print("Proceed with caution? (yes/no)")
  64. local choice = read()
  65.  
  66. if choice == "yes" then
  67. -- Replace the no-os read() function with the custom error message
  68. fs.copy(errorMessageFile, "/disk/no-os")
  69. print("Custom boot error message installed successfully.")
  70. else
  71. print("Installation cancelled.")
  72. end
  73. else
  74. print("Error: The provided file does not meet the security requirements.")
  75. end
  76. else
  77. print("Error: File not found.")
  78. end
  79. end
  80.  
  81. -- Main function
  82. local function main()
  83. print("Welcome to Doggy OS Developer Firmware Installer")
  84. print("1. Install Custom Bootloader")
  85. print("2. Install Custom Recovery")
  86. print("3. Install Custom Boot Error Message")
  87. print("4. Exit")
  88.  
  89. local choice = tonumber(read())
  90. if choice == 1 then
  91. installCustomBootloader()
  92. elseif choice == 2 then
  93. installCustomRecovery()
  94. elseif choice == 3 then
  95. installCustomBootErrorMessage()
  96. elseif choice == 4 then
  97. print("Exiting...")
  98. os.reboot()
  99. else
  100. print("Invalid choice.")
  101. end
  102. end
  103.  
  104. -- Run the main function
  105. main()
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement