Skip to content

Commit

Permalink
Move out time update cmd as a script
Browse files Browse the repository at this point in the history
  • Loading branch information
arunvelsriram committed Dec 25, 2016
1 parent 9fd2cde commit 98ca0b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docker-time-sync.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
6B6202181E0F316200A7B2B0 /* docker-time-sync */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "docker-time-sync"; sourceTree = BUILT_PRODUCTS_DIR; };
6B62021B1E0F316200A7B2B0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
6B6202231E0F31B800A7B2B0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
6B7DB3531E10538100CB0A5F /* update-docker-time */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "update-docker-time"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -62,6 +63,7 @@
isa = PBXGroup;
children = (
6B62021B1E0F316200A7B2B0 /* main.m */,
6B7DB3531E10538100CB0A5F /* update-docker-time */,
);
path = "docker-time-sync";
sourceTree = "<group>";
Expand Down Expand Up @@ -229,6 +231,7 @@
6B6202201E0F316200A7B2B0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Mac Developer";
DEVELOPMENT_TEAM = 4N5S9KH6Q8;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -237,6 +240,7 @@
6B6202211E0F316200A7B2B0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Mac Developer";
DEVELOPMENT_TEAM = 4N5S9KH6Q8;
PRODUCT_NAME = "$(TARGET_NAME)";
};
Expand All @@ -261,6 +265,7 @@
6B6202211E0F316200A7B2B0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
12 changes: 3 additions & 9 deletions docker-time-sync/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,14 @@ void SleepCallBack( void * refCon, io_service_t service, natural_t messageType,
(long unsigned int)messageArgument );

if (messageType == kIOMessageSystemHasPoweredOn) {
NSLog(@"Started to sync time...");
// docker run --rm -it --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n ntpd -d -q -n -p pool.ntp.org
NSLog(@"Run: /usr/local/bin/update-docker-time");
NSTask *task = [[NSTask alloc] init];
NSArray *arguments = [NSArray arrayWithObjects:@"run", @"--rm", @"-it", @"--privileged", @"--pid=host", @"walkerlee/nsenter", [NSString stringWithFormat: @"%@ %@",@"-t",@"1"], @"-m", @"-u", @"-i", @"-n", @"ntpd", @"-d", @"-q", @"-n", @"-p", @"pool.ntp.org", nil];
[task setLaunchPath: @"/usr/local/bin/docker"];
[task setArguments: arguments];
task.terminationHandler = ^(NSTask *aTask){
NSLog(@"\nDone!\n");
};
[task setLaunchPath:@"/usr/local/bin/update-docker-time"];
[task setArguments:@[]];
[task launch];
}
}


int main( int argc, char **argv )
{
io_connect_t root_port;
Expand Down
9 changes: 9 additions & 0 deletions docker-time-sync/update-docker-time
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# docker-sync-time.sh
# docker-sync-time
#
# Created by ArunvelSriram on 26/12/16.
# Copyright © 2016 ArunvelSriram. All rights reserved.

/usr/local/bin/docker run --rm --privileged --pid=host walkerlee/nsenter -t 1 -m -u -i -n ntpd -d -q -n -p pool.ntp.org

0 comments on commit 98ca0b8

Please sign in to comment.