Created
February 27, 2014 06:10
-
-
Save bryanjswift/9245254 to your computer and use it in GitHub Desktop.
Process STDIN containing DB row sets from a command selecting email address and password hash. Used in pipeline like `ssh {{ main_user_name }}@{{ domain }} 'PGPASSWORD={{ mail_db_password }} psql -U {{ mail_db_username }} -h 127.0.0.1 --command="SELECT email, password FROM virtual_users;" {{ mail_db_database }}' | grep '\$6\$' | ./mail_virtual_u…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'yaml' | |
# Part of command to sync down hashed user passwords | |
accounts = [] | |
$stdin.each_line do |line| | |
email = line.split('|')[0].gsub(/\s+/, '') | |
hash = line.split('|')[1].gsub(/\s+/, '') | |
accounts << { | |
'account' => email.split('@')[0], | |
'domain' => email.split('@')[1], | |
'password_hash' => hash, | |
'domain_pk_id' => 1, | |
} | |
end | |
mail_virtual_users = { 'mail_virtual_users' => accounts } | |
$stdout.puts mail_virtual_users.to_yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment