pd1_tools 0.43.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +12 -0
  3. data/exe/pd1 +8 -0
  4. data/lib/avmtrf1/active_directory/user.rb +28 -0
  5. data/lib/avmtrf1/active_directory.rb +8 -0
  6. data/lib/avmtrf1/ad_user.rb +11 -0
  7. data/lib/avmtrf1/check_point/session/login.rb +57 -0
  8. data/lib/avmtrf1/check_point/session.rb +60 -0
  9. data/lib/avmtrf1/check_point.rb +3 -0
  10. data/lib/avmtrf1/default_esosti.rb +20 -0
  11. data/lib/avmtrf1/default_jira.rb +18 -0
  12. data/lib/avmtrf1/default_redmine.rb +16 -0
  13. data/lib/avmtrf1/docker/image.rb +49 -0
  14. data/lib/avmtrf1/docker/image_runner.rb +83 -0
  15. data/lib/avmtrf1/docker.rb +9 -0
  16. data/lib/avmtrf1/esosti/entities/issue.rb +24 -0
  17. data/lib/avmtrf1/esosti/entities.rb +9 -0
  18. data/lib/avmtrf1/esosti/instance/changed.rb +33 -0
  19. data/lib/avmtrf1/esosti/instance.rb +22 -0
  20. data/lib/avmtrf1/esosti/raw_data_sanitizer.rb +47 -0
  21. data/lib/avmtrf1/esosti/session/action_base.rb +34 -0
  22. data/lib/avmtrf1/esosti/session/atividades.rb +35 -0
  23. data/lib/avmtrf1/esosti/session/login.rb +47 -0
  24. data/lib/avmtrf1/esosti/session/solicitacao/main.rb +49 -0
  25. data/lib/avmtrf1/esosti/session/solicitacao.rb +81 -0
  26. data/lib/avmtrf1/esosti/session.rb +36 -0
  27. data/lib/avmtrf1/esosti.rb +8 -0
  28. data/lib/avmtrf1/executables.rb +23 -0
  29. data/lib/avmtrf1/forponto/parsers/day_registers.rb +19 -0
  30. data/lib/avmtrf1/forponto/parsers/espelho/day_node.rb +50 -0
  31. data/lib/avmtrf1/forponto/parsers/espelho/methods_as_fields.rb +21 -0
  32. data/lib/avmtrf1/forponto/parsers/espelho/row_node.rb +34 -0
  33. data/lib/avmtrf1/forponto/parsers/espelho/rows_consumer.rb +71 -0
  34. data/lib/avmtrf1/forponto/parsers/espelho/sub_node.rb +20 -0
  35. data/lib/avmtrf1/forponto/parsers/espelho/summary_node.rb +55 -0
  36. data/lib/avmtrf1/forponto/parsers/espelho/utils.rb +32 -0
  37. data/lib/avmtrf1/forponto/parsers/espelho.rb +26 -0
  38. data/lib/avmtrf1/forponto/session/day_registers.rb +39 -0
  39. data/lib/avmtrf1/forponto/session/interval.rb +27 -0
  40. data/lib/avmtrf1/forponto/session/login.rb +45 -0
  41. data/lib/avmtrf1/forponto/session.rb +32 -0
  42. data/lib/avmtrf1/forponto/user/balance.rb +155 -0
  43. data/lib/avmtrf1/forponto/user/day_registers.rb +32 -0
  44. data/lib/avmtrf1/forponto/user/month.rb +141 -0
  45. data/lib/avmtrf1/forponto/user.rb +22 -0
  46. data/lib/avmtrf1/git/cached_repository.rb +27 -0
  47. data/lib/avmtrf1/git/gitlab.rb +11 -0
  48. data/lib/avmtrf1/git/issue_on_repository.rb +100 -0
  49. data/lib/avmtrf1/git/push_large/_utils.rb +16 -0
  50. data/lib/avmtrf1/git/push_large/lfs_commit/cache.rb +21 -0
  51. data/lib/avmtrf1/git/push_large/lfs_commit/checkout_previous_revision.rb +35 -0
  52. data/lib/avmtrf1/git/push_large/lfs_commit/commit_changes.rb +48 -0
  53. data/lib/avmtrf1/git/push_large/lfs_commit/helpers.rb +29 -0
  54. data/lib/avmtrf1/git/push_large/lfs_commit/pick_source_revision.rb +103 -0
  55. data/lib/avmtrf1/git/push_large/lfs_commit/push.rb +90 -0
  56. data/lib/avmtrf1/git/push_large/lfs_commit/track_large_files.rb +53 -0
  57. data/lib/avmtrf1/git/push_large/lfs_commit.rb +47 -0
  58. data/lib/avmtrf1/git/push_large/source_commit/push.rb +42 -0
  59. data/lib/avmtrf1/git/push_large/source_commit.rb +58 -0
  60. data/lib/avmtrf1/git/push_large.rb +69 -0
  61. data/lib/avmtrf1/git/reference.rb +34 -0
  62. data/lib/avmtrf1/git.rb +10 -0
  63. data/lib/avmtrf1/gitlab/commit.rb +37 -0
  64. data/lib/avmtrf1/gitlab/repository.rb +41 -0
  65. data/lib/avmtrf1/ini/profile.rb +42 -0
  66. data/lib/avmtrf1/ini.rb +55 -0
  67. data/lib/avmtrf1/inventario_sistemas/parser/body.rb +27 -0
  68. data/lib/avmtrf1/inventario_sistemas/parser/body_row.rb +12 -0
  69. data/lib/avmtrf1/inventario_sistemas/parser/header.rb +38 -0
  70. data/lib/avmtrf1/inventario_sistemas/parser/header_column.rb +27 -0
  71. data/lib/avmtrf1/inventario_sistemas/parser.rb +40 -0
  72. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/elements.rb +54 -0
  73. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/layout.rb +55 -0
  74. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base/stylesheet.css +57 -0
  75. data/lib/avmtrf1/inventario_sistemas/site_build/html_page_base.rb +41 -0
  76. data/lib/avmtrf1/inventario_sistemas/site_build/index.rb +20 -0
  77. data/lib/avmtrf1/inventario_sistemas/site_build/sistema.rb +62 -0
  78. data/lib/avmtrf1/inventario_sistemas/site_build/sistemas_index.rb +31 -0
  79. data/lib/avmtrf1/inventario_sistemas/site_build.rb +71 -0
  80. data/lib/avmtrf1/inventario_sistemas.rb +38 -0
  81. data/lib/avmtrf1/issues/factory.rb +22 -0
  82. data/lib/avmtrf1/issues.rb +7 -0
  83. data/lib/avmtrf1/jira/entities/issue.rb +30 -0
  84. data/lib/avmtrf1/jira/entities.rb +9 -0
  85. data/lib/avmtrf1/jira/instance.rb +28 -0
  86. data/lib/avmtrf1/jira.rb +8 -0
  87. data/lib/avmtrf1/node_js/docker_image.rb +14 -0
  88. data/lib/avmtrf1/node_js.rb +9 -0
  89. data/lib/avmtrf1/openvpn/config/builder.rb +59 -0
  90. data/lib/avmtrf1/openvpn/config/parser/builder.rb +62 -0
  91. data/lib/avmtrf1/openvpn/config/parser/line.rb +47 -0
  92. data/lib/avmtrf1/openvpn/config/parser/simple.rb +27 -0
  93. data/lib/avmtrf1/openvpn/config/parser/tag.rb +39 -0
  94. data/lib/avmtrf1/openvpn/config/parser.rb +20 -0
  95. data/lib/avmtrf1/oracle/connection/base.rb +66 -0
  96. data/lib/avmtrf1/oracle/connection/string_builder.rb +44 -0
  97. data/lib/avmtrf1/oracle/connection.rb +12 -0
  98. data/lib/avmtrf1/oracle/object/base.rb +39 -0
  99. data/lib/avmtrf1/oracle/object/table.rb +15 -0
  100. data/lib/avmtrf1/oracle/object/user.rb +15 -0
  101. data/lib/avmtrf1/oracle/object/view.rb +15 -0
  102. data/lib/avmtrf1/oracle/object.rb +25 -0
  103. data/lib/avmtrf1/oracle/objects/relation.rb +23 -0
  104. data/lib/avmtrf1/oracle/objects/sql_builder.rb +64 -0
  105. data/lib/avmtrf1/oracle/objects.rb +53 -0
  106. data/lib/avmtrf1/oracle/oci8.rb +29 -0
  107. data/lib/avmtrf1/oracle.rb +10 -0
  108. data/lib/avmtrf1/patches/avm/git/issue/complete.rb +50 -0
  109. data/lib/avmtrf1/patches/avm/git/issue.rb +4 -0
  110. data/lib/avmtrf1/patches/avm/git/launcher/base.rb +46 -0
  111. data/lib/avmtrf1/patches/avm/git/launcher.rb +4 -0
  112. data/lib/avmtrf1/patches/avm/git.rb +4 -0
  113. data/lib/avmtrf1/patches/avm.rb +4 -0
  114. data/lib/avmtrf1/patches/inifile.rb +13 -0
  115. data/lib/avmtrf1/patches.rb +4 -0
  116. data/lib/avmtrf1/php/docker_images/base.rb +49 -0
  117. data/lib/avmtrf1/php/docker_images/factory.rb +37 -0
  118. data/lib/avmtrf1/php/docker_images/v5.rb +47 -0
  119. data/lib/avmtrf1/php/docker_images/v7.rb +27 -0
  120. data/lib/avmtrf1/php/docker_images/v7_v4.rb +30 -0
  121. data/lib/avmtrf1/php/docker_images/v8.rb +19 -0
  122. data/lib/avmtrf1/php/docker_images.rb +11 -0
  123. data/lib/avmtrf1/php.rb +9 -0
  124. data/lib/avmtrf1/red/client/authorization.xml.erb +4 -0
  125. data/lib/avmtrf1/red/client.rb +38 -0
  126. data/lib/avmtrf1/red/helper.rb +35 -0
  127. data/lib/avmtrf1/red/profile/put_file.xml.erb +19 -0
  128. data/lib/avmtrf1/red/profile.rb +58 -0
  129. data/lib/avmtrf1/red/server.rb +33 -0
  130. data/lib/avmtrf1/red.rb +5 -0
  131. data/lib/avmtrf1/redmine/entities/issue.rb +29 -0
  132. data/lib/avmtrf1/redmine/entities/issue_status.rb +23 -0
  133. data/lib/avmtrf1/redmine/entities.rb +10 -0
  134. data/lib/avmtrf1/redmine/instance.rb +41 -0
  135. data/lib/avmtrf1/redmine.rb +7 -0
  136. data/lib/avmtrf1/rest_provider/entity.rb +18 -0
  137. data/lib/avmtrf1/rest_provider/instance/issues.rb +30 -0
  138. data/lib/avmtrf1/rest_provider/instance.rb +30 -0
  139. data/lib/avmtrf1/rest_provider/request.rb +44 -0
  140. data/lib/avmtrf1/rest_provider/response.rb +73 -0
  141. data/lib/avmtrf1/rest_provider.rb +7 -0
  142. data/lib/avmtrf1/result.rb +44 -0
  143. data/lib/avmtrf1/ruby.rb +9 -0
  144. data/lib/avmtrf1/tools/application.rb +13 -0
  145. data/lib/avmtrf1/tools/core_ext.rb +4 -0
  146. data/lib/avmtrf1/tools/msgraph/api/entity.rb +35 -0
  147. data/lib/avmtrf1/tools/msgraph/api/member.rb +31 -0
  148. data/lib/avmtrf1/tools/msgraph/api/root.rb +27 -0
  149. data/lib/avmtrf1/tools/msgraph/api/team/member_add.rb +36 -0
  150. data/lib/avmtrf1/tools/msgraph/api/team.rb +40 -0
  151. data/lib/avmtrf1/tools/msgraph/api.rb +55 -0
  152. data/lib/avmtrf1/tools/msgraph/error.rb +31 -0
  153. data/lib/avmtrf1/tools/msgraph/request_mixin.rb +18 -0
  154. data/lib/avmtrf1/tools/msgraph/response_mixin.rb +23 -0
  155. data/lib/avmtrf1/tools/msgraph/token_retrieve.rb +42 -0
  156. data/lib/avmtrf1/tools/msgraph.rb +11 -0
  157. data/lib/avmtrf1/tools/rubygems/dependency.rb +20 -0
  158. data/lib/avmtrf1/tools/rubygems/not_found_error.rb +17 -0
  159. data/lib/avmtrf1/tools/rubygems.rb +11 -0
  160. data/lib/avmtrf1/tools/runner/check_point/login.rb +33 -0
  161. data/lib/avmtrf1/tools/runner/check_point.rb +17 -0
  162. data/lib/avmtrf1/tools/runner/esosti/changed.rb +39 -0
  163. data/lib/avmtrf1/tools/runner/esosti/fetch.rb +39 -0
  164. data/lib/avmtrf1/tools/runner/esosti/request.rb +76 -0
  165. data/lib/avmtrf1/tools/runner/esosti.rb +27 -0
  166. data/lib/avmtrf1/tools/runner/forponto/espelho.rb +47 -0
  167. data/lib/avmtrf1/tools/runner/forponto/marcacoes.rb +32 -0
  168. data/lib/avmtrf1/tools/runner/forponto/resumos.rb +87 -0
  169. data/lib/avmtrf1/tools/runner/forponto/saldo.rb +91 -0
  170. data/lib/avmtrf1/tools/runner/forponto.rb +70 -0
  171. data/lib/avmtrf1/tools/runner/git/gitlab/commit_link.rb +81 -0
  172. data/lib/avmtrf1/tools/runner/git/gitlab.rb +20 -0
  173. data/lib/avmtrf1/tools/runner/git/issues_check.rb +59 -0
  174. data/lib/avmtrf1/tools/runner/git/push_large.rb +46 -0
  175. data/lib/avmtrf1/tools/runner/git.rb +14 -0
  176. data/lib/avmtrf1/tools/runner/inventario_sistemas.rb +71 -0
  177. data/lib/avmtrf1/tools/runner/msgraph/joined_teams.rb +39 -0
  178. data/lib/avmtrf1/tools/runner/msgraph/request.rb +45 -0
  179. data/lib/avmtrf1/tools/runner/msgraph/team/member/add.rb +48 -0
  180. data/lib/avmtrf1/tools/runner/msgraph/team/member.rb +25 -0
  181. data/lib/avmtrf1/tools/runner/msgraph/team/members.rb +38 -0
  182. data/lib/avmtrf1/tools/runner/msgraph/team.rb +27 -0
  183. data/lib/avmtrf1/tools/runner/msgraph/token.rb +31 -0
  184. data/lib/avmtrf1/tools/runner/msgraph.rb +43 -0
  185. data/lib/avmtrf1/tools/runner/node_js/docker.rb +15 -0
  186. data/lib/avmtrf1/tools/runner/node_js.rb +18 -0
  187. data/lib/avmtrf1/tools/runner/openvpn.rb +91 -0
  188. data/lib/avmtrf1/tools/runner/oracle/query.rb +71 -0
  189. data/lib/avmtrf1/tools/runner/oracle/source_get.rb +51 -0
  190. data/lib/avmtrf1/tools/runner/oracle/user_clear.rb +59 -0
  191. data/lib/avmtrf1/tools/runner/oracle.rb +37 -0
  192. data/lib/avmtrf1/tools/runner/php/docker.rb +20 -0
  193. data/lib/avmtrf1/tools/runner/php.rb +18 -0
  194. data/lib/avmtrf1/tools/runner/red.rb +83 -0
  195. data/lib/avmtrf1/tools/runner/source.rb +14 -0
  196. data/lib/avmtrf1/tools/runner.rb +43 -0
  197. data/lib/avmtrf1/tools.rb +4 -0
  198. data/lib/pd1_tools/version.rb +5 -0
  199. data/lib/pd1_tools.rb +7 -0
  200. data/template/avmtrf1/node_js/docker_image/Dockerfile.template +25 -0
  201. data/template/avmtrf1/node_js/docker_image/auxiliary/config_banner.sh +15 -0
  202. data/template/avmtrf1/node_js/docker_image/auxiliary/init.sh +18 -0
  203. data/template/avmtrf1/node_js/docker_image/auxiliary/lib.sh +30 -0
  204. data/template/avmtrf1/node_js/docker_image/auxiliary/ng_serve.sh +16 -0
  205. data/template/avmtrf1/node_js/docker_image/auxiliary/npm_install.sh +21 -0
  206. data/template/avmtrf1/node_js/docker_image/auxiliary/start.sh +17 -0
  207. data/template/avmtrf1/php/docker_images/base/Dockerfile.template +104 -0
  208. data/template/avmtrf1/php/docker_images/base/aux/apache_foreground.sh +16 -0
  209. data/template/avmtrf1/php/docker_images/base/aux/apache_user.sh +54 -0
  210. data/template/avmtrf1/php/docker_images/base/aux/app_user_run.sh +17 -0
  211. data/template/avmtrf1/php/docker_images/base/aux/config_banner.sh +20 -0
  212. data/template/avmtrf1/php/docker_images/base/aux/init.sh +39 -0
  213. data/template/avmtrf1/php/docker_images/base/aux/laravel.sh +58 -0
  214. data/template/avmtrf1/php/docker_images/base/aux/lib.sh +70 -0
  215. data/template/avmtrf1/php/docker_images/base/aux/pear.sh +35 -0
  216. data/template/avmtrf1/php/docker_images/base/aux/php_composer.sh +31 -0
  217. data/template/avmtrf1/php/docker_images/base/aux/php_values.sh +41 -0
  218. data/template/avmtrf1/php/docker_images/base/aux/setup_apache_site.sh +16 -0
  219. data/template/avmtrf1/php/docker_images/base/aux/start.sh +26 -0
  220. data/template/avmtrf1/php/docker_images/base/aux/templates/apache_site.conf +12 -0
  221. data/template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py +85 -0
  222. metadata +460 -0
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/ad_user'
4
+ require 'avmtrf1/executables'
5
+ require 'avmtrf1/openvpn/config/builder'
6
+ require 'eac_cli/core_ext'
7
+
8
+ module Avmtrf1
9
+ module Tools
10
+ class Runner
11
+ class Openvpn
12
+ runner_with :help do
13
+ desc 'Conecta-se utilizando OpenVPN com configurações dinâmicas.'
14
+ bool_opt '-S', '--no-sudo', 'Não executa com "sudo".'
15
+ bool_opt '-A', '--no-ad-auth', 'Não utiliza autenticação do Active Directory.'
16
+ pos_arg :ovpn_path
17
+ end
18
+
19
+ def run
20
+ on_temp_files do
21
+ start_banner
22
+ infov 'Resultado', command.system
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ attr_accessor :credentials_path, :ovpn_config_path
29
+
30
+ def ad_auth?
31
+ !parsed.no_ad_auth?
32
+ end
33
+
34
+ def command_uncached
35
+ if parsed.no_sudo?
36
+ ::Avmtrf1::Executables.env.command(*openvpn_args)
37
+ else
38
+ ::Avmtrf1::Executables.sudo.command(*openvpn_args)
39
+ end
40
+ end
41
+
42
+ def config_builder_uncached
43
+ r = ::Avmtrf1::Openvpn::Config::Builder.new(parsed.ovpn_path)
44
+ r.simple_add_or_update('auth-user-pass', [credentials_path.to_path]) if ad_auth?
45
+ r
46
+ end
47
+
48
+ def openvpn_args
49
+ ['openvpn', '--config', ovpn_config_path]
50
+ end
51
+
52
+ def start_banner
53
+ infov 'Arquivo de configuração', parsed.ovpn_path
54
+ infov 'Linha de comando', ::Shellwords.join(command.args)
55
+ end
56
+
57
+ def on_temp_files(&block)
58
+ on_credentials_file do
59
+ on_config_file(&block)
60
+ end
61
+ end
62
+
63
+ def on_credentials_file(&block)
64
+ if ad_auth?
65
+ on_temp_file(:credentials_path, -> { credentials_content }, &block)
66
+ else
67
+ block.call
68
+ end
69
+ end
70
+
71
+ def on_config_file(&block)
72
+ on_temp_file(:ovpn_config_path, -> { config_builder.data }, &block)
73
+ end
74
+
75
+ def on_temp_file(attr, content_proc)
76
+ ::EacRubyUtils::Fs::Temp.on_file do |file|
77
+ file.write(content_proc.call)
78
+ send("#{attr}=", file)
79
+ yield
80
+ send("#{attr}=", nil)
81
+ end
82
+ end
83
+
84
+ def credentials_content
85
+ [::Avmtrf1.ad_user.username, ::Avmtrf1.ad_user.password]
86
+ .map { |v| "#{v}\n" }.join
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ class Runner
8
+ class Oracle
9
+ class Query
10
+ DEFAULT_COLUMN_SEPARATOR = "\t"
11
+ DEFAULT_ROW_SEPARATOR = "\n"
12
+
13
+ runner_with :help do
14
+ desc 'Executa queries Oracle.'
15
+ arg_opt '-c', '--column-sep', 'Separator de colunas.'
16
+ bool_opt '-C', '--columns', 'Imprime o nome das colunas.'
17
+ arg_opt '-r', '--row-sep', 'Separator de registros.'
18
+ bool_opt '-t', '--count', 'Imprime a quantidade de registros retornados.'
19
+ pos_arg 'sql'
20
+ end
21
+
22
+ attr_reader :count
23
+
24
+ def run
25
+ print_header
26
+ print_body
27
+ print_footer
28
+ end
29
+
30
+ def print_header
31
+ return unless parsed.columns?
32
+
33
+ print_row(cursor.column_metadata.map(&:name))
34
+ end
35
+
36
+ def print_body
37
+ @count = 0
38
+ cursor.fetch do |row|
39
+ print_row(row)
40
+ @count += 1
41
+ end
42
+ end
43
+
44
+ def print_footer
45
+ return unless parsed.count?
46
+
47
+ print_row(["Count: #{count}"])
48
+ end
49
+
50
+ private
51
+
52
+ def column_separator_uncached
53
+ parsed.column_sep.if_present(DEFAULT_COLUMN_SEPARATOR)
54
+ end
55
+
56
+ def cursor_uncached
57
+ runner_context.call(:connection).query(parsed.sql)
58
+ end
59
+
60
+ def print_row(array)
61
+ out array.join(column_separator) + row_separator
62
+ end
63
+
64
+ def row_separator_uncached
65
+ parsed.row_sep.if_present(DEFAULT_ROW_SEPARATOR)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ class Runner
8
+ class Oracle
9
+ class SourceGet
10
+ runner_with :help do
11
+ pos_arg :name
12
+ pos_arg :type
13
+ end
14
+
15
+ TABLE = 'all_source'
16
+
17
+ delegate :name, to: :parsed
18
+
19
+ delegate :type, to: :parsed
20
+
21
+ def run
22
+ infov('Name', name)
23
+ infov('Type', type)
24
+ infov('Found', found_count)
25
+ infov('Enconding', OCI8.encoding)
26
+ connection.query(sql(false)) do |row|
27
+ out(row['TEXT'].encode('UTF-8').to_s)
28
+ end
29
+ end
30
+
31
+ def found_count
32
+ connection.unique_value(sql(true)).to_i
33
+ end
34
+
35
+ def sql(count)
36
+ projection = count ? 'count(*)' : '*'
37
+ selection = "lower(name) = lower('#{name}')"
38
+ selection += " and lower(type) = lower('#{type}')" if type.present?
39
+ "select #{projection} from #{TABLE} where #{selection} order by line"
40
+ end
41
+
42
+ private
43
+
44
+ def connection
45
+ runner_context.call(:connection)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ class Runner
8
+ class Oracle
9
+ class UserClear
10
+ SELECTED_TYPES = %w[FUNCTION PACKAGE PROCEDURE SEQUENCE TABLE VIEW].freeze
11
+
12
+ runner_with :confirmation, :help do
13
+ desc 'Remove todos os objetos (Tabelas, views, etc) de um usuário Oracle.'
14
+ bool_opt '-y', '--yes', 'Remove sem perguntar.'
15
+ bool_opt '-d', '--drop', 'Remove os objetos.'
16
+ pos_arg 'owner-name'
17
+ end
18
+
19
+ def run
20
+ objects_banner
21
+ drop_objects
22
+ end
23
+
24
+ private
25
+
26
+ def objects_banner
27
+ infov 'Owner', owner
28
+ infov 'Objects'
29
+ count = 0
30
+ objects.each do |object|
31
+ infov " * #{object.type}", object.fullname
32
+ count += 1
33
+ end
34
+ infov 'Total', count
35
+ end
36
+
37
+ def drop_objects
38
+ return unless parsed.drop
39
+ return unless confirm?('Confirma a remoção?')
40
+
41
+ infom 'Removendo objetos...'
42
+ objects.each do |object|
43
+ infom "Removendo \"#{object}\"..."
44
+ object.drop
45
+ end
46
+ end
47
+
48
+ def owner_uncached
49
+ runner_context.call(:connection).objects.first(name: parsed.owner_name, type: :user)
50
+ end
51
+
52
+ def objects_uncached
53
+ owner.objects(type: SELECTED_TYPES)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+ require 'avmtrf1/oracle/connection/base'
5
+ require 'avmtrf1/oracle/connection/string_builder'
6
+
7
+ module Avmtrf1
8
+ module Tools
9
+ class Runner
10
+ class Oracle
11
+ require_sub __FILE__
12
+ runner_with :help, :subcommands do
13
+ arg_opt '-H', '--host', 'Host Oracle (Ex.: 172.16.3.3)'
14
+ arg_opt '-p', '--port', 'Porta Oracle (Ex.: 1521) (Padrão: 1521)'
15
+ arg_opt '-s', '--service-name', 'Serviço Oracle (Ex.: trf1.trf1.gov.br)'
16
+ arg_opt '-u', '--user', 'Usuário Oracle'
17
+ arg_opt '-w', '--password', 'Senha Oracle'
18
+ subcommands
19
+ end
20
+
21
+ def connection
22
+ @connection ||= ::Avmtrf1::Oracle::Connection::Base.new(connection_string)
23
+ end
24
+
25
+ def connection_string
26
+ ::Avmtrf1::Oracle::Connection::StringBuilder.new(
27
+ host: parsed.host,
28
+ port: parsed.port,
29
+ user: parsed.user,
30
+ password: parsed.password,
31
+ service_name: parsed.service_name
32
+ ).build
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/php/docker_images/factory'
4
+ require 'avmtrf1/docker/image_runner'
5
+ require 'eac_cli/core_ext'
6
+ require 'eac_docker/registry'
7
+
8
+ module Avmtrf1
9
+ module Tools
10
+ class Runner
11
+ class Php
12
+ class Docker < ::Avmtrf1::Docker::ImageRunner
13
+ def docker_image_class(platform_version)
14
+ ::Avmtrf1::Php::DockerImages::Factory.new(platform_version).result
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ class Runner
8
+ class Php
9
+ require_sub __FILE__
10
+
11
+ runner_with :help, :subcommands do
12
+ desc 'Utilidades para PHP.'
13
+ subcommands
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+ require 'avmtrf1/ini'
5
+ require 'avmtrf1/red/profile'
6
+
7
+ module Avmtrf1
8
+ module Tools
9
+ class Runner
10
+ class Red
11
+ RED_PROFILE_DEFAULT = 'development'
12
+
13
+ runner_with :help do
14
+ desc 'Utilidades para RED.'
15
+ arg_opt '-i', '--red-ini', 'Arquivo red.ini com parâmetros de conexão e upload.'
16
+ arg_opt '-p', '--red-profile', 'Perfil/seção do red.ini ' \
17
+ "[default: #{RED_PROFILE_DEFAULT}]."
18
+ arg_opt '--put', 'Envia um arquivo.'
19
+ end
20
+
21
+ def put?
22
+ parsed.put.present?
23
+ end
24
+
25
+ def run
26
+ start_banner
27
+ if put?
28
+ file_put
29
+ else
30
+ fatal_error('Subcomando não mapeado (Isto é um defeito do software)')
31
+ end
32
+ end
33
+
34
+ def start_banner
35
+ infov 'red.ini', parsed.red_ini
36
+ infov 'Perfil de red.ini', red_profile_name
37
+ infov 'Arquivo para upload', parsed.put
38
+ end
39
+
40
+ def file_put
41
+ result = red_profile.put_file(file)
42
+ require 'pp' # rubocop:disable Lint/RedundantRequireStatement
43
+ puts '>' * 20
44
+ puts result
45
+ puts '<' * 20
46
+ end
47
+
48
+ def red_profile_name
49
+ parsed.red_profile.if_present(RED_PROFILE_DEFAULT)
50
+ end
51
+
52
+ def red_profile_uncached
53
+ ::Avmtrf1::Red::Profile.by_ini_profile(red_ini_profile)
54
+ end
55
+
56
+ def file
57
+ required_file(:put)
58
+ end
59
+
60
+ def red_ini_path_uncached
61
+ required_file(:red_ini)
62
+ end
63
+
64
+ def red_ini_uncached
65
+ ::Avmtrf1::Ini.new(red_ini_path)
66
+ end
67
+
68
+ def red_ini_profile
69
+ return red_ini.profiles[red_profile_name] if red_ini.profiles.key?(red_profile_name)
70
+
71
+ fatal_error "Perfil/seção \"#{red_profile_name}\" não encontrada em \"#{red_ini_path}\""
72
+ end
73
+
74
+ def required_file(option_key)
75
+ path = parsed[option_key]
76
+ return path if path
77
+
78
+ fatal_error("Arquivo \"#{path}\" não existe (Informado na opção #{option_key})")
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/tools/runner/source'
4
+ require 'avmtrf1/tools/core_ext'
5
+
6
+ module Avmtrf1
7
+ module Tools
8
+ class Runner
9
+ class Source < ::Avm::Tools::Runner::Source
10
+ require_sub __FILE__
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/node'
4
+ require 'aranha/selenium/driver_factory/base'
5
+ require 'avmtrf1/tools/rubygems/not_found_error'
6
+ require 'avmtrf1/tools/application'
7
+ require 'eac_ruby_base0/runner'
8
+
9
+ module Avmtrf1
10
+ module Tools
11
+ class Runner
12
+ require_sub __FILE__
13
+ include ::EacRubyBase0::Runner
14
+
15
+ runner_definition do
16
+ desc 'Utilidades para AVM-TRF1 (http://redmine.trf1.gov.br/projects/avm-trf1).'
17
+ bool_opt '-H', '--headless',
18
+ 'Quando usando Selenium não mostra a interface gráfica do navegador web.'
19
+ end
20
+
21
+ def application
22
+ ::Avmtrf1::Tools.application
23
+ end
24
+
25
+ def run
26
+ ::Aranha::Selenium::DriverFactory::Base.default_headless = parsed.headless?
27
+ super
28
+ rescue ::Avmtrf1::Tools::Rubygems::NotFoundError => e
29
+ on_gem_not_found(e.dependency)
30
+ end
31
+
32
+ private
33
+
34
+ def on_gem_not_found(dependency)
35
+ fatal_error "A gem \"#{dependency.gem_name}\" foi requerida " \
36
+ "(Por \"require '#{dependency.lib_name}'\") " \
37
+ "e não encontrada. Para instalá-la:\n\n " \
38
+ "gem install #{dependency.gem_name}\n\n" \
39
+ 'Nota: procedimentos adicionais podem ser necessários.'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/runner'
4
+ require 'avmtrf1/tools/version'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pd1Tools
4
+ VERSION = '0.43.0'
5
+ end
data/lib/pd1_tools.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+
5
+ module Pd1Tools
6
+ ::EacRubyUtils.require_sub(__FILE__)
7
+ end
@@ -0,0 +1,25 @@
1
+ # base image
2
+ FROM node:%%PLATFORM_VERSION%%
3
+
4
+ %%APT_SETUP%%
5
+
6
+ # ASDF - 0.12.0
7
+ ENV ASDF_DIR='/opt/asdf'
8
+ ENV ASDF_PACKAGE='https://github.com/asdf-vm/asdf/archive/816195d615427b033a7426a4fb4d7fac4cf2d791.tar.gz'
9
+ RUN mkdir -p "${ASDF_DIR}"
10
+ RUN wget -qO- "${ASDF_PACKAGE}" | tar -xzf - --strip-components 1 -C "${ASDF_DIR}"
11
+
12
+ # Python
13
+ ENV PYTHON_VERSION='3.6.15'
14
+ RUN "${ASDF_DIR}/bin/asdf" plugin add python
15
+ RUN "${ASDF_DIR}/bin/asdf" install python "${PYTHON_VERSION}"
16
+ RUN "${ASDF_DIR}/bin/asdf" global python "${PYTHON_VERSION}"
17
+
18
+ # Inicializador
19
+ RUN mkdir '/auxiliary'
20
+ RUN mkdir '/auxiliary/eac-bash-lib'
21
+ RUN wget -qO- https://github.com/esquilo-azul/eac-bash-lib/archive/449833c28d645e5925a4cc4bdb6a127eba80d38c.tar.gz \
22
+ | tar -xzf - --strip-components 1 -C '/auxiliary/eac-bash-lib'
23
+ ADD auxiliary '/auxiliary'
24
+ RUN chmod -R +x '/auxiliary'
25
+ CMD '/auxiliary/start.sh'
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ set -u
4
+ set -e
5
+
6
+ SOURCE="${BASH_SOURCE[0]}"
7
+ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
8
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
9
+ SOURCE="$(readlink "$SOURCE")"
10
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
11
+ done
12
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
13
+ source "$DIR/init.sh"
14
+
15
+ infov 'Application root path ($APP_ROOT)' "$APP_ROOT"
@@ -0,0 +1,18 @@
1
+ set -u
2
+ set -e
3
+
4
+ SOURCE="${BASH_SOURCE[0]}"
5
+ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
6
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
7
+ SOURCE="$(readlink "$SOURCE")"
8
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
9
+ done
10
+ export AUX_ROOT="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
11
+
12
+ source "$AUX_ROOT/lib.sh"
13
+ source "${ASDF_DIR}/asdf.sh"
14
+
15
+ # Caminho raiz da aplicação
16
+ path_set 'APP_ROOT' '/' '/app'
17
+
18
+ export PATH="$APP_ROOT/node_modules/.bin:$PATH"
@@ -0,0 +1,30 @@
1
+ set -u
2
+ set -e
3
+
4
+ source "$AUX_ROOT/eac-bash-lib/init.sh"
5
+
6
+ function join_paths() {
7
+ PATH_ARG="$1"
8
+ BASE_ARG="$2"
9
+
10
+ if [[ "$PATH_ARG" == '/'* ]]; then
11
+ printf -- "%s\n" "$PATH_ARG"
12
+ else
13
+ printf -- "%s/%s\n" "$BASE_ARG" "$PATH_ARG"
14
+ fi
15
+ }
16
+
17
+ function path_set() {
18
+ VARIABLE_NAME="$1"
19
+ BASE_PATH="$2"
20
+ DEFAULT_VALUE="$3"
21
+
22
+ RESULT="$DEFAULT_VALUE"
23
+ if var_present_r "$VARIABLE_NAME"; then
24
+ RESULT="$(join_paths "${!VARIABLE_NAME}" "$BASE_PATH")"
25
+ fi
26
+ if [ ! -d "$RESULT" ]; then
27
+ fatal_error "Caminho \"$RESULT\" (\$$VARIABLE_NAME) não existe ou não é um diretório"
28
+ fi
29
+ export $VARIABLE_NAME="$RESULT"
30
+ }
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ set -u
4
+ set -e
5
+
6
+ SOURCE="${BASH_SOURCE[0]}"
7
+ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
8
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
9
+ SOURCE="$(readlink "$SOURCE")"
10
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
11
+ done
12
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
13
+ source "$DIR/init.sh"
14
+
15
+ infom "Executando \"ng serve\"..."
16
+ (cd "$APP_ROOT"; ng serve --host 0.0.0.0 )
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ set -u
4
+ set -e
5
+
6
+ SOURCE="${BASH_SOURCE[0]}"
7
+ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
8
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
9
+ SOURCE="$(readlink "$SOURCE")"
10
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
11
+ done
12
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
13
+ source "$DIR/init.sh"
14
+
15
+ function npm_install() {
16
+ (cd "$APP_ROOT"; npm install "$@")
17
+ }
18
+
19
+ infom "Executando \"npm install\"..."
20
+ npm_install --save-dev --unsafe-perm node-sass
21
+ npm_install
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ set -u
4
+ set -e
5
+
6
+ SOURCE="${BASH_SOURCE[0]}"
7
+ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
8
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
9
+ SOURCE="$(readlink "$SOURCE")"
10
+ [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
11
+ done
12
+ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
13
+ source "$DIR/init.sh"
14
+
15
+ "$AUX_ROOT/config_banner.sh"
16
+ "$AUX_ROOT/npm_install.sh"
17
+ "$AUX_ROOT/ng_serve.sh"