add parameters for answerback-email -e,--email email_address: add email address -s,--ssh-pubkey pub_key_file: add a ssh login pub_key -f,--raw-email email_file: add email address[, pub_key] via email file
Usage: ruby answerback-email.rb -e email_address [-s pub_key_file] ruby answerback-email.rb -f email_file
why: easier for administrator to manully assign jumper account for user with the parameters
Signed-off-by: Luan Shengde luanshengde2@huawei.com --- container/assign-account/answerback-email.rb | 179 ++++++++----------- 1 file changed, 77 insertions(+), 102 deletions(-)
diff --git a/container/assign-account/answerback-email.rb b/container/assign-account/answerback-email.rb index b5283ba..a3108cb 100755 --- a/container/assign-account/answerback-email.rb +++ b/container/assign-account/answerback-email.rb @@ -3,74 +3,90 @@ # Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. # frozen_string_literal: true
-=begin - -repo_list: - all repos url list from upstream-repos.git - -API: -call graph: -read_mail_content -send_account_request - email_addr - get email address - email_message_id - get email message_id - check_email_available - check email available - pub_key_value - get pub key - account - send apply account request and return account info - build_message - build email message - send_mail - call send_mail to send mail whit build message - -the returned data for account_info like: -{ - "account" => "guest", - "passwd" => "Use pub_key to login", - "jumper_ip" => "10.10.10.10", - "jumper_port" => "10000" -} -=end +# xx --email xxx --login --ssh-pubkey xxx --raw-email email-file +# samba mount +# ssh logshn (huawei, ) (install pubkey / send password)
require 'json' require 'mail' require 'set' -require_relative '../defconfig.rb' +require 'optparse' +require_relative '../defconfig'
names = Set.new %w[ - JUMPER_IP + JUMPER_HOST JUMPER_PORT - CRYSTAL_INTRANET - SEND_MAIL_PORT + SEND_MAIL_HOST + SEND_INTERNET_MAIL_PORT ]
defaults = relevant_defaults(names)
-JUMPER_IP = defaults['JUMPER_IP'] -JUMPER_PORT = defaults['JUMPER_PORT'] -CRYSTAL_INTRANET = defaults['CRYSTAL_INTRANET'] -SEND_MAIL_PORT = defaults['SEND_MAIL_PORT'] +JUMPER_HOST = defaults['JUMPER_HOST'] || '183.134.196.212' +JUMPER_PORT = defaults['JUMPER_PORT'] || 29999 +SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost +SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312 + +apply_info = { + 'my_email' => nil, + 'my_pub_key' => nil +} + +def init_info(email_file, apply_info) + mail_content = Mail.read(email_file) + + my_email = mail_content.from[0] + my_pub_key = mail_content.part[1].body.decoded.gsub(/\r|\n/, '') if mail_content.part[1].filename == 'id_rsa.pub' + + apply_info['my_email'] = my_email + apply_info['my_pub_key'] = my_pub_key + + apply_info +end + +options = OptionParser.new do |opts| + opts.banner = "Usage: answerback-mail.rb [--email email] [--ssh-pubkey pub_key_file] [--raw-email email_file]\n" + opts.banner += " -e or -f is required\n" + opts.banner += ' -s is optional when use -e' + + opts.separator '' + opts.separator 'options:' + + opts.on('-e email_address', '--email email_address', 'appoint email address') do |email_address| + apply_info['my_email'] = email_address + end + + opts.on('-s pub_key_file', '--ssh-pubkey pub_key_file', 'ssh pub_key file, enable keyless login') do |pub_key_file| + apply_info['my_pub_key'] = File.read(pub_key_file) + end + + opts.on('-f email_file', '--raw-email email_file', 'email file') do |email_file| + init_info(email_file, apply_info) + end + + opts.on_tail('-h', '--help', 'show this message') do + puts opts + exit + end +end
-def build_message(email, message_id, infos) +options.parse!(ARGV) + +def build_message(email, acct_infos) message = <<~EMAIL_MESSAGE To: #{email} - Message-ID: #{message_id} Subject: jumper account is ready
- Dear #{email} + Dear user:
Thank you for joining us. You can use the following command to login the jumper server:
login command: - ssh -p #{infos['jumper_port']} #{infos['account']}@#{infos['jumper_ip']} + ssh -p #{acct_infos['jumper_port']} #{acct_infos['account']}@#{acct_infos['jumper_ip']}
- account passwd: - account_password: #{infos['passwd']} + account password: + #{acct_infos['passwd']}
regards compass-ci @@ -79,67 +95,26 @@ def build_message(email, message_id, infos) return message end
-def email_addr(mail_content) - msg = 'not an applying account email' - - raise msg unless mail_content.subject =~ /apply ssh account/i - - email = mail_content.from.join(',') - - return email -end - -# def check_email_available(mail_content, email) -# oos_list = File.read('/c/upstream-repos/repo_list').split(/\n/) -# url = mail_content.body.decoded.split(/\n/).find { |line| line =~ /https?:/// } -# base_url = url.split('/')[0,5].join('/') -# message = 'The url is not in upstream repo_list' -# -# raise message unless oos_list.include? base_url -# -# url_fdback = %x(curl #{url}) -# email_index = url_fdback.index email -# -# message = 'No commit info found from the url for the email' -# raise message unless email_index -# end - -def email_message_id(mail_content) - message_id = mail_content.message_id - return message_id -end - -def pub_key_value(mail_content) - pub_key = mail_content.body.decoded.split(/\n/).find { |line| line =~ /ssh-rsa/ } - return pub_key -end - def account_info(pub_key) - account_info_str = %x(curl -XGET '#{JUMPER_IP}:#{JUMPER_PORT}/assign_account' -d "pub_key: #{pub_key}") - account_info = JSON.parse account_info_str - - return account_info + account_info_str = if pub_key.nil? + %x(curl -XGET '#{JUMPER_HOST}:#{JUMPER_PORT}/assign_account') + else + %x(curl -XGET '#{JUMPER_HOST}:#{JUMPER_PORT}/assign_account' -d "pub_key: #{pub_key}") + end + JSON.parse account_info_str end
-def send_account(mail_content) - email = email_addr(mail_content) - message_id = email_message_id(mail_content) - # check_email_available(mail_content, email) +def send_account(apply_info) + message = "No email address specified\n" + message += "use -e email_address add a email address\n" + message += 'or use -f to add a email file' + raise message if apply_info['my_email'].nil?
- pub_key = pub_key_value(mail_content) - acct_info = account_info(pub_key) - - message = build_message(email, message_id, acct_info) - - %x(curl -XPOST '#{CRYSTAL_INTRANET}:#{SEND_MAIL_PORT}/send_mail_text' -d "#{message}") -end + acct_info = account_info(apply_info['my_pub_key'])
-def read_mail_content(mail_file) - mail_content = Mail.read(mail_file) + message = build_message(apply_info['my_email'], acct_info)
- return mail_content + %x(curl -XPOST '#{SEND_MAIL_HOST}:#{SEND_MAIL_PORT}/send_mail_text' -d "#{message}") end
-mail_file = ARGV[0] -mail_content = read_mail_content(mail_file) -send_account(mail_content) +send_account(apply_info)
+SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost +SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312
不大对称,可能有问题。 SEND_MAIL_HOST是啥东西? 为啥HOST可以复用, PORT不能复用?
+apply_info = {
- 'my_email' => nil,
- 'my_pub_key' => nil
my_pub_key => my_ssh_pubkey
因为还有比如gpg pub key, 避免混淆。
+def init_info(email_file, apply_info)
- mail_content = Mail.read(email_file)
- my_email = mail_content.from[0]
Avoid use-once variable!
- my_pub_key = mail_content.part[1].body.decoded.gsub(/\r|\n/, '') if mail_content.part[1].filename == 'id_rsa.pub'
Too long line.
- apply_info['my_email'] = my_email
- apply_info['my_pub_key'] = my_pub_key
- apply_info
+end
+options = OptionParser.new do |opts|
- opts.banner = "Usage: answerback-mail.rb [--email email] [--ssh-pubkey pub_key_file] [--raw-email email_file]\n"
- opts.banner += " -e or -f is required\n"
- opts.banner += ' -s is optional when use -e'
- opts.separator ''
- opts.separator 'options:'
- opts.on('-e email_address', '--email email_address', 'appoint email address') do |email_address|
'-e|--email email_address'
ditto for below params.
- apply_info['my_email'] = email_address
- end
- opts.on('-s pub_key_file', '--ssh-pubkey pub_key_file', 'ssh pub_key file, enable keyless login') do |pub_key_file|
keyless => password-less
- apply_info['my_pub_key'] = File.read(pub_key_file)
- end
- opts.on('-f email_file', '--raw-email email_file', 'email file') do |email_file|
- init_info(email_file, apply_info)
apply_info parameter can be removed?
- end
- opts.on_tail('-h', '--help', 'show this message') do
- puts opts
- exit
- end
+end
-def build_message(email, message_id, infos) +options.parse!(ARGV)
+def build_message(email, acct_infos) message = <<~EMAIL_MESSAGE To: #{email}
Message-ID: #{message_id} Subject: jumper account is ready
Dear #{email}
Dear user:
Thank you for joining us. You can use the following command to login the jumper server:
login command:
ssh -p #{infos['jumper_port']} #{infos['account']}@#{infos['jumper_ip']}
ssh -p #{acct_infos['jumper_port']} #{acct_infos['account']}@#{acct_infos['jumper_ip']}
account passwd:
account_password: #{infos['passwd']}
account password:
#{acct_infos['passwd']}
regards compass-ci
@@ -79,67 +95,26 @@ def build_message(email, message_id, infos) return message end
-def email_addr(mail_content)
- msg = 'not an applying account email'
- raise msg unless mail_content.subject =~ /apply ssh account/i
- email = mail_content.from.join(',')
- return email
-end
-# def check_email_available(mail_content, email) -# oos_list = File.read('/c/upstream-repos/repo_list').split(/\n/) -# url = mail_content.body.decoded.split(/\n/).find { |line| line =~ /https?:/// } -# base_url = url.split('/')[0,5].join('/') -# message = 'The url is not in upstream repo_list' -# -# raise message unless oos_list.include? base_url -# -# url_fdback = %x(curl #{url}) -# email_index = url_fdback.index email -# -# message = 'No commit info found from the url for the email' -# raise message unless email_index -# end
-def email_message_id(mail_content)
- message_id = mail_content.message_id
- return message_id
-end
-def pub_key_value(mail_content)
- pub_key = mail_content.body.decoded.split(/\n/).find { |line| line =~ /ssh-rsa/ }
- return pub_key
-end
def account_info(pub_key)
- account_info_str = %x(curl -XGET '#{JUMPER_IP}:#{JUMPER_PORT}/assign_account' -d "pub_key: #{pub_key}")
- account_info = JSON.parse account_info_str
- return account_info
- account_info_str = if pub_key.nil?
%x(curl -XGET '#{JUMPER_HOST}:#{JUMPER_PORT}/assign_account')
else
%x(curl -XGET '#{JUMPER_HOST}:#{JUMPER_PORT}/assign_account' -d "pub_key: #{pub_key}")
end
- JSON.parse account_info_str
end
-def send_account(mail_content)
- email = email_addr(mail_content)
- message_id = email_message_id(mail_content)
- # check_email_available(mail_content, email)
+def send_account(apply_info)
- message = "No email address specified\n"
- message += "use -e email_address add a email address\n"
- message += 'or use -f to add a email file'
- raise message if apply_info['my_email'].nil?
- pub_key = pub_key_value(mail_content)
- acct_info = account_info(pub_key)
- message = build_message(email, message_id, acct_info)
- %x(curl -XPOST '#{CRYSTAL_INTRANET}:#{SEND_MAIL_PORT}/send_mail_text' -d "#{message}")
-end
- acct_info = account_info(apply_info['my_pub_key'])
-def read_mail_content(mail_file)
- mail_content = Mail.read(mail_file)
- message = build_message(apply_info['my_email'], acct_info)
- return mail_content
- %x(curl -XPOST '#{SEND_MAIL_HOST}:#{SEND_MAIL_PORT}/send_mail_text' -d "#{message}")
end
-mail_file = ARGV[0] -mail_content = read_mail_content(mail_file) -send_account(mail_content)
+send_account(apply_info)
2.23.0
On Wed, Oct 21, 2020 at 10:31:34AM +0800, Wu Fengguang wrote:
+SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost +SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312
不大对称,可能有问题。 SEND_MAIL_HOST是啥东西?
SEND_MAIL_HOST is the host which send_mail service running on
为啥HOST可以复用, PORT不能复用?
because there are two service: send-mail: send intranet email(crystal.ci) send-internet-mail: send internet mail The two service may run on a single host
+apply_info = {
- 'my_email' => nil,
- 'my_pub_key' => nil
my_pub_key => my_ssh_pubkey
OK, I will rename it
因为还有比如gpg pub key, 避免混淆。
+def init_info(email_file, apply_info)
- mail_content = Mail.read(email_file)
- my_email = mail_content.from[0]
Avoid use-once variable!
OK, I will fix it
- my_pub_key = mail_content.part[1].body.decoded.gsub(/\r|\n/, '') if mail_content.part[1].filename == 'id_rsa.pub'
Too long line.
I got it
- apply_info['my_email'] = my_email
- apply_info['my_pub_key'] = my_pub_key
- apply_info
+end
+options = OptionParser.new do |opts|
- opts.banner = "Usage: answerback-mail.rb [--email email] [--ssh-pubkey pub_key_file] [--raw-email email_file]\n"
- opts.banner += " -e or -f is required\n"
- opts.banner += ' -s is optional when use -e'
- opts.separator ''
- opts.separator 'options:'
- opts.on('-e email_address', '--email email_address', 'appoint email address') do |email_address|
'-e|--email email_address'
ditto for below params.
I will fix it
- apply_info['my_email'] = email_address
- end
- opts.on('-s pub_key_file', '--ssh-pubkey pub_key_file', 'ssh pub_key file, enable keyless login') do |pub_key_file|
keyless => password-less
I got it
- apply_info['my_pub_key'] = File.read(pub_key_file)
- end
- opts.on('-f email_file', '--raw-email email_file', 'email file') do |email_file|
- init_info(email_file, apply_info)
apply_info parameter can be removed?
I will fix it
Thanks Luan Shengde
- end
- opts.on_tail('-h', '--help', 'show this message') do
- puts opts
- exit
- end
+end
-def build_message(email, message_id, infos) +options.parse!(ARGV)
+def build_message(email, acct_infos) message = <<~EMAIL_MESSAGE To: #{email}
Message-ID: #{message_id} Subject: jumper account is ready
Dear #{email}
Dear user:
Thank you for joining us. You can use the following command to login the jumper server:
login command:
ssh -p #{infos['jumper_port']} #{infos['account']}@#{infos['jumper_ip']}
ssh -p #{acct_infos['jumper_port']} #{acct_infos['account']}@#{acct_infos['jumper_ip']}
account passwd:
account_password: #{infos['passwd']}
account password:
#{acct_infos['passwd']}
regards compass-ci
@@ -79,67 +95,26 @@ def build_message(email, message_id, infos) return message end
-def email_addr(mail_content)
- msg = 'not an applying account email'
- raise msg unless mail_content.subject =~ /apply ssh account/i
- email = mail_content.from.join(',')
- return email
-end
-# def check_email_available(mail_content, email) -# oos_list = File.read('/c/upstream-repos/repo_list').split(/\n/) -# url = mail_content.body.decoded.split(/\n/).find { |line| line =~ /https?:/// } -# base_url = url.split('/')[0,5].join('/') -# message = 'The url is not in upstream repo_list' -# -# raise message unless oos_list.include? base_url -# -# url_fdback = %x(curl #{url}) -# email_index = url_fdback.index email -# -# message = 'No commit info found from the url for the email' -# raise message unless email_index -# end
-def email_message_id(mail_content)
- message_id = mail_content.message_id
- return message_id
-end
-def pub_key_value(mail_content)
- pub_key = mail_content.body.decoded.split(/\n/).find { |line| line =~ /ssh-rsa/ }
- return pub_key
-end
def account_info(pub_key)
- account_info_str = %x(curl -XGET '#{JUMPER_IP}:#{JUMPER_PORT}/assign_account' -d "pub_key: #{pub_key}")
- account_info = JSON.parse account_info_str
- return account_info
- account_info_str = if pub_key.nil?
%x(curl -XGET '#{JUMPER_HOST}:#{JUMPER_PORT}/assign_account')
else
%x(curl -XGET '#{JUMPER_HOST}:#{JUMPER_PORT}/assign_account' -d "pub_key: #{pub_key}")
end
- JSON.parse account_info_str
end
-def send_account(mail_content)
- email = email_addr(mail_content)
- message_id = email_message_id(mail_content)
- # check_email_available(mail_content, email)
+def send_account(apply_info)
- message = "No email address specified\n"
- message += "use -e email_address add a email address\n"
- message += 'or use -f to add a email file'
- raise message if apply_info['my_email'].nil?
- pub_key = pub_key_value(mail_content)
- acct_info = account_info(pub_key)
- message = build_message(email, message_id, acct_info)
- %x(curl -XPOST '#{CRYSTAL_INTRANET}:#{SEND_MAIL_PORT}/send_mail_text' -d "#{message}")
-end
- acct_info = account_info(apply_info['my_pub_key'])
-def read_mail_content(mail_file)
- mail_content = Mail.read(mail_file)
- message = build_message(apply_info['my_email'], acct_info)
- return mail_content
- %x(curl -XPOST '#{SEND_MAIL_HOST}:#{SEND_MAIL_PORT}/send_mail_text' -d "#{message}")
end
-mail_file = ARGV[0] -mail_content = read_mail_content(mail_file) -send_account(mail_content)
+send_account(apply_info)
2.23.0
On Wed, Oct 21, 2020 at 10:57:33AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 10:31:34AM +0800, Wu Fengguang wrote:
+SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost +SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312
不大对称,可能有问题。 SEND_MAIL_HOST是啥东西?
SEND_MAIL_HOST is the host which send_mail service running on
为啥HOST可以复用, PORT不能复用?
because there are two service: send-mail: send intranet email(crystal.ci) send-internet-mail: send internet mail The two service may run on a single host
那我想让他们在两台机器上跑呢?
Thanks, Fengguang
On Wed, Oct 21, 2020 at 11:32:54AM +0800, Wu Fengguang wrote:
On Wed, Oct 21, 2020 at 10:57:33AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 10:31:34AM +0800, Wu Fengguang wrote:
+SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost +SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312
不大对称,可能有问题。 SEND_MAIL_HOST是啥东西?
SEND_MAIL_HOST is the host which send_mail service running on
为啥HOST可以复用, PORT不能复用?
because there are two service: send-mail: send intranet email(crystal.ci) send-internet-mail: send internet mail The two service may run on a single host
那我想让他们在两台机器上跑呢?
SEND_INTERNET_MAIL_PORT => SEND_MAIL_PORT_INTERNET
set SEND_MAIL_PORT_INTERNET: xxxx1 SEND_MAIL_PORT_INTRANET: xxxx2 in ~/.config/compass-ci/default/$USER.yaml
no matter the two service run on a single host or two start file: send internet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTERNET send intranet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTRANET
mail-post.rb just receive variable: SEND_MAIL_PORT no matter send internet email or send intranet email, the mail-post can get the right port.
Thanks Luan Shengde
Thanks, Fengguang
On Wed, Oct 21, 2020 at 11:53:18AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 11:32:54AM +0800, Wu Fengguang wrote:
On Wed, Oct 21, 2020 at 10:57:33AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 10:31:34AM +0800, Wu Fengguang wrote:
+SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost +SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312
不大对称,可能有问题。 SEND_MAIL_HOST是啥东西?
SEND_MAIL_HOST is the host which send_mail service running on
为啥HOST可以复用, PORT不能复用?
because there are two service: send-mail: send intranet email(crystal.ci) send-internet-mail: send internet mail The two service may run on a single host
那我想让他们在两台机器上跑呢?
SEND_INTERNET_MAIL_PORT => SEND_MAIL_PORT_INTERNET
不是PORT啦,现在需要HOST不一样。
Thanks, Fengguang
set SEND_MAIL_PORT_INTERNET: xxxx1 SEND_MAIL_PORT_INTRANET: xxxx2 in ~/.config/compass-ci/default/$USER.yaml
no matter the two service run on a single host or two start file: send internet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTERNET send intranet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTRANET
mail-post.rb just receive variable: SEND_MAIL_PORT no matter send internet email or send intranet email, the mail-post can get the right port.
Thanks Luan Shengde
Thanks, Fengguang
On Wed, Oct 21, 2020 at 11:58:04AM +0800, Wu Fengguang wrote:
On Wed, Oct 21, 2020 at 11:53:18AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 11:32:54AM +0800, Wu Fengguang wrote:
On Wed, Oct 21, 2020 at 10:57:33AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 10:31:34AM +0800, Wu Fengguang wrote:
+SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost +SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312
不大对称,可能有问题。 SEND_MAIL_HOST是啥东西?
SEND_MAIL_HOST is the host which send_mail service running on
为啥HOST可以复用, PORT不能复用?
because there are two service: send-mail: send intranet email(crystal.ci) send-internet-mail: send internet mail The two service may run on a single host
那我想让他们在两台机器上跑呢?
SEND_INTERNET_MAIL_PORT => SEND_MAIL_PORT_INTERNET
不是PORT啦,现在需要HOST不一样。
then you may also set SEND_MAIL_HOST_INTERNET SEND_MAIL_HOST_INTRANET for the two services on different hosts
send internet email: SEND_MAIL_HOST <=> SEND_MAIL_HOST_INTERNET send intranet email: SEND_MAIL_HOST <=> SEND_MAIL_HOST_INTRANET
Thanks Luan Shengde
Thanks, Fengguang
set SEND_MAIL_PORT_INTERNET: xxxx1 SEND_MAIL_PORT_INTRANET: xxxx2 in ~/.config/compass-ci/default/$USER.yaml
no matter the two service run on a single host or two start file: send internet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTERNET send intranet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTRANET
mail-post.rb just receive variable: SEND_MAIL_PORT no matter send internet email or send intranet email, the mail-post can get the right port.
Thanks Luan Shengde
Thanks, Fengguang
On Wed, Oct 21, 2020 at 02:20:18PM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 11:58:04AM +0800, Wu Fengguang wrote:
On Wed, Oct 21, 2020 at 11:53:18AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 11:32:54AM +0800, Wu Fengguang wrote:
On Wed, Oct 21, 2020 at 10:57:33AM +0800, Luan Shengde wrote:
On Wed, Oct 21, 2020 at 10:31:34AM +0800, Wu Fengguang wrote:
>+SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || localhost >+SEND_MAIL_PORT = defaults['SEND_INTERNET_MAIL_PORT'] || 11312
不大对称,可能有问题。 SEND_MAIL_HOST是啥东西?
SEND_MAIL_HOST is the host which send_mail service running on
为啥HOST可以复用, PORT不能复用?
because there are two service: send-mail: send intranet email(crystal.ci) send-internet-mail: send internet mail The two service may run on a single host
那我想让他们在两台机器上跑呢?
SEND_INTERNET_MAIL_PORT => SEND_MAIL_PORT_INTERNET
不是PORT啦,现在需要HOST不一样。
then you may also set SEND_MAIL_HOST_INTERNET SEND_MAIL_HOST_INTRANET for the two services on different hosts
send internet email: SEND_MAIL_HOST <=> SEND_MAIL_HOST_INTERNET send intranet email: SEND_MAIL_HOST <=> SEND_MAIL_HOST_INTRANET
OK.
Thanks, Fengguang
set SEND_MAIL_PORT_INTERNET: xxxx1 SEND_MAIL_PORT_INTRANET: xxxx2 in ~/.config/compass-ci/default/$USER.yaml
no matter the two service run on a single host or two start file: send internet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTERNET send intranet email: SEND_MAIL_PORT <=> SEND_MAIL_PORT_INTRANET
mail-post.rb just receive variable: SEND_MAIL_PORT no matter send internet email or send intranet email, the mail-post can get the right port.
Thanks Luan Shengde
Thanks, Fengguang
On Wed, Oct 21, 2020 at 10:18:44AM +0800, Luan Shengde wrote:
add parameters for answerback-email -e,--email email_address: add email address -s,--ssh-pubkey pub_key_file: add a ssh login pub_key -f,--raw-email email_file: add email address[, pub_key] via email file
Usage: ruby answerback-email.rb -e email_address [-s pub_key_file] ruby answerback-email.rb -f email_file
Why not put this file into the sbin dir?
-mail_file = ARGV[0] -mail_content = read_mail_content(mail_file) -send_account(mail_content) +send_account(apply_info)
If the apply_info is global var no need pass it as a param. Thanks, Xueliang
-- 2.23.0
On Wed, Oct 21, 2020 at 03:19:05PM +0800, Cao Xueliang wrote:
On Wed, Oct 21, 2020 at 10:18:44AM +0800, Luan Shengde wrote:
add parameters for answerback-email -e,--email email_address: add email address -s,--ssh-pubkey pub_key_file: add a ssh login pub_key -f,--raw-email email_file: add email address[, pub_key] via email file
Usage: ruby answerback-email.rb -e email_address [-s pub_key_file] ruby answerback-email.rb -f email_file
Why not put this file into the sbin dir?
the old file is in container/assign-account so I just update it at it's original path
-mail_file = ARGV[0] -mail_content = read_mail_content(mail_file) -send_account(mail_content) +send_account(apply_info)
If the apply_info is global var no need pass it as a param.
I have fixed it in the new version
Thanks Luan Shengde
Thanks, Xueliang
-- 2.23.0