ish_models 0.0.33.286 → 0.0.33.291

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9858084eb2be19284f243aac721ab18d5796e734dd0ac5216a600199dde65b6e
4
- data.tar.gz: f48ad96c4cef14657a7688090cd7415ecee6c2130cb25694897268eb6680401c
3
+ metadata.gz: 257cf440b86a79d5147a9e3147ec4606c92e0e2238a6c11e51eae7fa924d35eb
4
+ data.tar.gz: 9c35232b6ca4a0d026c306576f2916cd7121156626f8aca52c1ff0ac9cc53901
5
5
  SHA512:
6
- metadata.gz: dc070cf944df807e0c43167ba5083f1d6269778f4fa6a5dfe784467f7e671dfdceb3fc05c3536389332f16fb3be0935bf725b8f60b7311ba3b17c701ac5f266b
7
- data.tar.gz: bb0a82434672c5aad1c941e13d5a9e6c4d118c76008d8433929bdf9636cdd8482d5e24cb34b78d180fd5bd4efe933fc2f5fd5a62cf4a53606084c178970ded66
6
+ metadata.gz: 741ac3cfb2a7f6b2a562266dd88f53f091ccd2dc26c792d4f410036035e4660121df479470dd020a882abba2d84a44170b6dc47139f5c3f7753510a7f10c8053
7
+ data.tar.gz: 35ca293da5528f2ced972d41342d3f5f305d5f03e539f8fc83a37793acfa304568b0bed4ed73e7ef99d8f3a1a8b1e9f44f55306a9a33f4ac1ee0950006dfc6c4
@@ -75,7 +75,10 @@ class ::Ish::EmailContext
75
75
  field :lead_id, type: :integer
76
76
  def lead; Lead.find( lead_id ); end
77
77
  def to_email; lead[:email]; end ## @TODO: remove, just use the lead. _vp_ 2023-03-27
78
-
78
+ # ## no `to` field b/c that's the lead
79
+ # field :tos, type: :array, default: []
80
+ field :cc, type: :string
81
+ field :ccs, type: :array, default: []
79
82
 
80
83
  ##
81
84
  ## For tracking / utm
@@ -29,6 +29,7 @@ class ::Ish::EmailTemplate
29
29
  field :config_exe, default: "" ## unused! _vp_ 2023-09-24
30
30
  field :config_json, type: Object, default: '{}'
31
31
 
32
+ DEFAULT_FROM_EMAIL = 'Victor Pudeyev <victor@wasya.co>'
32
33
  FROM_EMAILS = [
33
34
  'Annesque Studio <hello@annesque.studio>',
34
35
  'Annesque Studio <no-reply@annesque.studio>',
@@ -45,30 +46,30 @@ class ::Ish::EmailTemplate
45
46
  'Oquaney Splicing <hello@oquaney-splicing.com>',
46
47
  'Oquaney Splicing <no-reply@oquaney-splicing.com>',
47
48
 
48
- 'Victor Piousbox <piousbox@gmail.com>',
49
- 'Victor Piousbox <victor@piousbox.com>',
50
- 'Victor Piousbox <no-reply@piousbox.com>',
49
+ 'Victor Pudeyev <piousbox@gmail.com>',
50
+ 'Victor Pudeyev <victor@piousbox.com>',
51
+ 'Victor Pudeyev <no-reply@piousbox.com>',
51
52
  'Victor Pudeyev <victor@pudeyev.com>',
52
53
 
53
- 'Sender Sbs <hello@sender.sbs>',
54
- 'Sender Sbs <no-reply@sender.sbs>',
54
+ 'Sender SBS <hello@sender.sbs>',
55
+ 'Sender SBS <no-reply@sender.sbs>',
55
56
 
56
57
  'WasyaCo Consulting <admin@wasya.co>',
57
- 'Alex <alex@wasya.co>',
58
- 'Bailey <bailey@wasya.co>',
59
- 'Cameron <cameron@wasya.co>',
58
+ 'Alex WCo <alex@wasya.co>',
59
+ 'Bailey WCo <bailey@wasya.co>',
60
+ 'Cameron WCo <cameron@wasya.co>',
60
61
  'WasyaCo Consulting <hello@wasya.co>',
61
- 'Jess <jess@wasya.co>',
62
+ 'Jess WCo <jess@wasya.co>',
62
63
  'WasyaCo Consulting <no-reply@wasya.co>',
63
- 'Victor Piousbox <victor@wasya.co>',
64
+ 'Victor Pudeyev <victor@wasya.co>',
64
65
 
65
66
  'WasyaCo Consulting <admin@wasyaco.com>',
66
- 'Alex <alex@wasyaco.com>',
67
- 'Bailey <bailey@wasyaco.com>',
68
- 'Cameron <cameron@wasyaco.com>',
67
+ 'Alex WCo <alex@wasyaco.com>',
68
+ 'Bailey WCo <bailey@wasyaco.com>',
69
+ 'Cameron WCo <cameron@wasyaco.com>',
69
70
  'WasyaCo Consulting <hello@wasyaco.com>',
70
71
  'WasyaCo Consulting <no-reply@wasyaco.com>',
71
- 'Victor <victor@wasyaco.com>',
72
+ 'Victor Pudeyev <victor@wasyaco.com>',
72
73
 
73
74
  'Wasya Co Mailer <no-reply@wco.com.de>',
74
75
  'Wasya Co Mailer <wasyacomailer@gmail.com>',
@@ -78,6 +79,15 @@ class ::Ish::EmailTemplate
78
79
  [ [nil, nil] ] + FROM_EMAILS.map { |i| [i, i] }
79
80
  end
80
81
 
82
+ SIGNATURE = <<~AOL
83
+ <div>
84
+ <div><br></div>
85
+ <div>Regards,</div>
86
+ <div>-=----- &gt;8 --</div>
87
+ <div>Victor Pudeyev<br>Director of Engineering<br><a href="mailto:victor@piousbox.com" target="_blank">victor@piousbox.com</a> | <a href="https://tidycal.com/wasya-co/30min" target="_blank">Book a chat</a><br></div>
88
+ </div><hr /><br /><br /><br />
89
+ AOL
90
+
81
91
  ## 2023-03-04 _vp_ This works!
82
92
  def get_binding
83
93
  @lead = Lead.where( email: 'stub@wasya.co' ).first
data/lib/ish_models.rb CHANGED
@@ -81,6 +81,7 @@ require 'office/scheduled_email_action'
81
81
 
82
82
  require 'wco/appliance'
83
83
  require 'wco/appliance_tmpl'
84
+ require 'wco/leadset'
84
85
  require 'wco/price'
85
86
  require 'wco/product'
86
87
  require 'wco/serverhost'
@@ -53,6 +53,7 @@ class Office::EmailConversation
53
53
  wp_term_id: tag.id,
54
54
  }).first&.delete
55
55
  end
56
+ ## @deprecated, do not use. _vp_ 2023-10-29
56
57
  def rmtag which; remove_tag which; end
57
58
 
58
59
  def in_emailtag? which
data/lib/wco/appliance.rb CHANGED
@@ -5,7 +5,10 @@ class Wco::Appliance
5
5
 
6
6
  field :name
7
7
  validates :name, uniqueness: { scope: :leadset_id }, presence: true
8
+
8
9
  field :kind
10
+
11
+ field :service_name
9
12
  field :environment
10
13
 
11
14
  field :subdomain
@@ -19,7 +22,21 @@ class Wco::Appliance
19
22
  Leadset.find leadset_id
20
23
  end
21
24
 
22
- belongs_to :serverhost, class_name: 'Wco::Serverhost'
25
+ belongs_to :appliance_tmpl, class_name: 'Wco::ApplianceTmpl'
26
+ def tmpl
27
+ appliance_tmpl
28
+ end
29
+
30
+ belongs_to :serverhost, class_name: 'Wco::Serverhost'
31
+ belongs_to :wco_leadset, class_name: 'Wco::Leadset', inverse_of: :appliances
32
+
33
+ # field :ip
34
+ field :port
35
+
36
+ STATE_PENDING = 'state-pending'
37
+ STATE_LIVE = 'state-live'
38
+ STATE_TERM = 'state-term'
39
+ field :state, default: STATE_PENDING
23
40
 
24
41
  end
25
42
 
@@ -4,12 +4,33 @@ class Wco::ApplianceTmpl
4
4
  include Mongoid::Timestamps
5
5
 
6
6
  field :kind
7
- validates :kind, uniqueness: true, presence: true
7
+ validates :kind, uniqueness: { scope: :version }, presence: true
8
+
9
+ field :version, type: :string, default: '0.0.0'
10
+ validates :version, uniqueness: { scope: :kind }, presence: true
11
+ index({ kind: -1, version: -1 }, { name: :kind_version })
12
+
13
+ field :descr, type: :string
8
14
 
9
15
  field :image
10
16
  validates :image, presence: true
11
17
 
18
+ field :volume_zip
19
+ validates :volume_zip, presence: true
20
+
12
21
  KIND_CORPHOME1 = 'corphome1'
22
+ KIND_DRUPAL = 'drupal'
13
23
  KIND_HELLOWORLD = 'helloworld'
14
- KINDS = [ 'SMT', 'EmailCRM', KIND_CORPHOME1, KIND_HELLOWORLD, 'Drupal', 'Odoo', 'Mautic', 'IroWor', 'eCommStore1' ]
24
+ # KINDS = [ 'smt', 'emailcrm', KIND_CORPHOME1, KIND_HELLOWORLD, KIND_DRUPAL,
25
+ # 'mautic', 'matomo',
26
+ # 'irowor', 'eCommerce' ]
27
+ KINDS = [ KIND_HELLOWORLD ]
28
+
29
+ has_many :appliances, class_name: 'Wco::Appliance'
30
+
31
+ def self.latest_of kind
32
+ where({ kind: kind }).order_by({ version: :desc }).first
33
+ end
34
+
15
35
  end
36
+ AppTmpl = Wco::ApplianceTmpl
@@ -0,0 +1,17 @@
1
+
2
+ class Wco::Leadset
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+
6
+ field :name
7
+
8
+ field :domains, type: :string, default: 'orbital.city'
9
+
10
+ has_many :serverhosts, class_name: 'Wco::Serverhost', inverse_of: :wco_leadset
11
+ def next_serverhost
12
+ serverhosts.first
13
+ end
14
+
15
+ has_many :appliances, class_name: 'Wco::Appliance', inverse_of: :wco_leadset
16
+
17
+ end
@@ -1,6 +1,5 @@
1
1
 
2
2
  require 'net/scp'
3
- # require 'autoinc'
4
3
 
5
4
  class Wco::Serverhost
6
5
  include Mongoid::Document
@@ -8,17 +7,19 @@ class Wco::Serverhost
8
7
  # include Mongoid::Autoinc
9
8
 
10
9
  field :name, type: :string
11
- validates :name, uniqueness: { scope: :leadset_id }, presence: true
10
+ # validates :name, uniqueness: { scope: :leadset_id }, presence: true
11
+ validates :name, uniqueness: { scope: :wco_leadset }, presence: true
12
12
 
13
- field :next_port, type: :integer, default: 8000
14
- # increments :next_port
13
+ # field :leadset_id, type: :integer
14
+ # has_and_belongs_to_many :leadsets, class_name: 'Wco::Leadset', inverse_of: :serverhosts
15
+ belongs_to :wco_leadset, class_name: 'Wco::Leadset'
15
16
 
16
- field :leadset_id, type: :integer
17
+ field :next_port, type: :integer, default: 8000
17
18
 
18
19
  ## net-ssh, sshkit
19
20
  field :ssh_host
20
- field :ssh_username
21
- field :ssh_key
21
+ # field :ssh_username
22
+ # field :ssh_key
22
23
  field :nginx_root, default: '/opt/nginx'
23
24
 
24
25
  has_many :appliances, class_name: 'Wco::Appliance'
@@ -50,49 +51,50 @@ class Wco::Serverhost
50
51
 
51
52
  end
52
53
 
53
- def docker_add_service rendered_str=nil, config={}
54
- # puts! config, '#docker_add_service'
55
- File.write( "/Users/piousbox/projects/docker_demo/dc-#{config[:service_name]}.yml", rendered_str )
56
- out = ` mkdir /Users/piousbox/projects/docker_demo/#{config[:service_name]}_data `
57
- puts! out, 'out'
58
- out = ` cd /Users/piousbox/projects/docker_demo/ ; \
59
- docker compose -f dc-#{config[:service_name]}.yml up -d #{config[:service_name]} ; \
60
- echo ok
61
- `;
62
- puts! out, 'out'
63
- end
54
+ WORKDIR = "/opt/projects/docker"
55
+
56
+ def add_docker_service app={}
57
+ puts! app, '#add_docker_service'
58
+
59
+ ac = ActionController::Base.new
60
+ ac.instance_variable_set( :@app, app )
61
+ ac.instance_variable_set( :@workdir, WORKDIR )
62
+ rendered_str = ac.render_to_string("docker-compose/dc-#{app[:kind]}")
63
+ puts '+++ add_docker_service rendered_str:'
64
+ print rendered_str
65
+
66
+ file = Tempfile.new('prefix')
67
+ file.write rendered_str
68
+ file.close
69
+ puts! file.path, 'file.path'
64
70
 
65
- def load_data rendered_str=nil, config={}
66
- File.write( "/Users/piousbox/projects/docker_demo/#{config[:service_name]}_data/index.html", rendered_str )
71
+ `scp #{file.path} #{ssh_host}:#{WORKDIR}/dc-#{app[:service_name]}.yml`
72
+ `ssh #{ssh_host} 'cd #{WORKDIR} ; \
73
+ docker compose -f dc-#{app[:service_name]}.yml up -d #{app[:service_name]} ; \
74
+ echo ok #add_docker_service ' `
67
75
  end
68
76
 
77
+ def create_volume app={}
78
+ # puts! app, '#create_volume'
69
79
 
70
- end
80
+ ac = ActionController::Base.new
81
+ ac.instance_variable_set( :@app, app )
82
+ ac.instance_variable_set( :@workdir, WORKDIR )
83
+ rendered_str = ac.render_to_string("scripts/create_volume")
84
+ # puts '+++ create_volume rendered_str:'
85
+ # print rendered_str
86
+
87
+ file = Tempfile.new('prefix')
88
+ file.write rendered_str
89
+ file.close
90
+ # puts! file.path, 'file.path'
71
91
 
72
- # class Instance
73
- # def chmod
74
- # start do |ssh|
75
- # ssh.exec "sudo chmod +x /tmp/provision.sh"
76
- # # other operations on ssh
77
- # end
78
- # end
79
- # private
80
- # def start
81
- # Net::SSH.start(ip, 'ubuntu', keys: "mykey.pem" ) do |ssh|
82
- # yield ssh
83
- # end
84
- # end
85
- # end
86
-
87
-
88
- ## works:
89
- # nginx_root = '/opt/nginx'
90
- # config = { service_name: 'abba', }
91
- # Net::SSH.start( "18.209.12.11", "ubuntu", keys: "access/mac_id_rsa_3.pem" ) do |ssh|
92
- # out = ssh.scp.upload! "tmp/#{config[:service_name]}", "/opt/tmp/two.txt" do |ch, name, sent, total|
93
- # puts "#{name}: #{sent}/#{total}"
94
- # end
95
- # puts! out, 'out'
96
- # end
92
+ `scp #{file.path} #{ssh_host}:#{WORKDIR}/scripts/create_volume`
93
+ `ssh #{ssh_host} 'chmod a+x #{WORKDIR}/scripts/create_volume ; \
94
+ #{WORKDIR}/scripts/create_volume ' `
95
+ end
96
+ # alias_method :create_volume, :create_volume_2
97
97
 
98
98
 
99
+ end
100
+
@@ -0,0 +1,45 @@
1
+
2
+
3
+
4
+ # WORKDIR = "/Users/piousbox/projects/docker_wco"
5
+
6
+ # class Instance
7
+ # def chmod
8
+ # start do |ssh|
9
+ # ssh.exec "sudo chmod +x /tmp/provision.sh"
10
+ # # other operations on ssh
11
+ # end
12
+ # end
13
+ # private
14
+ # def start
15
+ # Net::SSH.start(ip, 'ubuntu', keys: "mykey.pem" ) do |ssh|
16
+ # yield ssh
17
+ # end
18
+ # end
19
+ # end
20
+
21
+
22
+ ## works:
23
+ # nginx_root = '/opt/nginx'
24
+ # config = { service_name: 'abba', }
25
+ # Net::SSH.start( "18.209.12.11", "ubuntu", keys: "access/mac_id_rsa_3.pem" ) do |ssh|
26
+ # out = ssh.scp.upload! "tmp/#{config[:service_name]}", "/opt/tmp/two.txt" do |ch, name, sent, total|
27
+ # puts "#{name}: #{sent}/#{total}"
28
+ # end
29
+ # puts! out, 'out'
30
+ # end
31
+
32
+
33
+
34
+
35
+ def create_volume_1 config={}
36
+ puts! config, '#create_volume'
37
+
38
+ out = ` cd #{WORKDIR} ; \
39
+ [ ! -e #{config[:kind]}__prototype.zip ] && wget #{config.tmpl.volume_zip} ; \
40
+ [ ! -e #{config[:kind]}__prototype ] && unzip #{config[:kind]}__prototype.zip ; \
41
+ mv #{config[:kind]}__prototype #{config[:service_name]}_data ; \
42
+ echo ok #create_volume
43
+ `;
44
+ puts! out, 'out'
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.286
4
+ version: 0.0.33.291
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
@@ -233,9 +233,11 @@ files:
233
233
  - lib/video.rb
234
234
  - lib/wco/appliance.rb
235
235
  - lib/wco/appliance_tmpl.rb
236
+ - lib/wco/leadset.rb
236
237
  - lib/wco/price.rb
237
238
  - lib/wco/product.rb
238
239
  - lib/wco/serverhost.rb
240
+ - lib/wco/serverhost.rb-trash
239
241
  - lib/wco/subscription.rb
240
242
  homepage: https://wasya.co
241
243
  licenses: