14
14
15
15
ssl ._create_default_https_context = ssl ._create_unverified_context
16
16
17
- INSTALL_DIR = "/usr/local/bin"
17
+ INSTALL_DIR = os .path .expanduser ("~/.odin" )
18
+ OLD_ODIN = "/usr/local/bin/odin"
18
19
19
20
20
21
def find_odin_file (directory = INSTALL_DIR , prefix = "odin-" ):
21
22
pattern = os .path .join (directory , f"{ prefix } *" ) # Match files like 'odin-*'
22
23
files = glob .glob (pattern )
23
24
if files :
24
25
return files [0 ]
25
- return INSTALL_DIR + "/odin"
26
+ return OLD_ODIN
26
27
27
28
28
- OLD_ODIN = INSTALL_DIR + "/odin"
29
29
NEW_ODIN = find_odin_file ()
30
30
31
31
branch = "update/mig-script"
@@ -72,9 +72,8 @@ def set_tokens(config_file):
72
72
73
73
74
74
def get_current_bin_version ():
75
- directory = '/usr/local/bin'
76
75
try :
77
- files = os .listdir (directory )
76
+ files = os .listdir (INSTALL_DIR )
78
77
for file in files :
79
78
if file .startswith ('odin-' ):
80
79
return file .split ("-" )[1 ]
@@ -98,19 +97,21 @@ def update_binary():
98
97
latest_version = filtered_files [0 ].split ("-" )[1 ]
99
98
100
99
current_version = get_current_bin_version ()
101
- NEW_ODIN = find_odin_file (INSTALL_DIR )
102
100
103
101
if current_version is None or current_version < latest_version :
104
102
print (f"Updating odin binary to version { latest_version } " )
105
103
url = f"https://raw.githubusercontent.com/dream11/odin/{ branch } /odin-{ latest_version } "
106
104
filepath = os .path .join (INSTALL_DIR , f"odin-{ latest_version } " )
107
105
urlretrieve (url , filename = filepath )
108
106
os .chmod (filepath , 0o755 )
107
+ # Enable app verification and remove quarantine attributes
108
+ subprocess .call (["sudo" , "spctl" , "--master-enable" ])
109
+ subprocess .call (["xattr" , "-dr" , "com.apple.quarantine" , filepath ])
109
110
else :
110
111
print (f"Error: Unable to fetch files (Status Code: { response .status_code } )" )
111
112
return []
112
113
except Exception as e :
113
- print ("Error: Unable to fetch files" )
114
+ print (f "Error: Unable to fetch files: { e } " )
114
115
115
116
116
117
def execute_new_odin ():
0 commit comments