Skip to content

Commit

Permalink
Merge pull request #681 from lindegroup/1.6-dev
Browse files Browse the repository at this point in the history
1.6 dev
  • Loading branch information
shawnhonsberger authored Jun 10, 2022
2 parents ee5f115 + a876132 commit c9058e0
Show file tree
Hide file tree
Showing 71 changed files with 3,523 additions and 896 deletions.
104 changes: 95 additions & 9 deletions AutoPkgr.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion AutoPkgr/Models/AutoPkg Task/LGAutoPkgRecipe.m
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ + (NSArray *)findRecipesRecursivelyAtPath:(NSString *)path isOverride:(BOOL)isOv
NSMutableArray *recipes = [[NSMutableArray alloc] init];

if (path && (access(path.UTF8String, F_OK) == 0)) {
NSString *matches = [NSString stringWithFormat:@"{%@/{*.recipe,*/*.recipe}}", path];
NSString *matches = [NSString stringWithFormat:@"{%@/{*.recipe,*/*.recipe,*.yaml,*/*.yaml,*.plist,*/*.plist}}", path];

glob_t results;
glob(matches.UTF8String, GLOB_BRACE | GLOB_NOSORT, NULL, &results);
Expand Down
2 changes: 2 additions & 0 deletions AutoPkgr/Models/AutoPkg Task/LGAutoPkgRepo.m
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ + (void)commonRepos:(void (^)(NSArray *))reply
@"https://github.com/autopkg/foigus-recipes.git",
@"https://github.com/autopkg/gerardkok-recipes.git",
@"https://github.com/autopkg/grahamgilbert-recipes.git",
@"https://github.com/autopkg/grahampugh-recipes.git",
@"https://github.com/autopkg/gregneagle-recipes.git",
@"https://github.com/autopkg/hansen-m-recipes.git",
@"https://github.com/autopkg/hjuutilainen-recipes.git",
Expand Down Expand Up @@ -399,6 +400,7 @@ + (void)commonRepos:(void (^)(NSArray *))reply
@"https://github.com/autopkg/scriptingosx-recipes.git",
@"https://github.com/autopkg/seansgm-recipes.git",
@"https://github.com/autopkg/sheagcraig-recipes.git",
@"https://github.com/autopkg/smithjw-recipes.git",
@"https://github.com/autopkg/swy-recipes.git",
@"https://github.com/autopkg/timsutton-recipes.git",
@"https://github.com/autopkg/valdore86-recipes.git",
Expand Down
13 changes: 1 addition & 12 deletions AutoPkgr/Models/AutoPkg Task/LGAutoPkgTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,7 @@
// Return the correct python path
static NSString *const python()
{
NSFileManager *fm = [NSFileManager defaultManager];
NSString *autopkgReceipt = @"/private/var/db/receipts/com.github.autopkg.autopkg.plist";
NSString *_autopkgReceiptVersion;
NSDictionary *receiptDict;
if ([fm fileExistsAtPath:autopkgReceipt]) {
receiptDict = [NSDictionary dictionaryWithContentsOfFile:autopkgReceipt];
_autopkgReceiptVersion = receiptDict[@"PackageVersion"];
if([_autopkgReceiptVersion hasPrefix:@"2."]) {
return @"/usr/local/autopkg/python";
}
}
return @"/usr/bin/python";
return @"/usr/local/autopkg/python";
}

static NSDictionary *AutoPkgVerbStringToEnum()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// LGIntegrationManager.h
// AutoPkgr
//
// Copyright 2015 Eldon Ahrold
// Copyright 2015-2022 Linde Group.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -24,6 +24,7 @@
#import "LGFileWaveIntegration.h"
#import "LGGitIntegration.h"
#import "LGIntegration.h"
#import "LGJamfUploaderIntegration.h"
#import "LGJSSImporterIntegration.h"
#import "LGLANrevIntegration.h"
#import "LGMacPatchIntegration.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// LGIntegrationManager.m
// AutoPkgr
//
// Copyright 2015 Eldon Ahrold
// Copyright 2015-2022 Linde Group.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@ + (void)load
[LGAutoPkgIntegration class],
[LGFileWaveIntegration class],
[LGGitIntegration class],
[LGJamfUploaderIntegration class],
[LGJSSImporterIntegration class],
[LGLANrevIntegration class],
[LGMacPatchIntegration class],
Expand Down
42 changes: 42 additions & 0 deletions AutoPkgr/Models/Integrations/LGJamfUploaderIntegration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// LGJamfUploaderIntegration.h
// AutoPkgr
//
// Copyright 2022 The Linde Group.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import "LGDefaults.h"
#import "LGConstants.h"
#import "LGIntegration+Protocols.h"
#import "LGIntegration.h"

@class LGHTTPCredential;

@interface LGJamfUploaderIntegration : LGIntegration

@end

#pragma mark - LGDefaults extensions for JamfUploader Interface
@interface LGJamfUploaderDefaults : LGDefaults

+ (instancetype)standardUserDefaults __attribute__((unavailable("Cannot use the shared object in this subclass.")));

@property (copy, nonatomic) NSString *JSSURL;
@property (copy, nonatomic) NSString *JSSAPIUsername;
@property (copy, nonatomic) NSString *JSSAPIPassword;
@property (copy, nonatomic) NSArray *JSSRepos;
@property (assign, nonatomic) BOOL JSSVerifySSL;

@end
194 changes: 194 additions & 0 deletions AutoPkgr/Models/Integrations/LGJamfUploaderIntegration.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
//
// LGJamfUploaderIntegration.m
// AutoPkgr
//
// Copyright 2022 The Linde Group.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#import "LGIntegration+Protocols.h"
#import "LGJamfUploaderIntegration.h"
#import "LGLogger.h"
#import "LGServerCredentials.h"
#import <Foundation/Foundation.h>

@interface LGJamfUploaderIntegration () <LGIntegrationSharedProcessor>
@end

@implementation LGJamfUploaderIntegration

@synthesize gitHubInfo = _gitHubInfo;
@synthesize installedVersion = _installedVersion;

#pragma mark - Class overrides
+ (NSString *)name
{
return @"JamfUploader";
}

+ (NSString *)credits
{
return @"Graham Pugh\nhttp://www.apache.org/licenses/LICENSE-2.0\nhttps://github.com/autopkg/grahampugh-recipes";
}

+ (NSURL *)homePage
{
return [NSURL URLWithString:@"https://github.com/autopkg/grahampugh-recipes"];
}

+ (NSString *)gitHubURL
{
return @"https://github.com/autopkg/grahampugh-recipes";
}

+ (NSString *)defaultRepository
{
return @"https://github.com/autopkg/grahampugh-recipes.git";
}

+ (NSString *)binary
{
static NSString *const jamfUploaderBinary = @"~/Library/AutoPkg/RecipeRepos/com.github.autopkg.grahampugh-recipes/JamfUploaderProcessors/JamfUploaderLib/JamfUploaderBase.py";
return jamfUploaderBinary.stringByExpandingTildeInPath;
}

+ (NSArray *)components
{
return @[
[self binary],
];
}

+ (NSArray *)packageIdentifiers
{
return @[ @"com.github.autopkg.grahampugh-recipes"];
}

+ (BOOL)isUninstallable
{
return YES;
}

+ (NSArray *)summaryResultKey
{
return @[ @"jamfcategoryuploader_summary_result", @"jamfcomputergroupuploader_summary_result", @"jamfdockitemuploader_summary_result", @"jamfextensionattributeuploader_summary_result", @"jamfpackageuploader_summary_result", @"jamfpatchuploader_summary_result", @"jamfpolicyuploader_summary_result", @"jamfscriptuploader_summary_result" ];
}

#pragma mark - Instance overrides.

- (NSString *)installedVersion
{
NSFileManager *fm = [NSFileManager defaultManager];

NSString *receipt = @"~/Library/AutoPkg/RecipeRepos/com.github.autopkg.grahampugh-recipes/JamfUploaderProcessors/JamfUploaderLib/JamfUploaderBase.py";


if ([[self class] isInstalled]) {
if ([fm fileExistsAtPath:receipt]) {
}
_installedVersion = @"is";
}

return _installedVersion;
}

- (void)customInstallActions:(void (^)(NSError *))reply
{
LGJamfUploaderDefaults *defaults = [[LGJamfUploaderDefaults alloc] init];
NSNumber *verifySSL = [defaults autoPkgDomainObject:@"JSS_VERIFY_SSL"];
if (!verifySSL) {
defaults.JSSVerifySSL = YES;
}
reply(nil);
}

- (void)customUninstallActions:(void (^)(NSError *))reply
{
// Clear out the defaults.
LGJamfUploaderDefaults *defaults = [[LGJamfUploaderDefaults alloc] init];
defaults.JSSAPIPassword = nil;
defaults.JSSAPIUsername = nil;
defaults.JSSRepos = nil;
defaults.JSSURL = nil;

reply(nil);
}

@end

#pragma mark - LGDefaults category implementation for JamfUploader Interface

@implementation LGJamfUploaderDefaults

- (NSString *)JSSURL
{
return [self autoPkgDomainObject:@"JSS_URL"];
}

- (void)setJSSURL:(NSString *)JSSURL
{
[self setAutoPkgDomainObject:JSSURL forKey:@"JSS_URL"];
}

#pragma mark -
- (NSString *)JSSAPIUsername
{
return [self autoPkgDomainObject:@"API_USERNAME"];
}

- (void)setJSSAPIUsername:(NSString *)JSSAPIUsername
{
[self setAutoPkgDomainObject:JSSAPIUsername forKey:@"API_USERNAME"];
}

#pragma mark -
- (NSString *)JSSAPIPassword
{
return [self autoPkgDomainObject:@"API_PASSWORD"];
}

- (void)setJSSAPIPassword:(NSString *)JSSAPIPassword
{
[self setAutoPkgDomainObject:JSSAPIPassword forKey:@"API_PASSWORD"];
}

#pragma mark -
- (NSArray *)JSSRepos
{
return [self autoPkgDomainObject:@"JSS_REPOS"];
}

- (void)setJSSRepos:(NSArray *)JSSRepos
{
[self setAutoPkgDomainObject:JSSRepos forKey:@"JSS_REPOS"];
}

#pragma mark -
- (BOOL)JSSVerifySSL
{
NSNumber *verifySSL = [self autoPkgDomainObject:@"JSS_VERIFY_SSL"];
if (verifySSL == nil) {
return YES;
}

return [verifySSL boolValue];
}

- (void)setJSSVerifySSL:(BOOL)JSSVerifySSL
{
DevLog(@"Setting JSS_SSL_VERIFY to %@", JSSVerifySSL ? @"YES" : @"NO");
[self setAutoPkgDomainObject:@(JSSVerifySSL) forKey:@"JSS_VERIFY_SSL"];
}

@end
71 changes: 71 additions & 0 deletions AutoPkgr/Models/LGJamfDistributionPoint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//
// LGJamfDistributionPoint.h
// AutoPkgr
//
// Copyright 2022 The Linde Group.
//

#import <Foundation/Foundation.h>

typedef NS_OPTIONS(NSInteger, JamfDistributionPointType) {
kLGJamfTypeFromJamf = 1 << 0,
kLGJamfTypeAFP = 1 << 1,
kLGJamfTypeSMB = 1 << 2,
kLGJamfTypeJDS = 1 << 3,
kLGJamfTypeCDP = 1 << 4,
kLGJamfTypeLocal = 1 << 5
};

extern NSString *const kLGJamfDistPointNameKey;
extern NSString *const kLGJamfDistPointURLKey;
extern NSString *const kLGJamfDistPointSharePointKey;
extern NSString *const kLGJamfDistPointMountPointKey;
extern NSString *const kLGJamfDistPointPortKey;
extern NSString *const kLGJamfDistPointUserNameKey;
extern NSString *const kLGJamfDistPointPasswordKey;
extern NSString *const kLGJamfDistPointWorkgroupDomainKey;
extern NSString *const kLGJamfDistPointTypeKey;

// Corresponding type string in keyJamfInfoDict().
extern const NSString *kJamfTypeString;
// Key used to indicate the array of required keys for a DP.
extern const NSString *kJamfRequired;
// Key used to indicate the array of optional keys for a DP.
extern const NSString *kJamfOptional;

@interface LGJamfDistributionPoint : NSObject
// Dictionary to query for type string.
// Corresponding values can be looked up using an NSNumber representation of JamfDistributionPointType as the key.
+ (NSDictionary *)keyJamfInfoDict;

+ (NSArray<LGJamfDistributionPoint *> *)enabledDistributionPoints;

+ (void)getFromRemote:(void (^)(NSArray<LGJamfDistributionPoint *> *distPoints, NSError *error))distPoints;

// The Dictionary representation of the Distribution Point object, suitable for writing to defaults.
@property (copy, readonly) NSDictionary *representation;
@property (copy) NSString *name;
@property (copy) NSString *URL;
@property (copy) NSString *mount_point;
@property (copy) NSString *port;
@property (copy) NSString *share_name;
@property (copy) NSString *username;
@property (copy) NSString *password;
@property (copy) NSString *domain;
@property (copy) NSString *typeString;
@property JamfDistributionPointType type;

- (BOOL)isEditable;

// Initialize a distribution point using a dictionary.
- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (instancetype)initWithType:(JamfDistributionPointType)type;
- (instancetype)initWithTypeString:(NSString *)typeString;

// Save or modify an existing distribution point to defaults.
- (BOOL)save;

// Remove a distribution point.
- (BOOL)remove;

@end
Loading

0 comments on commit c9058e0

Please sign in to comment.