mirror of
https://github.com/munki/munki.git
synced 2026-04-23 13:29:26 -05:00
munkiimport: Only offer to unmount the repo if we mounted it in the first place.
git-svn-id: http://munki.googlecode.com/svn/trunk@1028 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
+12
-3
@@ -100,6 +100,7 @@ def mountRepoGUI():
|
||||
|
||||
def mountRepoCLI():
|
||||
"""Attempts to connect to the repo fileshare"""
|
||||
global WE_MOUNTED_THE_REPO
|
||||
repo_path = pref('repo_path')
|
||||
repo_url = pref('repo_url')
|
||||
if os.path.exists(repo_path):
|
||||
@@ -110,6 +111,8 @@ def mountRepoCLI():
|
||||
retcode = subprocess.call(cmd)
|
||||
if retcode:
|
||||
os.rmdir(repo_path)
|
||||
else:
|
||||
WE_MOUNTED_THE_REPO = True
|
||||
|
||||
|
||||
def unmountRepoCLI():
|
||||
@@ -442,12 +445,17 @@ def makeCatalogs():
|
||||
|
||||
|
||||
def cleanupAndExit(exitcode):
|
||||
if not NOINTERACTIVE:
|
||||
answer = raw_input('Unmount the repo fileshare? [y/n] ')
|
||||
if answer.lower().startswith('y'):
|
||||
result = 0
|
||||
if WE_MOUNTED_THE_REPO:
|
||||
if not NOINTERACTIVE:
|
||||
answer = raw_input('Unmount the repo fileshare? [y/n] ')
|
||||
if answer.lower().startswith('y'):
|
||||
result = unmountRepoCLI()
|
||||
else:
|
||||
result = unmountRepoCLI()
|
||||
exit(exitcode or result)
|
||||
|
||||
|
||||
def pref(prefname):
|
||||
"""Returns a preference for prefname"""
|
||||
try:
|
||||
@@ -483,6 +491,7 @@ PREFSNAME = 'com.googlecode.munki.munkiimport.plist'
|
||||
PREFSPATH = os.path.expanduser(os.path.join('~/Library/Preferences',
|
||||
PREFSNAME))
|
||||
NOINTERACTIVE = False
|
||||
WE_MOUNTED_THE_REPO = False
|
||||
|
||||
def main():
|
||||
"""Main routine"""
|
||||
|
||||
Reference in New Issue
Block a user