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.
- checksums.yaml +7 -0
- data/LICENSE.txt +177 -0
- data/README.md +7 -0
- data/bin/xoloserver +106 -0
- data/data/com.pixar.xoloserver.plist +29 -0
- data/data/uninstall-pkgs-by-id.zsh +103 -0
- data/lib/xolo/server/app.rb +133 -0
- data/lib/xolo/server/command_line.rb +216 -0
- data/lib/xolo/server/configuration.rb +739 -0
- data/lib/xolo/server/constants.rb +70 -0
- data/lib/xolo/server/helpers/auth.rb +257 -0
- data/lib/xolo/server/helpers/client_data.rb +415 -0
- data/lib/xolo/server/helpers/file_transfers.rb +265 -0
- data/lib/xolo/server/helpers/jamf_pro.rb +156 -0
- data/lib/xolo/server/helpers/log.rb +97 -0
- data/lib/xolo/server/helpers/maintenance.rb +401 -0
- data/lib/xolo/server/helpers/notification.rb +145 -0
- data/lib/xolo/server/helpers/pkg_signing.rb +141 -0
- data/lib/xolo/server/helpers/progress_streaming.rb +252 -0
- data/lib/xolo/server/helpers/title_editor.rb +92 -0
- data/lib/xolo/server/helpers/titles.rb +145 -0
- data/lib/xolo/server/helpers/versions.rb +160 -0
- data/lib/xolo/server/log.rb +286 -0
- data/lib/xolo/server/mixins/changelog.rb +315 -0
- data/lib/xolo/server/mixins/title_jamf_access.rb +1668 -0
- data/lib/xolo/server/mixins/title_ted_access.rb +519 -0
- data/lib/xolo/server/mixins/version_jamf_access.rb +1541 -0
- data/lib/xolo/server/mixins/version_ted_access.rb +373 -0
- data/lib/xolo/server/object_locks.rb +102 -0
- data/lib/xolo/server/routes/auth.rb +89 -0
- data/lib/xolo/server/routes/jamf_pro.rb +89 -0
- data/lib/xolo/server/routes/maint.rb +174 -0
- data/lib/xolo/server/routes/title_editor.rb +71 -0
- data/lib/xolo/server/routes/titles.rb +285 -0
- data/lib/xolo/server/routes/uploads.rb +93 -0
- data/lib/xolo/server/routes/versions.rb +261 -0
- data/lib/xolo/server/routes.rb +168 -0
- data/lib/xolo/server/title.rb +1143 -0
- data/lib/xolo/server/version.rb +902 -0
- data/lib/xolo/server.rb +205 -0
- data/lib/xolo-server.rb +8 -0
- metadata +243 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f9f5dc9ea500833d5c8801217644bb7f3d13854381904e82f4258686f4ca2658
|
|
4
|
+
data.tar.gz: d7f5707fac107f389747d7eb754c872e001e8e08e1aa9bae5c2450773dffdf47
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d0eaea573242edf948631e7276654e88bfe16b586d2545af05bb09968d511e564163e9a0d15b98cf7e5bcaa0238cf48bd753f21dd5cba0be11a18861adb12091
|
|
7
|
+
data.tar.gz: 46d443c1d859c1cd56a1cc0eef30ae9f5a8da32d878ca991eb66c1564c17c6b56cace0ab140d26d9bd5355dcfa01a624a8133060016d4b2017c8a15dc331d4fc
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
TOMORROW OPEN SOURCE TECHNOLOGY LICENSE 1.0
|
|
3
|
+
|
|
4
|
+
The Tomorrow Open Source Technology License 1.0 differs from the original Apache License 2.0 in the following manner. The scope of the trademark grant in section 6 is different.
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor
|
|
141
|
+
and its affiliates, except as required to comply with Section 4(c) of
|
|
142
|
+
the License and to reproduce the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
data/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Xolo - CLI and Automated Package and Patch Management for Jamf Pro
|
|
2
|
+
|
|
3
|
+
The xolo-server gem packages the code needed to run `xoloserver`, a sinatra-based HTTPS server that is the heart of Xolo [link to come], a command-line based system for automation and standardization around software deployment and management via Jamf Pro and the Jamf Title Editor.
|
|
4
|
+
|
|
5
|
+
The xolo server provides the interface between the admin tool `xadm` and the Jamf Pro and Jamf Title Editor APIs.
|
|
6
|
+
|
|
7
|
+
More documentation coming soon.
|
data/bin/xoloserver
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Copyright 2025 Pixar
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the terms set forth in the LICENSE.txt file available at
|
|
6
|
+
# at the root of this project.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
# frozen_string_literal: true
|
|
10
|
+
|
|
11
|
+
require 'xolo/server'
|
|
12
|
+
|
|
13
|
+
# The Server Wrapper App
|
|
14
|
+
#####################
|
|
15
|
+
class XoloServer
|
|
16
|
+
|
|
17
|
+
# include Xolo::Core::Output
|
|
18
|
+
|
|
19
|
+
###########################
|
|
20
|
+
def initialize
|
|
21
|
+
# CLI
|
|
22
|
+
Xolo::Server.parse_cli
|
|
23
|
+
Xolo::Server.debug = Xolo::Server.cli_opts[:debug]
|
|
24
|
+
Xolo::Server.app_env = Xolo::Server.cli_opts[:production] ? Xolo::Server::APP_ENV_PROD : Xolo::Server::APP_ENV_DEV
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
###########################
|
|
28
|
+
def run
|
|
29
|
+
Process.setproctitle Xolo::Server::EXECUTABLE_FILENAME
|
|
30
|
+
|
|
31
|
+
# Run the Server
|
|
32
|
+
if Xolo::Server.config_opts.empty?
|
|
33
|
+
Xolo::Server.logger.info "Starting version #{Xolo::VERSION} in #{Xolo::Server.app_env} mode"
|
|
34
|
+
Xolo::Server::App.run!
|
|
35
|
+
|
|
36
|
+
# Set config
|
|
37
|
+
elsif Xolo::Server.config_opts[:set]
|
|
38
|
+
set_config
|
|
39
|
+
|
|
40
|
+
# Show config
|
|
41
|
+
# always --show unless --set
|
|
42
|
+
else
|
|
43
|
+
show_config
|
|
44
|
+
end
|
|
45
|
+
end # run
|
|
46
|
+
|
|
47
|
+
###########################
|
|
48
|
+
def show_config
|
|
49
|
+
puts '# Current Xolo Server Settings:'
|
|
50
|
+
puts '#################################'
|
|
51
|
+
|
|
52
|
+
keys_to_display = Xolo::Server.config_opts[:keys_to_display] || Xolo::Server::Configuration::KEYS.keys
|
|
53
|
+
max_key_len = keys_to_display.max_by(&:length).length + 2
|
|
54
|
+
|
|
55
|
+
# Display the requested keys
|
|
56
|
+
keys_to_display.each do |k|
|
|
57
|
+
deets = Xolo::Server::Configuration::KEYS[k]
|
|
58
|
+
|
|
59
|
+
v = Xolo::Server.config_opts[:expand] ? Xolo::Server.config.send(k) : Xolo::Server.config.raw_data[k]
|
|
60
|
+
|
|
61
|
+
if v.pix_empty?
|
|
62
|
+
if deets
|
|
63
|
+
'** required but not set' if deets[:required]
|
|
64
|
+
else
|
|
65
|
+
'Unknown Key'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
printf "%-#{max_key_len}s %s\n", "#{k}: ", v
|
|
70
|
+
end # keys_to_display.each
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
###########################
|
|
74
|
+
def set_config
|
|
75
|
+
# puts 'Config opts:'
|
|
76
|
+
# Xolo::Server.config_opts.each do |k, v|
|
|
77
|
+
# puts " #{k} (#{k.class}): #{v}"
|
|
78
|
+
# end
|
|
79
|
+
# puts '-------------------------------'
|
|
80
|
+
|
|
81
|
+
# raw_data is the data as read from the config file, which is the data we want to save back
|
|
82
|
+
# after updating the values
|
|
83
|
+
data_to_save = Xolo::Server.config.raw_data.dup
|
|
84
|
+
|
|
85
|
+
Xolo::Server::Configuration::KEYS.each_key do |k|
|
|
86
|
+
next unless Xolo::Server.config_opts.key? "#{k}_given".to_sym
|
|
87
|
+
|
|
88
|
+
new_val = Xolo::Server.config_opts[k]
|
|
89
|
+
puts "Setting #{k} to #{new_val}"
|
|
90
|
+
data_to_save[k] = new_val
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Xolo::Server.config.save_to_file(data: data_to_save)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end # class XoloServer
|
|
97
|
+
|
|
98
|
+
# MAIN
|
|
99
|
+
#####################
|
|
100
|
+
begin
|
|
101
|
+
app = XoloServer.new
|
|
102
|
+
app.run
|
|
103
|
+
rescue => e
|
|
104
|
+
warn "ERROR #{e.class.name.split('::').last}: #{e}"
|
|
105
|
+
e.backtrace.each { |l| warn "..#{l}" }
|
|
106
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>KeepAlive</key>
|
|
6
|
+
<true/>
|
|
7
|
+
<key>Label</key>
|
|
8
|
+
<string>com.pixar.xoloserver</string>
|
|
9
|
+
<!-- You probably want to set these environment variables
|
|
10
|
+
<key>EnvironmentVariables</key>
|
|
11
|
+
<dict>
|
|
12
|
+
<key>GEM_PATH</key>
|
|
13
|
+
<string></string>
|
|
14
|
+
<key>PATH</key>
|
|
15
|
+
<string></string>
|
|
16
|
+
</dict>
|
|
17
|
+
-->
|
|
18
|
+
<key>ProgramArguments</key>
|
|
19
|
+
<array>
|
|
20
|
+
<string>/usr/local/bin/xoloserver</string>
|
|
21
|
+
</array>
|
|
22
|
+
<key>RunAtLoad</key>
|
|
23
|
+
<true/>
|
|
24
|
+
<key>StandardOutPath</key>
|
|
25
|
+
<string>/Library/Application Support/xoloserver/logs/xoloserver.log</string>
|
|
26
|
+
<key>StandardErrorPath</key>
|
|
27
|
+
<string>/Library/Application Support/xoloserver/logs/xoloserver.log</string>
|
|
28
|
+
</dict>
|
|
29
|
+
</plist>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/bin/zsh
|
|
2
|
+
|
|
3
|
+
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
|
|
4
|
+
|
|
5
|
+
# Used by Xolo to uninstall packages based on one or more package-IDs as used by the
|
|
6
|
+
# 'pkgutil' command.
|
|
7
|
+
#
|
|
8
|
+
# This will get the list of files installed by each package-ID, and in a
|
|
9
|
+
# depth-first manner, delete them all. Directories will only be deleted if
|
|
10
|
+
# they are empty after deleting anything inside them what was installed by the same
|
|
11
|
+
# package. (hence the need for depth-first traversal)
|
|
12
|
+
#
|
|
13
|
+
# NOTE: This will not be useful if something was installed in a manner other than
|
|
14
|
+
# an installer.pkg (e.g. drag-installing an app) because there won't be
|
|
15
|
+
# a matching entry in the pkgutil database.
|
|
16
|
+
# It also won't help if the user has moved or renamed files after installation.
|
|
17
|
+
|
|
18
|
+
# DO NOT CHANGE THE VALUE OF IDS_TO_UNINSTALL
|
|
19
|
+
# This is a placeholder for the package IDs that Xolo will insert into the script
|
|
20
|
+
IDS_TO_UNINSTALL=(PKG_IDS_FROM_XOLO_GO_HERE)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# the current IDs known to pkgutil
|
|
24
|
+
IFS=$'\n' installed_pkgids=($(/usr/sbin/pkgutil --pkgs))
|
|
25
|
+
|
|
26
|
+
# iterate over our ids
|
|
27
|
+
for pkgid in $IDS_TO_UNINSTALL ; do
|
|
28
|
+
|
|
29
|
+
# next unless this id is known
|
|
30
|
+
if ! (( $installed_pkgids[(Ie)$pkgid] )) ; then
|
|
31
|
+
echo "pkg ID $pkgid is not known"
|
|
32
|
+
continue
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# the items to delete for a pkg ID
|
|
36
|
+
IFS=$'\n' items_to_delete=($(/usr/sbin/pkgutil --files $pkgid ))
|
|
37
|
+
|
|
38
|
+
# next if that failed for some reason
|
|
39
|
+
if ! [[ $? = 0 ]] ; then
|
|
40
|
+
echo "failed to get file list for $pkgid, skipping"
|
|
41
|
+
continue
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# IMPORTANT - get the install volume and install location to prepend
|
|
45
|
+
# to the pathnames
|
|
46
|
+
inst_volume=$(/usr/sbin/pkgutil --pkg-info-plist $pkgid | /usr/bin/plutil -extract volume raw -- -)
|
|
47
|
+
echo "inst_volume is: '$inst_volume'"
|
|
48
|
+
|
|
49
|
+
# if the inst_volume is set and it's last character is not a slash
|
|
50
|
+
# we need to insert a slash after it
|
|
51
|
+
[[ -n $inst_volume ]] && [[ "${inst_volume[-1]}" != '/' ]] && vol_slash='/'
|
|
52
|
+
|
|
53
|
+
inst_location=$(/usr/sbin/pkgutil --pkg-info-plist $pkgid | /usr/bin/plutil -extract install-location raw -- -)
|
|
54
|
+
echo "inst_location is: '$inst_location'"
|
|
55
|
+
|
|
56
|
+
# if the location is also just /, then don't use it
|
|
57
|
+
[[ "$inst_location" = '/' ]] && inst_location=''
|
|
58
|
+
echo "inst_location is NOW: '$inst_location'"
|
|
59
|
+
|
|
60
|
+
# if the inst_location is set and it's last character is not a slash
|
|
61
|
+
# we need to insert a slash after it
|
|
62
|
+
[[ -n $inst_location ]] && [[ "${inst_location[-1]}" != '/' ]] && loc_slash='/'
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
echo "deleting files installed by $pkgid"
|
|
66
|
+
echo '----------------'
|
|
67
|
+
|
|
68
|
+
# we need iterate them in reverse them so that we delete things depth-first
|
|
69
|
+
# which is what the (Oa) does
|
|
70
|
+
for path in ${(Oa)items_to_delete}; do
|
|
71
|
+
|
|
72
|
+
# echo "orig path is: '$path'"
|
|
73
|
+
|
|
74
|
+
path_to_delete="${inst_volume}${vol_slash}${inst_location}${loc_slash}${path}"
|
|
75
|
+
|
|
76
|
+
if [[ -f "$path_to_delete" ]] ; then
|
|
77
|
+
echo "$path_to_delete is a file - deleting it"
|
|
78
|
+
/bin/rm -f "$path_to_delete"
|
|
79
|
+
|
|
80
|
+
elif [[ -L "$path_to_delete" ]] ; then
|
|
81
|
+
echo "$path_to_delete is a symlink - deleting it"
|
|
82
|
+
/bin/rm -f "$path_to_delete"
|
|
83
|
+
|
|
84
|
+
elif [[ -d "$path_to_delete" ]] ; then
|
|
85
|
+
echo "$path_to_delete is a directory..."
|
|
86
|
+
|
|
87
|
+
if [[ $(/bin/ls -A "$path_to_delete" | /usr/bin/wc -l) -eq 0 ]] ; then
|
|
88
|
+
echo "... and it's empty - deleting it"
|
|
89
|
+
/bin/rm -f "$path_to_delete"
|
|
90
|
+
else
|
|
91
|
+
echo "... but its not empty - NOT deleting it"
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
else
|
|
95
|
+
echo "$path_to_delete doesn't exist'"
|
|
96
|
+
fi
|
|
97
|
+
|
|
98
|
+
done
|
|
99
|
+
|
|
100
|
+
echo "done deleting files from $pkgid"
|
|
101
|
+
echo "------------------------------------"
|
|
102
|
+
|
|
103
|
+
done
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
|
|
8
|
+
# frozen_string_literal: true
|
|
9
|
+
|
|
10
|
+
# main module
|
|
11
|
+
module Xolo
|
|
12
|
+
|
|
13
|
+
module Server
|
|
14
|
+
|
|
15
|
+
# The actual server application - a Sinatra/Thin HTTPS server
|
|
16
|
+
class App < Sinatra::Base
|
|
17
|
+
|
|
18
|
+
# Extensions & Helpers
|
|
19
|
+
##############################
|
|
20
|
+
##############################
|
|
21
|
+
|
|
22
|
+
register Xolo::Server::Routes
|
|
23
|
+
register Xolo::Server::Routes::Auth
|
|
24
|
+
register Xolo::Server::Routes::Maint
|
|
25
|
+
register Xolo::Server::Routes::JamfPro
|
|
26
|
+
register Xolo::Server::Routes::TitleEditor
|
|
27
|
+
register Xolo::Server::Routes::Titles
|
|
28
|
+
register Xolo::Server::Routes::Versions
|
|
29
|
+
register Xolo::Server::Routes::Uploads
|
|
30
|
+
|
|
31
|
+
helpers Xolo::Core::Constants
|
|
32
|
+
helpers Xolo::Core::JSONWrappers
|
|
33
|
+
helpers Xolo::Server::Helpers::Log
|
|
34
|
+
helpers Xolo::Server::Helpers::Notification
|
|
35
|
+
helpers Xolo::Server::Helpers::Auth
|
|
36
|
+
helpers Xolo::Server::Helpers::JamfPro
|
|
37
|
+
helpers Xolo::Server::Helpers::TitleEditor
|
|
38
|
+
helpers Xolo::Server::Helpers::Titles
|
|
39
|
+
helpers Xolo::Server::Helpers::Versions
|
|
40
|
+
helpers Xolo::Server::Helpers::FileTransfers
|
|
41
|
+
helpers Xolo::Server::Helpers::PkgSigning
|
|
42
|
+
helpers Xolo::Server::Helpers::ProgressStreaming
|
|
43
|
+
helpers Xolo::Server::Helpers::ClientData
|
|
44
|
+
helpers Xolo::Server::Helpers::Maintenance
|
|
45
|
+
|
|
46
|
+
# Sinatra setup
|
|
47
|
+
##############################
|
|
48
|
+
##############################
|
|
49
|
+
|
|
50
|
+
##########
|
|
51
|
+
configure do
|
|
52
|
+
Xolo::Server.logger.debug 'Configuring Server App'
|
|
53
|
+
set :server, :thin
|
|
54
|
+
set :bind, '0.0.0.0'
|
|
55
|
+
set :port, 443
|
|
56
|
+
|
|
57
|
+
set :dump_errors, true
|
|
58
|
+
disable :show_exceptions
|
|
59
|
+
|
|
60
|
+
# Logging is handled by the Xolo::Server::Log module
|
|
61
|
+
|
|
62
|
+
enable :sessions
|
|
63
|
+
set :session_secret, SecureRandom.hex(64)
|
|
64
|
+
set :protection, session: true
|
|
65
|
+
set :sessions, expire_after: Xolo::Server::Constants::SESSION_EXPIRE_AFTER
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
###############
|
|
69
|
+
configure :development do
|
|
70
|
+
require 'pp'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
#############
|
|
74
|
+
configure :production do
|
|
75
|
+
set :show_exceptions, false
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Run !
|
|
79
|
+
################
|
|
80
|
+
def self.run!(**options, &block)
|
|
81
|
+
Xolo::Server.logger.info 'Server App Starting Up'
|
|
82
|
+
|
|
83
|
+
setup
|
|
84
|
+
|
|
85
|
+
super do |server|
|
|
86
|
+
server.ssl = true
|
|
87
|
+
# verify peer is false so that we don't require client certs
|
|
88
|
+
server.ssl_options = {
|
|
89
|
+
cert_chain_file: Xolo::Server::Configuration::SSL_CERT_FILE.to_s,
|
|
90
|
+
private_key_file: Xolo::Server::Configuration::SSL_KEY_FILE.to_s,
|
|
91
|
+
verify_peer: false
|
|
92
|
+
}
|
|
93
|
+
end # super do
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Do some setup as we start the server
|
|
97
|
+
##########################
|
|
98
|
+
def self.setup
|
|
99
|
+
Xolo::Server::DATA_DIR.mkpath
|
|
100
|
+
Xolo::Server::Title::TITLES_DIR.mkpath
|
|
101
|
+
|
|
102
|
+
setup_ssl
|
|
103
|
+
|
|
104
|
+
Xolo::Server.start_time = Time.now
|
|
105
|
+
|
|
106
|
+
Xolo::Server::Log.log_rotation_timer_task.execute
|
|
107
|
+
Xolo::Server::Helpers::Maintenance.cleanup_timer_task.execute
|
|
108
|
+
|
|
109
|
+
# Disable warnings in logs about known scope bug in Jamf Classic API
|
|
110
|
+
Jamf::Scopable::Scope.do_not_warn_about_policy_scope_bugs
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
##########################
|
|
114
|
+
def self.setup_ssl
|
|
115
|
+
Xolo::Server.logger.debug 'Setting up SSL certificates'
|
|
116
|
+
Xolo::Server::Configuration::SSL_DIR.mkpath
|
|
117
|
+
Xolo::Server::Configuration::SSL_DIR.chmod 0o700
|
|
118
|
+
Xolo::Server::Configuration::SSL_CERT_FILE.pix_save Xolo::Server.config.ssl_cert
|
|
119
|
+
Xolo::Server::Configuration::SSL_CERT_FILE.chmod 0o600
|
|
120
|
+
Xolo::Server::Configuration::SSL_KEY_FILE.pix_save Xolo::Server.config.ssl_key
|
|
121
|
+
Xolo::Server::Configuration::SSL_KEY_FILE.chmod 0o600
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
######################
|
|
125
|
+
def debug?
|
|
126
|
+
Xolo::Server.debug?
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
end # class App
|
|
130
|
+
|
|
131
|
+
end # Server
|
|
132
|
+
|
|
133
|
+
end # Xolo
|