From 84ae0c3924c23aa6df6db6399482bb79670c0df3 Mon Sep 17 00:00:00 2001 From: npyl Date: Tue, 27 Nov 2018 00:02:24 +0200 Subject: [PATCH] Work for #17 --- Manage Conky.xcodeproj/project.pbxproj | 8 +++++ Manage Conky/MCObjects/MCObjects.m | 33 +++++++------------ Manage Conky/Resources/SetupFilesystem.sh | 16 +++++++++ Manage Conky/Resources/UninstallFilesystem.sh | 7 ++++ 4 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 Manage Conky/Resources/SetupFilesystem.sh create mode 100644 Manage Conky/Resources/UninstallFilesystem.sh diff --git a/Manage Conky.xcodeproj/project.pbxproj b/Manage Conky.xcodeproj/project.pbxproj index fb68033..1f0dc5e 100644 --- a/Manage Conky.xcodeproj/project.pbxproj +++ b/Manage Conky.xcodeproj/project.pbxproj @@ -22,6 +22,8 @@ 096341FD212E235500D011FD /* ConkyX-LICENSE in Copy Licenses */ = {isa = PBXBuildFile; fileRef = 096341FB212E234200D011FD /* ConkyX-LICENSE */; }; 098C76AF213C097600B1F05A /* Manage_Conky_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 098C76AE213C097600B1F05A /* Manage_Conky_Tests.m */; }; 09A20B7321AC9CED00FB7258 /* NPTask.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 09A20B6821AC9CCE00FB7258 /* NPTask.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 09A20B7621ACA14000FB7258 /* SetupFilesystem.sh in Resources */ = {isa = PBXBuildFile; fileRef = 09A20B7421AC9DF500FB7258 /* SetupFilesystem.sh */; }; + 09A20B7721ACA14000FB7258 /* UninstallFilesystem.sh in Resources */ = {isa = PBXBuildFile; fileRef = 09A20B7521ACA11A00FB7258 /* UninstallFilesystem.sh */; }; 09B56B08211B574E00075BC8 /* MCFilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B56B07211B574E00075BC8 /* MCFilesystem.m */; }; 09BF3BEB215CF21A003EF57D /* Fragaria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09BF3BE6215CF203003EF57D /* Fragaria.framework */; }; 09BF3BEC215CF22C003EF57D /* Fragaria.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 09BF3BE6215CF203003EF57D /* Fragaria.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -241,6 +243,8 @@ 098C76AE213C097600B1F05A /* Manage_Conky_Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Manage_Conky_Tests.m; sourceTree = ""; }; 098C76B0213C097600B1F05A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 09A20B5821AC9CCE00FB7258 /* NPTask.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = NPTask.xcodeproj; path = Frameworks/NPTask/NPTask.xcodeproj; sourceTree = ""; }; + 09A20B7421AC9DF500FB7258 /* SetupFilesystem.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = SetupFilesystem.sh; path = Resources/SetupFilesystem.sh; sourceTree = ""; }; + 09A20B7521ACA11A00FB7258 /* UninstallFilesystem.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = UninstallFilesystem.sh; path = Resources/UninstallFilesystem.sh; sourceTree = ""; }; 09ACA82A212E1F02002B9754 /* Fragaria-LICENSE-2.0.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "Fragaria-LICENSE-2.0.txt"; path = "Resources/Licenses/Fragaria-LICENSE-2.0.txt"; sourceTree = ""; }; 09B56B05211B565B00075BC8 /* MCFilesystem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MCFilesystem.h; sourceTree = ""; }; 09B56B07211B574E00075BC8 /* MCFilesystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MCFilesystem.m; sourceTree = ""; }; @@ -478,6 +482,8 @@ ECB76D5A205D716B00A3BB22 /* default-themes-2.1.cmtp.7z */, ECB76D5B205D716B00A3BB22 /* dsa_pub.pem */, 09421B4920FC2B480088187F /* toggleXquartzVisibilityScript.fmt */, + 09A20B7421AC9DF500FB7258 /* SetupFilesystem.sh */, + 09A20B7521ACA11A00FB7258 /* UninstallFilesystem.sh */, ); name = Resources; sourceTree = ""; @@ -744,6 +750,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 09A20B7621ACA14000FB7258 /* SetupFilesystem.sh in Resources */, + 09A20B7721ACA14000FB7258 /* UninstallFilesystem.sh in Resources */, 092114A52084BE9A0098AC5D /* Changelog.rtf in Resources */, 09366F712166A67900157ECA /* Preferences.xib in Resources */, ECB76D61205D725100A3BB22 /* Credits.rtf in Resources */, diff --git a/Manage Conky/MCObjects/MCObjects.m b/Manage Conky/MCObjects/MCObjects.m index 6cf180c..b69966a 100644 --- a/Manage Conky/MCObjects/MCObjects.m +++ b/Manage Conky/MCObjects/MCObjects.m @@ -12,6 +12,7 @@ #import #import #import "../Extensions/NSString+Relative.h" +#import /** `Helper function` * Check if Xquartz and conky are installed @@ -215,30 +216,20 @@ - (void)installManageConkyFilesystem NSString *ConkyXPath = [[NSBundle mainBundle] pathForResource:@"ConkyX" ofType:@"app"]; NSString *conkyPath = [[NSBundle bundleWithPath:ConkyXPath] pathForResource:@"conky" ofType:nil]; + NSString *scriptPath = [[NSBundle mainBundle] pathForResource:@"SetupFilesystem" ofType:@"sh"]; - // TODO(npyl): this needs to be done as ROOT, see #17 /* - * Create symbolic link to install ConkyX to Applications + * Run script that setups basic paths as administrator */ - if (![fm createSymbolicLinkAtPath:CONKYX withDestinationPath:ConkyXPath error:&error]) - { - MCError(error, @"Error creating symlink to Applications for ConkyX"); - } - - error = nil; - - // TODO: this needs to be done as ROOT - /* - * Create /usr/local/bin dir; - * Ensure that we are going to get the symlink in place. - */ - //[fm createDirectoryAtPath:@"/usr/local/bin" withIntermediateDirectories:YES attributes:nil error:&error]; - //if (error) - //{ - // NSLog(@"%@", error); - //} - - // TODO: This needs to be done as normal user + NSTask *script = [[NSTask alloc] init]; + script.launchPath = @"/bin/bash"; + script.arguments = @[@"-l", + @"-c", + scriptPath, + ConkyXPath]; + [script launchAuthenticated]; + [script waitUntilExit]; + /* * Create symbolic link to allow using from terminal */ diff --git a/Manage Conky/Resources/SetupFilesystem.sh b/Manage Conky/Resources/SetupFilesystem.sh new file mode 100644 index 0000000..c668b2c --- /dev/null +++ b/Manage Conky/Resources/SetupFilesystem.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# SetupStuff.sh +# Manage Conky +# +# Created by Nickolas Pylarinos Stamatelatos on 26/11/2018. +# Copyright © 2018 Nickolas Pylarinos. All rights reserved. + +CONKY_X=$1 + +# create symlink to ConkyX in Applications +ln -s "$CONKY_X" /Applications + +# Create /usr/local/bin dir; +# Ensure that we are going to get the symlink in place. +mkdir -p /usr/local/bin diff --git a/Manage Conky/Resources/UninstallFilesystem.sh b/Manage Conky/Resources/UninstallFilesystem.sh new file mode 100644 index 0000000..6f98cfe --- /dev/null +++ b/Manage Conky/Resources/UninstallFilesystem.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# UninstallFilesystem.sh +# Manage Conky +# +# Created by Nickolas Pylarinos Stamatelatos on 26/11/2018. +# Copyright © 2018 Nickolas Pylarinos. All rights reserved.