Skip to content

Commit 114935a

Browse files
committed
v0.0.6
1 parent 64ab303 commit 114935a

File tree

11 files changed

+294
-3
lines changed

11 files changed

+294
-3
lines changed

src/corectl.xcodeproj/project.pbxproj

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,26 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
136605381D23CCB200D497A0 /* fetch_latest_iso_alpha.command in Resources */ = {isa = PBXBuildFile; fileRef = 136605361D23CCB200D497A0 /* fetch_latest_iso_alpha.command */; };
11+
136605391D23CCB200D497A0 /* functions.sh in Resources */ = {isa = PBXBuildFile; fileRef = 136605371D23CCB200D497A0 /* functions.sh */; };
12+
1366053B1D23D6AD00D497A0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1366053A1D23D6AD00D497A0 /* Foundation.framework */; };
13+
1366053D1D23D6B800D497A0 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1366053C1D23D6B800D497A0 /* AppKit.framework */; };
14+
1366053F1D23D6C700D497A0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1366053E1D23D6C700D497A0 /* Cocoa.framework */; };
15+
136605431D23E85800D497A0 /* fetch_latest_iso_beta.command in Resources */ = {isa = PBXBuildFile; fileRef = 136605411D23E85800D497A0 /* fetch_latest_iso_beta.command */; };
16+
136605441D23E85800D497A0 /* fetch_latest_iso_stable.command in Resources */ = {isa = PBXBuildFile; fileRef = 136605421D23E85800D497A0 /* fetch_latest_iso_stable.command */; };
1017
13CAFC2A1D2272B000E57ED4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13CAFC291D2272B000E57ED4 /* AppDelegate.swift */; };
1118
13CAFC2C1D2272B000E57ED4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13CAFC2B1D2272B000E57ED4 /* Assets.xcassets */; };
1219
13CAFC2F1D2272B000E57ED4 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13CAFC2D1D2272B000E57ED4 /* MainMenu.xib */; };
1320
/* End PBXBuildFile section */
1421

1522
/* Begin PBXFileReference section */
23+
136605361D23CCB200D497A0 /* fetch_latest_iso_alpha.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fetch_latest_iso_alpha.command; sourceTree = "<group>"; };
24+
136605371D23CCB200D497A0 /* functions.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = functions.sh; sourceTree = "<group>"; };
25+
1366053A1D23D6AD00D497A0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
26+
1366053C1D23D6B800D497A0 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
27+
1366053E1D23D6C700D497A0 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
28+
136605411D23E85800D497A0 /* fetch_latest_iso_beta.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fetch_latest_iso_beta.command; sourceTree = "<group>"; };
29+
136605421D23E85800D497A0 /* fetch_latest_iso_stable.command */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = fetch_latest_iso_stable.command; sourceTree = "<group>"; };
1630
13CAFC261D2272B000E57ED4 /* corectl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = corectl.app; sourceTree = BUILT_PRODUCTS_DIR; };
1731
13CAFC291D2272B000E57ED4 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1832
13CAFC2B1D2272B000E57ED4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -25,16 +39,42 @@
2539
isa = PBXFrameworksBuildPhase;
2640
buildActionMask = 2147483647;
2741
files = (
42+
1366053F1D23D6C700D497A0 /* Cocoa.framework in Frameworks */,
43+
1366053D1D23D6B800D497A0 /* AppKit.framework in Frameworks */,
44+
1366053B1D23D6AD00D497A0 /* Foundation.framework in Frameworks */,
2845
);
2946
runOnlyForDeploymentPostprocessing = 0;
3047
};
3148
/* End PBXFrameworksBuildPhase section */
3249

3350
/* Begin PBXGroup section */
51+
136605351D23CC9A00D497A0 /* scripts */ = {
52+
isa = PBXGroup;
53+
children = (
54+
136605361D23CCB200D497A0 /* fetch_latest_iso_alpha.command */,
55+
136605411D23E85800D497A0 /* fetch_latest_iso_beta.command */,
56+
136605421D23E85800D497A0 /* fetch_latest_iso_stable.command */,
57+
136605371D23CCB200D497A0 /* functions.sh */,
58+
);
59+
name = scripts;
60+
sourceTree = "<group>";
61+
};
62+
136605401D23D6F600D497A0 /* Frameworks */ = {
63+
isa = PBXGroup;
64+
children = (
65+
1366053E1D23D6C700D497A0 /* Cocoa.framework */,
66+
1366053C1D23D6B800D497A0 /* AppKit.framework */,
67+
1366053A1D23D6AD00D497A0 /* Foundation.framework */,
68+
);
69+
name = Frameworks;
70+
sourceTree = "<group>";
71+
};
3472
13CAFC1D1D2272B000E57ED4 = {
3573
isa = PBXGroup;
3674
children = (
3775
13CAFC281D2272B000E57ED4 /* corectl */,
76+
136605351D23CC9A00D497A0 /* scripts */,
77+
136605401D23D6F600D497A0 /* Frameworks */,
3878
13CAFC271D2272B000E57ED4 /* Products */,
3979
);
4080
sourceTree = "<group>";
@@ -117,8 +157,12 @@
117157
isa = PBXResourcesBuildPhase;
118158
buildActionMask = 2147483647;
119159
files = (
160+
136605441D23E85800D497A0 /* fetch_latest_iso_stable.command in Resources */,
120161
13CAFC2C1D2272B000E57ED4 /* Assets.xcassets in Resources */,
121162
13CAFC2F1D2272B000E57ED4 /* MainMenu.xib in Resources */,
163+
136605391D23CCB200D497A0 /* functions.sh in Resources */,
164+
136605381D23CCB200D497A0 /* fetch_latest_iso_alpha.command in Resources */,
165+
136605431D23E85800D497A0 /* fetch_latest_iso_beta.command in Resources */,
122166
);
123167
runOnlyForDeploymentPostprocessing = 0;
124168
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
type = "1"
4+
version = "2.0">
5+
</Bucket>

src/corectl/AppDelegate.swift

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Cocoa
10+
import Foundation
1011

1112
@NSApplicationMain
1213
class AppDelegate: NSObject, NSApplicationDelegate {
@@ -78,13 +79,105 @@ class AppDelegate: NSObject, NSApplicationDelegate {
7879
ServerStart()
7980
}
8081

82+
83+
// fetch latest ISOs
84+
85+
@IBAction func fetchLatestISOAlpha(sender: NSMenuItem) {
86+
87+
// send a notification on to the screen
88+
let notification: NSUserNotification = NSUserNotification()
89+
notification.title = "Corectl"
90+
notification.informativeText = "CoreOS Alpha ISO image will be updated"
91+
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(notification)
92+
93+
// run the script
94+
runTerminal(NSBundle.mainBundle().resourcePath! + "/fetch_latest_iso_alpha.command")
95+
96+
}
97+
98+
99+
@IBAction func fetchLatestISOBeta(sender: NSMenuItem) {
100+
// send a notification on to the screen
101+
let notification: NSUserNotification = NSUserNotification()
102+
notification.title = "Corectl"
103+
notification.informativeText = "CoreOS Beta ISO image will be updated"
104+
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(notification)
105+
106+
// run the script
107+
runTerminal(NSBundle.mainBundle().resourcePath! + "/fetch_latest_iso_beta.command")
108+
}
109+
110+
111+
@IBAction func fetchLatestISOStable(sender: NSMenuItem) {
112+
// send a notification on to the screen
113+
let notification: NSUserNotification = NSUserNotification()
114+
notification.title = "Corectl"
115+
notification.informativeText = "CoreOS Stable ISO image will be updated"
116+
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(notification)
117+
118+
// run the script
119+
runTerminal(NSBundle.mainBundle().resourcePath! + "/fetch_latest_iso_stable.command")
120+
}
121+
//
122+
81123

82124
@IBAction func Quit(sender: NSMenuItem) {
125+
// send a notification on to the screen
126+
let notification: NSUserNotification = NSUserNotification()
127+
notification.title = "Quitting Corectl App"
128+
NSUserNotificationCenter.defaultUserNotificationCenter().deliverNotification(notification)
129+
83130
// stop corectld server
84131
ServerStop()
85132

86133
// exit App
87134
exit(0)
88135
}
136+
137+
138+
// helping functions
139+
140+
func runScript(scriptName: String, arguments: String) {
141+
let task: NSTask = NSTask()
142+
task.launchPath = "\(NSBundle.mainBundle().pathForResource(scriptName, ofType: "command")!)"
143+
task.arguments = [arguments]
144+
task.launch()
145+
task.waitUntilExit()
146+
}
147+
148+
149+
func runTerminal(arguments: String) {
150+
let fileManager = NSFileManager.defaultManager()
151+
// Check if file exists, given its path
152+
if fileManager.fileExistsAtPath("/Applications/iTerm.app") {
153+
// lunch iTerm App
154+
NSWorkspace.sharedWorkspace().openFile(arguments, withApplication: "iTerm")
155+
} else {
156+
// lunch Terminal App
157+
NSWorkspace.sharedWorkspace().openFile(arguments, withApplication: "Terminal")
158+
}
159+
}
160+
161+
162+
func runApp(appName: String, arguments: String) {
163+
// lunch an external App
164+
NSWorkspace.sharedWorkspace().openFile(arguments, withApplication: appName)
165+
}
166+
167+
// notifications
168+
func userNotificationCenter(center: NSUserNotificationCenter, shouldPresentNotification notification: NSUserNotification) -> Bool {
169+
return true
170+
}
171+
172+
173+
func displayWithMessage(mText: String, infoText: String) {
174+
let alert: NSAlert = NSAlert()
175+
// alert.alertStyle = NSInformationalAlertStyle
176+
// alert.icon = NSImage(named: "coreos-wordmark-vert-color")
177+
alert.messageText = mText
178+
alert.informativeText = infoText
179+
alert.runModal()
180+
}
181+
89182
}
90183

src/corectl/Base.lproj/MainMenu.xib

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,40 @@
683683
</connections>
684684
</menuItem>
685685
<menuItem isSeparatorItem="YES" id="7F0-f8-uD9"/>
686-
<menuItem title="Quit" tag="3" alternate="YES" id="Nfe-LP-eNg">
686+
<menuItem title="Check for updates" id="G6m-bG-AHV">
687+
<modifierMask key="keyEquivalentModifierMask"/>
688+
</menuItem>
689+
<menuItem title="Fetch latest CoreOS ISO" id="cxS-wy-CSq">
690+
<modifierMask key="keyEquivalentModifierMask"/>
691+
<menu key="submenu" title="Fetch latest CoreOS ISO" id="WjL-bi-BbT">
692+
<items>
693+
<menuItem title="Alpha" id="0SQ-P4-rTq">
694+
<modifierMask key="keyEquivalentModifierMask"/>
695+
<connections>
696+
<action selector="fetchLatestISOAlpha:" target="Voe-Tx-rLC" id="DCJ-Zh-pW9"/>
697+
</connections>
698+
</menuItem>
699+
<menuItem title="Beta" id="KEW-NR-3cp">
700+
<modifierMask key="keyEquivalentModifierMask"/>
701+
<connections>
702+
<action selector="fetchLatestISOBeta:" target="Voe-Tx-rLC" id="3sE-Lg-VcR"/>
703+
</connections>
704+
</menuItem>
705+
<menuItem title="Stable" id="gJK-EZ-iV0">
706+
<modifierMask key="keyEquivalentModifierMask"/>
707+
<connections>
708+
<action selector="fetchLatestISOStable:" target="Voe-Tx-rLC" id="xjn-If-zaL"/>
709+
</connections>
710+
</menuItem>
711+
</items>
712+
</menu>
713+
</menuItem>
714+
<menuItem isSeparatorItem="YES" id="6MD-ne-tfW"/>
715+
<menuItem title="Preferences" id="jv0-Md-oMt">
716+
<modifierMask key="keyEquivalentModifierMask"/>
717+
</menuItem>
718+
<menuItem isSeparatorItem="YES" id="gfq-fY-qL1"/>
719+
<menuItem title="Quit Corectl" tag="3" alternate="YES" id="Nfe-LP-eNg">
687720
<modifierMask key="keyEquivalentModifierMask"/>
688721
<connections>
689722
<action selector="Quit:" target="Voe-Tx-rLC" id="1hY-bR-e5f"/>

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.0.5</string>
20+
<string>0.0.6</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
24-
<string>25</string>
24+
<string>27</string>
2525
<key>LSMinimumSystemVersion</key>
2626
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
2727
<key>LSUIElement</key>

src/fetch_latest_iso_alpha.command

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# fetch latest iso
4+
#
5+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
6+
source "${DIR}"/functions.sh
7+
8+
# set channel
9+
CHANNEL=alpha
10+
11+
echo " "
12+
echo "Fetching lastest CoreOS $CHANNEL channel ISO ..."
13+
echo " "
14+
#
15+
/usr/local/sbin/corectl pull --channel="$CHANNEL" 2>&1 | tee ~/.coreos/tmp/check_channel
16+
CHECK_CHANNEL=$(cat ~/.coreos/tmp/check_channel | grep "downloading" | awk '{print $2}')
17+
#
18+
if [[ "$CHECK_CHANNEL" == "downloading" ]]; then
19+
echo " "
20+
echo "You need to reload your VMs to use the lastest version !!! "
21+
rm -f ~/.coreos/tmp/check_channel
22+
fi
23+
24+
echo " "
25+
pause 'Press [Enter] key to continue...'

src/fetch_latest_iso_beta.command

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# fetch latest iso
4+
#
5+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
6+
source "${DIR}"/functions.sh
7+
8+
# set channel
9+
CHANNEL=beta
10+
11+
echo " "
12+
echo "Fetching lastest CoreOS $CHANNEL channel ISO ..."
13+
echo " "
14+
#
15+
/usr/local/sbin/corectl pull --channel="$CHANNEL" 2>&1 | tee ~/.coreos/tmp/check_channel
16+
CHECK_CHANNEL=$(cat ~/.coreos/tmp/check_channel | grep "downloading" | awk '{print $2}')
17+
#
18+
if [[ "$CHECK_CHANNEL" == "downloading" ]]; then
19+
echo " "
20+
echo "You need to reload your VMs to use the lastest version !!! "
21+
rm -f ~/.coreos/tmp/check_channel
22+
fi
23+
24+
echo " "
25+
pause 'Press [Enter] key to continue...'

src/fetch_latest_iso_stable.command

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# fetch latest iso
4+
#
5+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
6+
source "${DIR}"/functions.sh
7+
8+
# set channel
9+
CHANNEL=stable
10+
11+
echo " "
12+
echo "Fetching lastest CoreOS $CHANNEL channel ISO ..."
13+
echo " "
14+
#
15+
/usr/local/sbin/corectl pull --channel="$CHANNEL" 2>&1 | tee ~/.coreos/tmp/check_channel
16+
CHECK_CHANNEL=$(cat ~/.coreos/tmp/check_channel | grep "downloading" | awk '{print $2}')
17+
#
18+
if [[ "$CHECK_CHANNEL" == "downloading" ]]; then
19+
echo " "
20+
echo "You need to reload your VMs to use the lastest version !!! "
21+
rm -f ~/.coreos/tmp/check_channel
22+
fi
23+
24+
echo " "
25+
pause 'Press [Enter] key to continue...'

src/functions.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# shared functions library
4+
5+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
6+
7+
8+
function pause(){
9+
read -p "$*"
10+
}
11+
12+
13+
14+
15+
16+

src/install_iterm.command

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# fetch latest iso
4+
#
5+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
6+
source "${DIR}"/functions.sh
7+
8+
# set channel
9+
CHANNEL=stable
10+
11+
echo " "
12+
echo "Fetching lastest CoreOS $CHANNEL channel ISO ..."
13+
echo " "
14+
#
15+
/usr/local/sbin/corectl pull --channel="$CHANNEL" 2>&1 | tee ~/.coreos/tmp/check_channel
16+
CHECK_CHANNEL=$(cat ~/.coreos/tmp/check_channel | grep "downloading" | awk '{print $2}')
17+
#
18+
if [[ "$CHECK_CHANNEL" == "downloading" ]]; then
19+
echo " "
20+
echo "You need to reload your VMs to use the lastest version !!! "
21+
rm -f ~/.coreos/tmp/check_channel
22+
fi
23+
24+
echo " "
25+
pause 'Press [Enter] key to continue...'

0 commit comments

Comments
 (0)