Skip to content

Commit 3a7aedb

Browse files
authored
Merge pull request #32 from TheNewNormal/v0.2.5
v0.2.5
2 parents 5dd08f2 + e61912d commit 3a7aedb

File tree

9 files changed

+58
-80
lines changed

9 files changed

+58
-80
lines changed

src/check_dns_status.command

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# check if DNS port 53 is not in use
4+
#
5+
CHECK_DNS_STATUS=$(/usr/sbin/netstat -an | grep LISTEN | grep -w "*.53")
6+
7+
if [[ "$CHECK_DNS_STATUS" == "" ]]; then
8+
# DNS port is not in use
9+
echo "no"
10+
else
11+
# DNS port is in use
12+
echo "yes"
13+
fi

src/corectl.xcodeproj/project.pbxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1318E2041D302A3400EC75E9 /* stop_docker_registry.command in Resources */ = {isa = PBXBuildFile; fileRef = 1318E2031D302A3400EC75E9 /* stop_docker_registry.command */; };
1111
13278FF81D32A6B5001EF5F4 /* check_corectl_app_version.command in Resources */ = {isa = PBXBuildFile; fileRef = 13278FF71D32A6B5001EF5F4 /* check_corectl_app_version.command */; };
1212
134476021D2E5F220035B3B9 /* check_active_vms.command in Resources */ = {isa = PBXBuildFile; fileRef = 134476011D2E5F220035B3B9 /* check_active_vms.command */; };
13+
134B4DD21D6DC65D0018D004 /* check_dns_status.command in Resources */ = {isa = PBXBuildFile; fileRef = 134B4DD11D6DC65D0018D004 /* check_dns_status.command */; };
1314
134DD75C1D2FEBF100E60CDE /* check_corectld_status.command in Resources */ = {isa = PBXBuildFile; fileRef = 134DD75B1D2FEBF100E60CDE /* check_corectld_status.command */; };
1415
134DD75E1D300CE400E60CDE /* check_corectld_version.command in Resources */ = {isa = PBXBuildFile; fileRef = 134DD75D1D300CE400E60CDE /* check_corectld_version.command */; };
1516
134F3CEC1D2C2270002B9668 /* check_blobs_version.command in Resources */ = {isa = PBXBuildFile; fileRef = 134F3CEB1D2C2270002B9668 /* check_blobs_version.command */; };
@@ -28,7 +29,6 @@
2829
137597631D2BC9CF000CB88F /* update_corectl_blobs.command in Resources */ = {isa = PBXBuildFile; fileRef = 137597621D2BC9CF000CB88F /* update_corectl_blobs.command */; };
2930
137597651D2BD5A6000CB88F /* copy_corectl_blobs.command in Resources */ = {isa = PBXBuildFile; fileRef = 137597641D2BD5A5000CB88F /* copy_corectl_blobs.command */; };
3031
1375976B1D2BF306000CB88F /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1375976A1D2BF306000CB88F /* Security.framework */; };
31-
1375976F1D2C05AA000CB88F /* start_corectld.command in Resources */ = {isa = PBXBuildFile; fileRef = 1375976E1D2C05AA000CB88F /* start_corectld.command */; };
3232
13BC96B41D2CF42C006D27B3 /* Notifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13BC96B31D2CF42C006D27B3 /* Notifications.swift */; };
3333
13BC96B61D2CF4DC006D27B3 /* RunShellApps.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13BC96B51D2CF4DC006D27B3 /* RunShellApps.swift */; };
3434
13BC96BA1D2CF701006D27B3 /* HelpingFunctions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13BC96B91D2CF701006D27B3 /* HelpingFunctions.swift */; };
@@ -42,6 +42,7 @@
4242
1318E2031D302A3400EC75E9 /* stop_docker_registry.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = stop_docker_registry.command; sourceTree = "<group>"; };
4343
13278FF71D32A6B5001EF5F4 /* check_corectl_app_version.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = check_corectl_app_version.command; sourceTree = "<group>"; };
4444
134476011D2E5F220035B3B9 /* check_active_vms.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = check_active_vms.command; sourceTree = "<group>"; };
45+
134B4DD11D6DC65D0018D004 /* check_dns_status.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = check_dns_status.command; sourceTree = "<group>"; };
4546
134DD75B1D2FEBF100E60CDE /* check_corectld_status.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = check_corectld_status.command; sourceTree = "<group>"; };
4647
134DD75D1D300CE400E60CDE /* check_corectld_version.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = check_corectld_version.command; sourceTree = "<group>"; };
4748
134F3CEB1D2C2270002B9668 /* check_blobs_version.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = check_blobs_version.command; sourceTree = "<group>"; };
@@ -60,7 +61,6 @@
6061
137597621D2BC9CF000CB88F /* update_corectl_blobs.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = update_corectl_blobs.command; sourceTree = "<group>"; };
6162
137597641D2BD5A5000CB88F /* copy_corectl_blobs.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = copy_corectl_blobs.command; sourceTree = "<group>"; };
6263
1375976A1D2BF306000CB88F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
63-
1375976E1D2C05AA000CB88F /* start_corectld.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = start_corectld.command; sourceTree = "<group>"; };
6464
13BC96B31D2CF42C006D27B3 /* Notifications.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Notifications.swift; sourceTree = "<group>"; };
6565
13BC96B51D2CF4DC006D27B3 /* RunShellApps.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RunShellApps.swift; sourceTree = "<group>"; };
6666
13BC96B91D2CF701006D27B3 /* HelpingFunctions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HelpingFunctions.swift; sourceTree = "<group>"; };
@@ -93,9 +93,9 @@
9393
136605371D23CCB200D497A0 /* functions.sh */,
9494
137597641D2BD5A5000CB88F /* copy_corectl_blobs.command */,
9595
134476011D2E5F220035B3B9 /* check_active_vms.command */,
96-
1375976E1D2C05AA000CB88F /* start_corectld.command */,
97-
13599DA81D4776E8004F8F5A /* start_docker_registry.command */,
96+
134B4DD11D6DC65D0018D004 /* check_dns_status.command */,
9897
134DD75B1D2FEBF100E60CDE /* check_corectld_status.command */,
98+
13599DA81D4776E8004F8F5A /* start_docker_registry.command */,
9999
1318E2031D302A3400EC75E9 /* stop_docker_registry.command */,
100100
136605361D23CCB200D497A0 /* fetch_latest_iso_alpha.command */,
101101
136605411D23E85800D497A0 /* fetch_latest_iso_beta.command */,
@@ -225,6 +225,7 @@
225225
134DD75E1D300CE400E60CDE /* check_corectld_version.command in Resources */,
226226
136605391D23CCB200D497A0 /* functions.sh in Resources */,
227227
137597651D2BD5A6000CB88F /* copy_corectl_blobs.command in Resources */,
228+
134B4DD21D6DC65D0018D004 /* check_dns_status.command in Resources */,
228229
1375975B1D2BA78E000CB88F /* bin in Resources */,
229230
136605381D23CCB200D497A0 /* fetch_latest_iso_alpha.command in Resources */,
230231
134DD75C1D2FEBF100E60CDE /* check_corectld_status.command in Resources */,
@@ -233,7 +234,6 @@
233234
136605431D23E85800D497A0 /* fetch_latest_iso_beta.command in Resources */,
234235
13599DAD1D477C6D004F8F5A /* registry in Resources */,
235236
13599DA91D4776E8004F8F5A /* start_docker_registry.command in Resources */,
236-
1375976F1D2C05AA000CB88F /* start_corectld.command in Resources */,
237237
);
238238
runOnlyForDeploymentPostprocessing = 0;
239239
};

src/corectl/AppDelegate.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5959
if (status == "no") {
6060
menuItem.menu?.itemWithTag(1)?.title = "Server is starting"
6161
// start corectld server
62-
ServerStartShell()
62+
ServerStart()
6363
//
6464
menuItem.menu?.itemWithTag(3)?.title = "Check for updates"
6565
}
@@ -146,7 +146,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
146146
@IBAction func About(sender: NSMenuItem) {
147147
let version = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString")as? String
148148
let mText: String = "Corectl for macOS v" + version!
149-
let infoText: String = "It is a simple wrapper around the corectld server, allows to have a control via the Status Bar App !!!"
149+
let infoText: String = "It is a simple wrapper around the \"corectld\" server, allows to have a control via the Status Bar App !!!"
150150
displayWithMessage(mText, infoText: infoText)
151151
}
152152

@@ -188,8 +188,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
188188
// check if corectl blobs are in place
189189
check_that_corectl_blobs_are_in_place()
190190

191+
// send stop to corectld just in case it was left running
192+
ServerStop()
193+
191194
// start corectld server
192-
ServerStartShell()
195+
ServerStart()
193196

194197
// start local docker registry
195198
startDockerRegistry()

src/corectl/HelpingFunctions.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@
99
import Foundation
1010
import Cocoa
1111

12+
13+
// check if DNS port 53 is free to be used
14+
func check_if_DNS_port_in_use() -> Bool {
15+
//
16+
let script = NSBundle.mainBundle().resourcePath! + "/check_dns_status.command"
17+
let status = shell(script, arguments: [])
18+
NSLog("DNS port use status: '%@'",status)
19+
//
20+
if (status == "yes"){
21+
// display the error message
22+
let mText: String = "Corectl for macOS"
23+
let infoText: String = "Cannot start \"corectld server\" as DNS port 53 is used by some application !!!"
24+
displayWithMessage(mText, infoText: infoText)
25+
return true
26+
}
27+
else {
28+
return false
29+
}
30+
31+
}
32+
1233
// check if corectl blobs exist
1334
func check_that_corectl_blobs_are_in_place() {
1435
// Get App's resource folder

src/corectl/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>0.2.4</string>
20+
<string>0.2.5</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>135</string>
24+
<string>137</string>
2525
<key>LSApplicationCategoryType</key>
2626
<string>public.app-category.utilities</string>
2727
<key>LSMinimumSystemVersion</key>

src/corectl/ServerControl.swift

Lines changed: 11 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,77 +9,26 @@
99
import Foundation
1010
import Cocoa
1111

12-
// server control //
1312

1413
// start corectld server
1514
func ServerStart() {
16-
// send stop to corectld just in case it was left running
17-
ServerStop()
1815

19-
// send an alert about the user password
20-
let mText: String = "Corectl for macOS"
21-
let infoText: String = "You will be asked to type your user password, needed to start 'corectld' server !!!"
22-
displayWithMessage(mText, infoText: infoText)
23-
24-
//
25-
let menuItem : NSStatusItem = statusItem
26-
27-
// start corectld server
28-
let task = NSTask()
29-
task.launchPath = "~/bin/corectld"
30-
task.arguments = ["start"]
31-
task.launch()
32-
task.waitUntilExit()
33-
34-
//
35-
let time = dispatch_time(dispatch_time_t(DISPATCH_TIME_NOW), 4 * Int64(NSEC_PER_SEC))
36-
dispatch_after(time, dispatch_get_main_queue()) {
37-
//
38-
let script = NSBundle.mainBundle().resourcePath! + "/check_corectld_status.command"
39-
let status = shell(script, arguments: [])
40-
NSLog("corectld running status: '%@'",status)
41-
//
42-
if (status == "no"){
43-
let menuItem : NSStatusItem = statusItem
44-
menuItem.menu?.itemWithTag(1)?.title = "Server is Off"
45-
// display the error message
46-
let mText: String = "Corectl for macOS"
47-
let infoText: String = "Cannot start the \"corectld server\" !!!"
48-
displayWithMessage(mText, infoText: infoText)
49-
}
50-
else {
51-
menuItem.menu?.itemWithTag(1)?.title = "Server is running"
52-
menuItem.menu?.itemWithTag(1)?.state = NSOnState
53-
//
54-
let script = NSBundle.mainBundle().resourcePath! + "/check_corectld_version.command"
55-
let version = shell(script, arguments: [])
56-
NSLog("corectld version: '%@'",version)
57-
menuItem.menu?.itemWithTag(11)?.title = " Server version: " + version
58-
}
59-
}
60-
}
61-
62-
63-
func ServerStartShell() {
64-
// send stop to corectld just in case it was left running
65-
let stop_task = NSTask()
66-
stop_task.launchPath = "~/bin/corectld"
67-
stop_task.arguments = ["stop"]
68-
stop_task.launch()
69-
stop_task.waitUntilExit()
16+
// check if DNS port 53 is not in use
17+
if check_if_DNS_port_in_use() {return}
7018

7119
// send an alert about the user password
7220
let mText: String = "Corectl for macOS"
73-
let infoText: String = "You will be asked to type your user password, needed to start 'corectld' server !!!"
21+
let infoText: String = "You will be asked to type your \"user\" password, needed to start \"corectld\" server !!!"
7422
displayWithMessage(mText, infoText: infoText)
7523

7624
//
7725
let menuItem : NSStatusItem = statusItem
7826

7927
// start corectld server
8028
let task: NSTask = NSTask()
81-
let launchPath = NSBundle.mainBundle().resourcePath! + "/start_corectld.command"
29+
let launchPath = "~/bin/corectld"
8230
task.launchPath = launchPath
31+
task.arguments = ["start", "--user", "$(whoami)"]
8332
task.launch()
8433
task.waitUntilExit()
8534

@@ -114,6 +63,7 @@ func ServerStartShell() {
11463

11564
// stop corectld server
11665
func ServerStop() {
66+
//
11767
let menuItem : NSStatusItem = statusItem
11868

11969
// show notification on to screen
@@ -143,19 +93,20 @@ func RestartServer() {
14393
notification.title = "Restarting corectld server"
14494
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(notification)
14595

146-
menuItem.menu?.itemWithTag(1)?.title = "Server is stopping"
147-
14896
// stop corectld server
97+
menuItem.menu?.itemWithTag(1)?.title = "Server is stopping"
14998
ServerStop()
15099

151-
menuItem.menu?.itemWithTag(1)?.title = "Server is starting"
152100
// start corectld server
153-
ServerStartShell()
101+
menuItem.menu?.itemWithTag(1)?.title = "Server is starting"
102+
ServerStart()
103+
154104
//
155105
menuItem.menu?.itemWithTag(3)?.title = "Check for App updates"
156106
menuItem.menu?.itemWithTag(4)?.title = "Check for corectl updates"
157107
}
158108

109+
159110
//
160111
func appDelegate () -> AppDelegate
161112
{

src/docker_registry

22.5 MB
Binary file not shown.

src/start_corectld.command

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)