Skip to content

Commit 9eee2cc

Browse files
committed
chore: updatecli binary
Signed-off-by: surajgour-d11 <[email protected]>
1 parent c9dfc35 commit 9eee2cc

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

migrate-odin.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,3 @@ add_odin_to_shell_config "$HOME/.zshrc"
5757
add_odin_to_shell_config "$HOME/.bashrc"
5858
#add_odin_to_shell_config "$HOME/.bash_profile"
5959

60-
# Enable app verification and remove quarantine attributes
61-
sudo spctl --master-enable
62-
xattr -dr com.apple.quarantine /usr/local/bin/odin-new

switch.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414

1515
ssl._create_default_https_context = ssl._create_unverified_context
1616

17-
INSTALL_DIR = "/usr/local/bin"
17+
INSTALL_DIR = os.path.expanduser("~/.odin")
18+
OLD_ODIN = "/usr/local/bin/odin"
1819

1920

2021
def find_odin_file(directory=INSTALL_DIR, prefix="odin-"):
2122
pattern = os.path.join(directory, f"{prefix}*") # Match files like 'odin-*'
2223
files = glob.glob(pattern)
2324
if files:
2425
return files[0]
25-
return INSTALL_DIR + "/odin"
26+
return OLD_ODIN
2627

2728

28-
OLD_ODIN = INSTALL_DIR + "/odin"
2929
NEW_ODIN = find_odin_file()
3030

3131
branch = "update/mig-script"
@@ -72,9 +72,8 @@ def set_tokens(config_file):
7272

7373

7474
def get_current_bin_version():
75-
directory = '/usr/local/bin'
7675
try:
77-
files = os.listdir(directory)
76+
files = os.listdir(INSTALL_DIR)
7877
for file in files:
7978
if file.startswith('odin-'):
8079
return file.split("-")[1]
@@ -98,19 +97,21 @@ def update_binary():
9897
latest_version = filtered_files[0].split("-")[1]
9998

10099
current_version = get_current_bin_version()
101-
NEW_ODIN = find_odin_file(INSTALL_DIR)
102100

103101
if current_version is None or current_version < latest_version:
104102
print(f"Updating odin binary to version {latest_version}")
105103
url = f"https://raw.githubusercontent.com/dream11/odin/{branch}/odin-{latest_version}"
106104
filepath = os.path.join(INSTALL_DIR, f"odin-{latest_version}")
107105
urlretrieve(url, filename=filepath)
108106
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])
109110
else:
110111
print(f"Error: Unable to fetch files (Status Code: {response.status_code})")
111112
return []
112113
except Exception as e:
113-
print("Error: Unable to fetch files")
114+
print(f"Error: Unable to fetch files: {e}")
114115

115116

116117
def execute_new_odin():

0 commit comments

Comments
 (0)