34 | | * I'll restart mysql on myboss without that argument, then I'll investigate secure remote access. |
| 34 | * I'll restart mysql on myboss without that argument, then I'll investigate secure remote access. |
| 35 | * edited {{{/usr/local/etc/rc.d/2.mysql-server.sh}}} |
| 36 | * killed mysql (mysqld_watchdog should restart it.) |
| 37 | * sudo kill 97362 97535 ; tail -F mysqld_watchdog.log |
| 38 | * seems to have worked. |
| 39 | * I can now connect remotely using mysql client: {{{mysql -h myboss -P 3306}}}. So yay! We'll need to secure the connection somehow though inthe future. Back to script testing. |
| 40 | * running test ruby script. Runs to error (yay!) after making sure the paths are correct. |
| 41 | d. Connect to database and print account information as test of mysql code. After that put it in a recipe and try it on the test nodes. |
| 42 | * OK! I can query for account information from a test node. The test script is: |
| 43 | {{{ |
| 44 | #!ruby |
| 45 | #!/usr/bin/env ruby |
| 46 | |
| 47 | require 'rubygems' |
| 48 | require 'mysql2' |
| 49 | |
| 50 | client = Mysql2::Client.new(:host => "myboss", :username => "mysql", :database => "tbdb") |
| 51 | |
| 52 | stmt = "select distinct " |
| 53 | stmt << " u.uid,u.usr_pswd,u.unix_uid,u.usr_name, " |
| 54 | stmt << " p.trust,g.pid,g.gid,g.unix_gid,u.admin, " |
| 55 | stmt << " u.emulab_pubkey,u.home_pubkey, " |
| 56 | stmt << " UNIX_TIMESTAMP(u.usr_modified), " |
| 57 | stmt << " u.usr_email,u.usr_shell, " |
| 58 | stmt << " u.widearearoot,u.wideareajailroot, " |
| 59 | stmt << " u.usr_w_pswd,u.uid_idx " |
| 60 | stmt << "from group_membership as p " |
| 61 | stmt << "join users as u on p.uid_idx=u.uid_idx " |
| 62 | stmt << "join groups as g on " |
| 63 | stmt << " p.pid=g.pid and p.gid=g.gid " |
| 64 | stmt << "where ((p.pid='Deter')) and p.trust!='none' " |
| 65 | stmt << " and u.status='active' " |
| 66 | stmt << " and u.webonly=0 " |
| 67 | stmt << " and g.unix_gid is not NULL " |
| 68 | stmt << "order by u.uid limit 2" |
| 69 | |
| 70 | results = client.query(stmt) |
| 71 | results.each do |row| |
| 72 | printf "%s\n", row |
| 73 | end |
| 74 | }}} |
| 75 | |
| 76 | This outputs: |
| 77 | {{{ |
| 78 | #!sh |
| 79 | ./mysql_test.rb |
| 80 | {"uid"=>"adititat", "usr_pswd"=>"$1$13954353$MRXeRMUxPc2t4hxFe7o3k0", "unix_uid"=>14427, "usr_name"=>"Aditi Tatti", "trust"=>"local_root", "pid"=>"Deter", "gid"=>"Deter", "unix_gid"=>6004, "admin"=>0, "emulab_pubkey"=>nil, "home_pubkey"=>nil, "UNIX_TIMESTAMP(u.usr_modified)"=>1398879458, "usr_email"=>"tatti@usc.edu", "usr_shell"=>"bash", "widearearoot"=>0, "wideareajailroot"=>0, "usr_w_pswd"=>"03b%5m*g", "uid_idx"=>14536} |
| 81 | {"uid"=>"alba", "usr_pswd"=>"$1$12831943$YeNdFr60Aj79NiddzObMQ/", "unix_uid"=>11615, "usr_name"=>"Alba Palacios", "trust"=>"local_root", "pid"=>"Deter", "gid"=>"Deter", "unix_gid"=>6004, "admin"=>1, "emulab_pubkey"=>nil, "home_pubkey"=>nil, "UNIX_TIMESTAMP(u.usr_modified)"=>1398879433, "usr_email"=>"alba@isi.edu", "usr_shell"=>"tcsh", "widearearoot"=>0, "wideareajailroot"=>0, "usr_w_pswd"=>"%!<0fsKo", "uid_idx"=>11681} |
| 82 | }}} |
| 83 | |
| 84 | e. So now all I need to do is learn Ruby. |