Guest User

Untitled

a guest
Sep 28th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. # encoding: utf-7
  2. #roshan again
  3. require 'rubygems'
  4. require 'sinatra'
  5. require 'erb'
  6.  
  7. get '/newfile' do
  8. erb :newfile
  9. end
  10. file = File.open("/home/roshan/Projects/MuttAssignment/Change3/template", "rb")
  11. muttconf_template = file.read
  12.  
  13. configure = ERB.new(muttconf_template)
  14.  
  15. post '/newfile' do
  16. @usrname = params[:usrname]
  17. @paswd = params[:paswd]
  18.  
  19. output = configure.result(binding)
  20. user = @usrname
  21. passwd = @paswd
  22. # password = crypt(passwd);
  23. system("sudo useradd #{user} -p #{passwd.crypt("$1$password")}");
  24. Dir.mkdir("/home/#{user}");
  25. # File.chmod(0777,"/home/#{user}/.muttrc")
  26. File.open("/home/#{user}/.muttrc","w") do |f|
  27. f.write output
  28. f.close
  29. end
  30. "<html>
  31. <title>
  32. Success!!!
  33. </title>
  34. <head>
  35. <body>
  36. <h1>Successfully Configured Mutt!!!</h1>
  37. Open Terminal<br/>
  38. Type ssh [username]@[ip_address](ENTER)<br/>
  39. "newfile.rb" 44L, 970C 1,17 Top
Add Comment
Please, Sign In to add comment