xolo-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +177 -0
  3. data/README.md +7 -0
  4. data/bin/xoloserver +106 -0
  5. data/data/com.pixar.xoloserver.plist +29 -0
  6. data/data/uninstall-pkgs-by-id.zsh +103 -0
  7. data/lib/xolo/server/app.rb +133 -0
  8. data/lib/xolo/server/command_line.rb +216 -0
  9. data/lib/xolo/server/configuration.rb +739 -0
  10. data/lib/xolo/server/constants.rb +70 -0
  11. data/lib/xolo/server/helpers/auth.rb +257 -0
  12. data/lib/xolo/server/helpers/client_data.rb +415 -0
  13. data/lib/xolo/server/helpers/file_transfers.rb +265 -0
  14. data/lib/xolo/server/helpers/jamf_pro.rb +156 -0
  15. data/lib/xolo/server/helpers/log.rb +97 -0
  16. data/lib/xolo/server/helpers/maintenance.rb +401 -0
  17. data/lib/xolo/server/helpers/notification.rb +145 -0
  18. data/lib/xolo/server/helpers/pkg_signing.rb +141 -0
  19. data/lib/xolo/server/helpers/progress_streaming.rb +252 -0
  20. data/lib/xolo/server/helpers/title_editor.rb +92 -0
  21. data/lib/xolo/server/helpers/titles.rb +145 -0
  22. data/lib/xolo/server/helpers/versions.rb +160 -0
  23. data/lib/xolo/server/log.rb +286 -0
  24. data/lib/xolo/server/mixins/changelog.rb +315 -0
  25. data/lib/xolo/server/mixins/title_jamf_access.rb +1668 -0
  26. data/lib/xolo/server/mixins/title_ted_access.rb +519 -0
  27. data/lib/xolo/server/mixins/version_jamf_access.rb +1541 -0
  28. data/lib/xolo/server/mixins/version_ted_access.rb +373 -0
  29. data/lib/xolo/server/object_locks.rb +102 -0
  30. data/lib/xolo/server/routes/auth.rb +89 -0
  31. data/lib/xolo/server/routes/jamf_pro.rb +89 -0
  32. data/lib/xolo/server/routes/maint.rb +174 -0
  33. data/lib/xolo/server/routes/title_editor.rb +71 -0
  34. data/lib/xolo/server/routes/titles.rb +285 -0
  35. data/lib/xolo/server/routes/uploads.rb +93 -0
  36. data/lib/xolo/server/routes/versions.rb +261 -0
  37. data/lib/xolo/server/routes.rb +168 -0
  38. data/lib/xolo/server/title.rb +1143 -0
  39. data/lib/xolo/server/version.rb +902 -0
  40. data/lib/xolo/server.rb +205 -0
  41. data/lib/xolo-server.rb +8 -0
  42. metadata +243 -0
@@ -0,0 +1,216 @@
1
+ # Copyright 2025 Pixar
2
+ #
3
+ # Licensed under the terms set forth in the LICENSE.txt file available at
4
+ # at the root of this project.
5
+ #
6
+
7
+ # frozen_string_literal: true
8
+
9
+ require 'optimist_with_insert_blanks'
10
+
11
+ module Xolo
12
+
13
+ module Server
14
+
15
+ # Module for parsing and validating the xadm options from the commandline
16
+ module CommandLine
17
+
18
+ # when this module is included
19
+ def self.included(includer)
20
+ Xolo.verbose_include includer, self
21
+ end
22
+
23
+ # when this module is extended
24
+ def self.extended(extender)
25
+ Xolo.verbose_extend extender, self
26
+ end
27
+
28
+ #### Constants
29
+ #########################
30
+
31
+ CONFIG_CMD = 'config'
32
+
33
+ SUBCOMMANDS = [CONFIG_CMD].freeze
34
+
35
+ CLI_OPTIONS = {
36
+ production: {
37
+ label: 'Production',
38
+ cli: :p,
39
+ walkthru: false,
40
+ desc: <<~ENDDESC
41
+ Run xoloserver in production mode.
42
+ This sets various server settings to production mode, including setting the log-level to 'info' at start-time, unless -d is also given.
43
+
44
+ By default the server starts in development mode, and the log level is 'debug'
45
+ ENDDESC
46
+ },
47
+
48
+ debug: {
49
+ label: 'Debug',
50
+ cli: :d,
51
+ walkthru: false,
52
+ desc: <<~ENDDESC
53
+ Run xoloserver in debug mode. This sets the log-level to 'debug' at start-time in production mode.
54
+ ENDDESC
55
+ }
56
+ }.freeze
57
+
58
+ # CLI usage message
59
+ ################################################
60
+ def usage
61
+ @usage ||= "#{Xolo::Server::EXECUTABLE_FILENAME} --production --debug --help --version [config --help options args]"
62
+ end
63
+
64
+ # An OStruct to hold the CLI options
65
+ ################################################
66
+ def cli_opts
67
+ @cli_opts ||= {}
68
+ end
69
+
70
+ # An OStruct to hold the config subcommand options
71
+ ################################################
72
+ def config_opts
73
+ @config_opts ||= {}
74
+ end
75
+
76
+ # Use optimist to parse ARGV.
77
+ ################################################
78
+ def parse_cli
79
+ # get the global options
80
+ parse_global_opts
81
+ return if ARGV.empty?
82
+
83
+ # if there are subcommands, parse them
84
+ subcommand = ARGV.shift
85
+ case subcommand
86
+ when CONFIG_CMD
87
+ parse_config_opts
88
+ else
89
+ Optimist.die "Unknown subcommand: #{subcommand}"
90
+ end
91
+ end
92
+
93
+ # Parse the main/global options
94
+ ################################################
95
+ def parse_global_opts
96
+ usg = usage
97
+ @cli_opts = Optimist.options do
98
+ stop_on SUBCOMMANDS
99
+ version "Xolo version: #{Xolo::VERSION}"
100
+ synopsis <<~SYNOPSIS
101
+ Name:
102
+ #{Xolo::Server::EXECUTABLE_FILENAME}, The server for 'xolo', a tool for managing Patch Titles and Versions in Jamf Pro
103
+
104
+ Usage:
105
+ #{usg}
106
+
107
+ See '#{Xolo::Server::EXECUTABLE_FILENAME} config --help' for configuration options.
108
+ SYNOPSIS
109
+
110
+ # add a blank line between each of the cli options in the help output
111
+ # NOTE: chrisl added this to the optimist.rb included in this project.
112
+ insert_blanks
113
+
114
+ # The global opts
115
+ ## manually set :version and :help here, or they appear at the bottom of the help
116
+ opt :version, 'Print version and exit'
117
+ opt :help, 'Show this help and exit'
118
+
119
+ CLI_OPTIONS.each do |opt_key, deets|
120
+ opt opt_key, deets[:desc], short: deets[:cli]
121
+ end
122
+ end # Optimist.options
123
+ end
124
+
125
+ # Parse the config subcommand options
126
+ ################################################
127
+ def parse_config_opts
128
+ if ARGV.empty?
129
+ config_opts[:show] = true
130
+ return
131
+ end
132
+
133
+ @config_opts = Optimist.options do
134
+ synopsis <<~ENDSYNOPSIS
135
+ NAME
136
+ #{Xolo::Server::EXECUTABLE_FILENAME} #{CONFIG_CMD} - Manage the server configuration file
137
+
138
+ SYNOPSIS
139
+ #{Xolo::Server::EXECUTABLE_FILENAME} #{CONFIG_CMD} [--show] [--expand] [config_key ...]
140
+
141
+ #{Xolo::Server::EXECUTABLE_FILENAME} #{CONFIG_CMD} --set --config-key=value ...
142
+
143
+ #{Xolo::Server::EXECUTABLE_FILENAME} #{CONFIG_CMD} --help
144
+
145
+
146
+ DESCRIPTION
147
+ The Xolo server configuration file is a YAML file located at
148
+ #{Xolo::Server.config.conf_file}"
149
+
150
+ It contains a Ruby Hash of configuration options, the keys are Symbols and the values are the
151
+ configuration values. While the file can be edited directly, it is recommended to use the
152
+ 'config' subcommand to view and set the values.
153
+
154
+ Some sensitive values may be stored in the configuration file as a command or file path from
155
+ which to read the actual value. Config values starting with a pipe '|' are executed as a command
156
+ (after removing the pipe) and the value to be used is read from the standard output of the
157
+ command. Values that are file paths are read from the file at the path. If the stored value
158
+ doesn't start with a pipe, and is not a valid file path, the value is used as is. Be wary of
159
+ security issues, permissions, etc when working with these values.
160
+
161
+ See '#{Xolo::Server::EXECUTABLE_FILENAME} #{CONFIG_CMD} --help' for details on which configuration
162
+ keys are used this way.
163
+
164
+ Showing configuration values:
165
+ When used without --set, --show is implied. If no config keys are given, all keys are shown.
166
+ Keys can be given as 'key_name' or 'key-name'.
167
+
168
+ Values are shown as stored in the config file. With --expand, the actual value used by the server
169
+ is shown, after reading from commands or files.
170
+
171
+ Setting configuration values:
172
+ To set configuration values, use --set followed by one or more config keys as options, e.g.
173
+ --config-key=value. You must restart the server to apply changes.
174
+
175
+ NOTE: As of this writing, there is very little validation of the values you set, nor any
176
+ enforcement of required values. Be careful.
177
+
178
+ Help:
179
+ Using --help shows this help message, and descriptions of all available config_keys as options
180
+ to --set.
181
+
182
+ Private values:
183
+ Config keys marked Private (see #{Xolo::Server::EXECUTABLE_FILENAME} #{CONFIG_CMD} --help) are
184
+ not shown when the config values are displayed to users of xadm, instead they see '#{Xolo::Server::Configuration::PRIVATE}'
185
+ ENDSYNOPSIS
186
+
187
+ # add a blank line between each of the cli options in the help output
188
+ # NOTE: chrisl added this to the optimist.rb included in this project.
189
+ insert_blanks
190
+
191
+ opt :show, 'Show configuration values', short: :none
192
+ opt :expand, 'Show expanded configuration values', short: :none
193
+ opt :set, 'Set configuration values', short: :none
194
+
195
+ Xolo::Server::Configuration::KEYS.each do |key, deets|
196
+ # puts "defining: #{key} "
197
+
198
+ moinfo = deets[:required] ? 'Required if not already set ' : ''
199
+ moinfo = "#{moinfo}[Private]" if deets[:private]
200
+ moinfo = "#{moinfo.strip}\n" unless moinfo.empty?
201
+
202
+ desc = "#{moinfo}#{deets[:desc]}"
203
+ opt key, desc, default: deets[:default], type: deets[:type], short: :none
204
+ end # KEYS.each
205
+ end # Optimist.options
206
+
207
+ # any other args are the keys to display,
208
+ # convert them to symbols and store them in the config_opts
209
+ config_opts[:keys_to_display] = ARGV.map { |k| k.gsub('-', '_').to_sym } unless ARGV.empty?
210
+ end
211
+
212
+ end # module CommandLine
213
+
214
+ end # Server
215
+
216
+ end # module Xolo