Guest User

Untitled

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