Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server program
- local function registerDomain(domain)
- local file = fs.open("Domain", "w")
- file.writeLine("Domain Name: " .. domain)
- file.writeLine("Server ID: " .. os.computerID())
- file.close()
- print("Domain registered successfully.")
- shell.run("server")
- end
- local function createUser(username, password)
- local userDir = "/disk/users/" .. username
- fs.makeDir(userDir)
- local passwordFile = fs.open(userDir .. "/password.txt", "w")
- passwordFile.write(password)
- passwordFile.close()
- print("User created successfully.")
- shell.run("server")
- end
- local function deleteUser(username)
- local userDir = "/disk/users/" .. username
- fs.delete(userDir)
- print("User deleted successfully.")
- shell.run("server")
- end
- -- Main program
- while true do
- print("1. Register Domain")
- print("2. Create User")
- print("3. Delete User")
- print("4. Run Server (press Enter to go back to menu)")
- local option = tonumber(read())
- if option == 1 then
- print("Enter Domain Name:")
- local domain = read()
- registerDomain(domain)
- elseif option == 2 then
- print("Enter Username:")
- local username = read()
- print("Enter Password:")
- local password = read("*")
- createUser(username, password)
- elseif option == 3 then
- print("Enter Username to Delete:")
- local username = read()
- deleteUser(username)
- elseif option == 4 then
- shell.run("server")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement