Advertisement
DOGGYWOOF

Doggy OS first admin user setup

Feb 24th, 2024 (edited)
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. -- WARNING: Use this script at your own risk.
  2. -- Ensure you have a backup before running it.
  3.  
  4. -- Doggy OS First Admin Account Setup Script
  5.  
  6. -- Function to delete all directories in /disk/users/ except "root"
  7. local function deleteDirectories()
  8. local usersPath = "/disk/users/"
  9.  
  10. -- Get a list of all directories
  11. local directories = fs.list(usersPath)
  12.  
  13. term.clear()
  14. term.setCursorPos(1, 1)
  15.  
  16. term.setTextColor(colors.red)
  17. print("Welcome to Doggy OS\n")
  18. term.setTextColor(colors.white)
  19.  
  20. print("Deleting unnecessary directories...\n")
  21.  
  22. for _, dir in pairs(directories) do
  23. if dir ~= "root" then
  24. fs.delete(usersPath .. dir)
  25. end
  26. end
  27.  
  28. print("\nDeletion completed.")
  29. end
  30.  
  31. -- Function to create /disk/users/ directory
  32. local function createUsersDirectory()
  33. local usersPath = "/disk/users/"
  34.  
  35. -- Recreate /disk/users/ directory
  36. fs.makeDir(usersPath)
  37.  
  38. print("\nCreated /disk/users/ directory.")
  39. end
  40.  
  41. -- Function to set up the first admin account
  42. local function setupFirstAdminAccount()
  43. term.clear()
  44. term.setCursorPos(1, 1)
  45.  
  46. term.setTextColor(colors.green)
  47. print("Doggy OS First Admin Account Setup\n")
  48. term.setTextColor(colors.white)
  49.  
  50. print("Enter your desired Admin username:")
  51. local username = read()
  52.  
  53. print("\nEnter a secure password for \"" .. username .. "\":")
  54. local password = read("*")
  55.  
  56. local userPath = "/disk/users/" .. username
  57.  
  58. -- Create user directory
  59. fs.makeDir(userPath)
  60.  
  61. -- Store password in a file
  62. local passwordFile = fs.open(userPath .. "/password.txt", "w")
  63. passwordFile.write(password)
  64. passwordFile.close()
  65.  
  66. -- Create admin.txt file
  67. local adminFile = fs.open(userPath .. "/admin.txt", "w")
  68. adminFile.close()
  69.  
  70. term.clear()
  71. term.setCursorPos(1, 1)
  72.  
  73. term.setTextColor(colors.yellow)
  74. print("Setting up first Admin account...\n")
  75. term.setTextColor(colors.white)
  76.  
  77. os.sleep(5)
  78. end
  79.  
  80. -- Main program
  81. deleteDirectories()
  82. createUsersDirectory()
  83. setupFirstAdminAccount()
  84.  
  85. -- Run /disk/boot/error instead of /disk/boot/BIOS
  86. term.clear()
  87. term.setCursorPos(1, 1)
  88.  
  89. term.setTextColor(colors.blue)
  90. print("Running Doggy OS...\n")
  91. term.setTextColor(colors.white)
  92. shell.run("/disk/boot/error")
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement