use ctl install_launcher, only start via launchctl if launcher is installed

This commit is contained in:
Jan Gerber 2015-03-31 20:25:18 +02:00
parent 0731e8c963
commit 01e66b647a
2 changed files with 9 additions and 28 deletions

View file

@ -5,8 +5,12 @@ if [[ ! -e "/usr/sbin/miredo" ]]; then
open -W ../Resources/miredo-osx-v1.2.6-beta2.pkg open -W ../Resources/miredo-osx-v1.2.6-beta2.pkg
fi fi
if [[ -e "$BASE" ]]; then if [[ -e "$BASE" ]]; then
if [[ -e "$HOME/Library/LaunchAgents/com.openmedialibrary.loginscript.plist" ]]; then
launchctl start com.openmedialibrary.loginscript launchctl start com.openmedialibrary.loginscript
open "$BASE/openmedialibrary/static/html/load.html" open "$BASE/openmedialibrary/static/html/load.html"
else
"$BASE/ctl" open
fi
else else
python install.py "$BASE" & python install.py "$BASE" &
open ../Resources/static/install.html open ../Resources/static/install.html

View file

@ -85,7 +85,7 @@ class Install(Thread):
self.status["progress"] = 1 self.status["progress"] = 1
with open('config/release.json', 'w') as fd: with open('config/release.json', 'w') as fd:
json.dump(release, fd, indent=2) json.dump(release, fd, indent=2)
self.install_launchd() os.system("./ctl install_launcher")
self.status = {"done": True} self.status = {"done": True}
self.httpd.shutdown() self.httpd.shutdown()
@ -111,29 +111,6 @@ class Install(Thread):
data = json.load(u) data = json.load(u)
return data 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('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>%s</string>
<key>ProgramArguments</key>
<array>
<string>%s/ctl</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>''' % (name, self.target))
os.system('launchctl load "%s"' % plist)
os.system('launchctl start %s' % name)
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) == 1: if len(sys.argv) == 1:
target = os.path.join(os.curdir, 'openmedialibrary') target = os.path.join(os.curdir, 'openmedialibrary')