Skip to content

Commit

Permalink
add auto-update mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazzaps committed Oct 16, 2023
1 parent 4d9336b commit 46570cf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ ampm --server='nfs://1.2.3.4/some/repo' get foobar:mbf5qxqli76zx7btc5n7fkq47tjs6

# Remove artifact from server (must be precise hash), Make sure no one is using the artifact!
ampm remote-rm --i-realise-this-may-break-other-peoples-builds-in-the-future foobar:mbf5qxqli76zx7btc5n7fkq47tjs6cl2

# Update ampm
ampm update
```

## Hash calculation algorithm
Expand Down
2 changes: 1 addition & 1 deletion ampm/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.5.3'
__version__ = '1.5.5'
5 changes: 5 additions & 0 deletions ampm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,11 @@ def edit(ctx: click.Context, artifact: str, attr: Dict[str, str], env: Dict[str,
remote_repo.edit_artifact(artifact, attr, env)


@cli.command()
def update():
os.system("/opt/ampm/update.sh")


def main():
cli()

Expand Down
8 changes: 8 additions & 0 deletions ampm/get_ampm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
set -e

REMOTE_REPO="nfs://127.0.0.1/mnt/myshareddir#ampm_repo"
UPDATE_URL="https://github.com/Wazzaps/ampm/releases/latest/download/get_ampm.sh"
UPDATE_CMD="curl -fsSL $UPDATE_URL | sudo sh"

if [ "$(id -u)" -ne 0 ]; then
echo 'This script must be run as root'
Expand All @@ -17,6 +19,12 @@ echo ''
echo "Configuring remote repo to be '$REMOTE_REPO'..."
echo "$REMOTE_REPO" > /opt/ampm.tmp/repo_uri

echo ''
echo "Configuring update url to be '$UPDATE_URL'..."
echo "#!/bin/sh" > /opt/ampm.tmp/update.sh
echo "$UPDATE_CMD" >> /opt/ampm.tmp/update.sh
chmod +x /opt/ampm.tmp/update.sh

echo ''
echo 'Adding ampm launcher to /usr/local/bin/...'
install /opt/ampm.tmp/ampm.sh /usr/local/bin/ampm
Expand Down

0 comments on commit 46570cf

Please sign in to comment.