Skip to content

Commit

Permalink
Update selfUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuwei Ye authored and Shuwei Ye committed Oct 24, 2023
1 parent 84716b4 commit a2aeecf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion run-atlas_container.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# coding: utf-8
# version=2023-10-24-alpha02
# version=2023-10-24-alpha03
# author: Shuwei Ye <yesw@bnl.gov>
"true" '''\'
myScript="${BASH_SOURCE:-$0}"
Expand Down Expand Up @@ -150,12 +150,14 @@ def selfUpdate(args):
latestVersion = getVersion(content.split('\n'))
if latestVersion is not None:
if currentVersion is None or latestVersion > currentVersion:
print("Update available, updating the script itself")
myScript = os.path.abspath(sys.argv[0])
os.rename(myScript, myScript + '.old')
try:
myfile = open(myScript, 'w')
myfile.write(content)
myfile.close()
print("Update finished")
except Exception:
err = sys.exc_info()[1]
print("Failed to write out the latest version of this script\n", err)
Expand Down

0 comments on commit a2aeecf

Please sign in to comment.