From 01e66b647a99d31f72828e91e806b4be988bd059 Mon Sep 17 00:00:00 2001 From: Jan Gerber Date: Tue, 31 Mar 2015 20:25:18 +0200 Subject: [PATCH] use ctl install_launcher, only start via launchctl if launcher is installed --- .../Contents/MacOS/Open Media Library | 12 ++++++--- .../Contents/MacOS/install.py | 25 +------------------ 2 files changed, 9 insertions(+), 28 deletions(-) diff --git a/Open Media Library.app/Contents/MacOS/Open Media Library b/Open Media Library.app/Contents/MacOS/Open Media Library index 78c784f..8944c50 100755 --- a/Open Media Library.app/Contents/MacOS/Open Media Library +++ b/Open Media Library.app/Contents/MacOS/Open Media Library @@ -5,9 +5,13 @@ if [[ ! -e "/usr/sbin/miredo" ]]; then open -W ../Resources/miredo-osx-v1.2.6-beta2.pkg fi if [[ -e "$BASE" ]]; then - launchctl start com.openmedialibrary.loginscript - open "$BASE/openmedialibrary/static/html/load.html" + if [[ -e "$HOME/Library/LaunchAgents/com.openmedialibrary.loginscript.plist" ]]; then + launchctl start com.openmedialibrary.loginscript + open "$BASE/openmedialibrary/static/html/load.html" + else + "$BASE/ctl" open + fi else - python install.py "$BASE" & - open ../Resources/static/install.html + python install.py "$BASE" & + open ../Resources/static/install.html fi diff --git a/Open Media Library.app/Contents/MacOS/install.py b/Open Media Library.app/Contents/MacOS/install.py index 3a75b53..9d3e933 100755 --- a/Open Media Library.app/Contents/MacOS/install.py +++ b/Open Media Library.app/Contents/MacOS/install.py @@ -85,7 +85,7 @@ class Install(Thread): self.status["progress"] = 1 with open('config/release.json', 'w') as fd: json.dump(release, fd, indent=2) - self.install_launchd() + os.system("./ctl install_launcher") self.status = {"done": True} self.httpd.shutdown() @@ -111,29 +111,6 @@ class Install(Thread): data = json.load(u) return data - def install_launchd(self): - name = 'com.openmedialibrary.loginscript' - plist = os.path.expanduser('~/Library/LaunchAgents/%s.plist'%name) - with open(plist, 'w') as f: - f.write(''' - - - - Label - %s - ProgramArguments - - %s/ctl - start - - RunAtLoad - - -''' % (name, self.target)) - os.system('launchctl load "%s"' % plist) - os.system('launchctl start %s' % name) - - if __name__ == '__main__': if len(sys.argv) == 1: target = os.path.join(os.curdir, 'openmedialibrary')