Skip to content

Add automatic update notification system to eic-shell#25

Open
Copilot wants to merge 4 commits intomainfrom
copilot/add-update-notification-system
Open

Add automatic update notification system to eic-shell#25
Copilot wants to merge 4 commits intomainfrom
copilot/add-update-notification-system

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

Adds a non-intrusive, offline-safe update notification system that alerts users when a newer eic-shell release is available, with local modification protection and a self-upgrade path.

New behavior

  • On normal startup, a background check (check_for_updates_async) compares the installed release version against the latest GitHub release — never blocking shell startup
  • Single-line notification when an update is available:
    eic-shell update available (24.06.0-stable -> 24.09.0-stable). Run './eic-shell --upgrade' to update.
    eic-shell update available (24.06.0-stable -> 24.09.0-stable), but local modifications detected. Reinstall with: curl -L https://get.epic-eic.org | bash
    
  • Results cached for 24 hours to avoid repeated API calls; fails silently when offline (5s curl timeout)

New flags (both Singularity and Docker launchers)

  • --upgrade — re-runs https://get.epic-eic.org installer preserving PREFIX/VERSION/CONTAINER; blocked if local script modifications are detected
  • --version (no argument) — prints current container and installed version on a single line: container: eic_xl:nightly version: 24.06.0-stable. When called with an argument (Singularity only), sets the version to install as before.

install.sh changes

  • After generating the eic-shell launcher, fetches the current release tag from the GitHub API asynchronously (non-blocking) and records it alongside the script's mtime in $PREFIX/.eic-shell-metadata
  • If offline during install, stores "unknown" as the installed version

Metadata and cache files

File Contents
$PREFIX/.eic-shell-metadata INSTALLED_VERSION, INSTALLED_DATE, CONTAINER, ORGANIZATION, EIC_SHELL_ORIGINAL_MTIME
$PREFIX/.eic-shell-version-check LAST_CHECK, LATEST_VERSION, CHECK_STATUS, HAS_LOCAL_MODIFICATIONS

Local modification detection compares the current mtime of the eic-shell script against EIC_SHELL_ORIGINAL_MTIME stored at install time. Cross-platform stat fallback handles both Linux (stat -c %Y) and macOS (stat -f %m).

Original prompt

Overview

Add an automatic update notification system to eic-shell that alerts users when newer versions are available on the main branch. The system should be non-intrusive, work offline, and protect user modifications.

Requirements

Core Functionality

  1. Track commits from main branch

    • Store the installed commit SHA (7-char short form) in metadata file
    • Check GitHub API for latest commit on main branch: https://api.github.com/repos/eic/eic-shell/commits/main
    • Compare current vs latest commit SHA
  2. Non-blocking, offline-safe version checking

    • Check for updates asynchronously in background (don't delay shell startup)
    • Network requests must have timeout (5 seconds)
    • Fail silently if network unavailable
    • Cache results for 24 hours to avoid excessive API calls
  3. Local modification detection

    • Track original mtime of eic-shell script in metadata
    • Detect if script modified within last 24 hours
    • Block automatic upgrade if local modifications detected
    • Show different notification message when mods detected
  4. Simple notifications

    • Single-line output when update available
    • No fancy boxes or multi-line output
    • Format: eic-shell update available (oldsha -> newsha). Run './eic-shell --upgrade' to update.
    • With mods: eic-shell update available (oldsha -> newsha), but local modifications detected. Reinstall with: curl -L https://get.epic-eic.org | bash
  5. Upgrade mechanism

    • New --upgrade flag on eic-shell launcher
    • Downloads and runs latest install.sh from https://get.epic-eic.org
    • Preserves existing configuration (PREFIX, CONTAINER, VERSION, etc.)
    • Blocks upgrade if local modifications detected
    • Updates metadata after successful upgrade
  6. Manual check option

    • New --check-updates flag to force immediate check
    • Bypasses 24-hour cache
    • Shows current status

Implementation Details

Metadata file: $PREFIX/.eic-shell-metadata

INSTALLED_COMMIT=a1b2c3d
INSTALLED_DATE=1234567890
CONTAINER=eic_xl
ORGANIZATION=eicweb
EIC_SHELL_ORIGINAL_MTIME=1234567890

Cache file: $PREFIX/.eic-shell-version-check

LAST_CHECK=1234567890
LAST_CHECK_DATE="Fri Mar 14 12:00:00 UTC 2026"
LATEST_COMMIT=e4f5g6h
CHECK_STATUS=success
HAS_LOCAL_MODIFICATIONS=no

Changes to install.sh:

  1. After creating eic-shell script, fetch current commit SHA from GitHub API
  2. Create metadata file with commit SHA and script mtime
  3. If offline during install, use "unknown" as commit SHA

Changes to eic-shell launcher:

  1. Add version check functions at the top
  2. Add --upgrade and --check-updates to argument parsing
  3. Call check_for_updates_async on normal startup (background, non-blocking)
  4. Implement upgrade logic that re-downloads and runs install.sh

Key Functions to Implement

In eic-shell launcher script:

  • read_metadata() - Source metadata file
  • check_local_modifications() - Return 0 if modified in last 24h, 1 otherwise
  • should_check_version() - Return 0 if cache older than 1 day, 1 otherwise
  • fetch_latest_commit() - Curl GitHub API with timeout, extract 7-char SHA
  • cache_version_check() - Write results to cache file
  • read_cached_commit() - Read LATEST_COMMIT from cache
  • read_cached_modification_status() - Read HAS_LOCAL_MODIFICATIONS from cache
  • display_update_notification() - Echo single-line message
  • check_for_updates() - Main check logic (respects cache, handles offline)
  • check_for_updates_async() - Background wrapper with output suppression

Cross-platform Compatibility

  • Use stat with fallback for macOS (stat -f %m) and Linux (stat -c %Y)
  • Use [[ =~ ]] for regex matching (available in bash)
  • Curl flags should work on both platforms

Error Handling

  • All curl commands: curl -s --connect-timeout 5 --max-time 5 ... 2>/dev/null
  • Validate commit SHA is 7 hex chars: [[ "$result" =~ ^[0-9a-f]{7}$ ]]
  • Suppress all errors from background check: ( check_for_updates 2>/dev/null & )
  • Never exit or error on network failure - just continue silently

Configuration

  • EIC_SHELL_REPO="eic/eic-shell"
  • INSTALL_URL="https://get.epic-eic.org"
  • CHECK_INTERVAL_DAYS=1
  • NETWORK_TIMEOUT=5
  • MODIFICATION_GRACE_HOURS=24

Testing Scenarios

  1. Normal operation: User starts eic-shell, check happens in background, notification appears if update available
  2. Offline: Network unavailable, check times out silently, shell starts normally
  3. Local modifications: User edited eic-shell within 24h, notification shows reinstall message, --upgrade blocked
  4. Force check: ./eic-shell --check-updates bypasses cache, shows current status
  5. Upgrade: ./eic-shell --upgrade downloads installer, reruns with same config, updates metadata
  6. Rate limiting: Multiple shell starts within 24h use cached result, don't hit API

Notes

  • This is for the existing install.sh (shell script version)...

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 14, 2026 16:00
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Copilot AI changed the title [WIP] Add automatic update notification system to eic-shell Add automatic update notification system to eic-shell Mar 14, 2026
Copilot AI requested a review from wdconinc March 14, 2026 16:02
install.sh Outdated
echo "OPTIONAL ARGUMENTS:"
echo " -u,--upgrade Upgrade the container to the latest version"
echo " -u,--upgrade Upgrade eic-shell to the latest version"
echo " --check-updates Check for available eic-shell updates"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Remove the --check-updates functionality. Only do implicit update checks. Explicit update checks are not supported, and the user can anyway do an explicit upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9c3d4f1. Removed --check-updates from both Singularity and Docker launchers (argument parsing, help text, and handler blocks).

install.sh Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Although --version serves a different purpose already, add support for the --version options without a second argument to print the current container version and other metadata (on a single line).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9c3d4f1. --version with no argument (or when followed by another flag) now prints a single line: container: eic_xl:nightly version: 24.06.0-stable. With an argument it continues to set the version to install (Singularity) or is version-info only (Docker). The help text and examples are updated accordingly.

install.sh Outdated
Comment on lines +800 to +803
INSTALLED_VERSION=$(curl -s --connect-timeout 5 --max-time 5 \
"https://api.github.com/repos/eic/eic-shell/releases/latest" 2>/dev/null \
| grep '"tag_name":' \
| sed -E 's/.*"([^"]+)".*/\1/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Ensure that the curl call here is also async and not blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9c3d4f1. The GitHub API call is now in a background subshell (( ... ) &). The stat to capture the eic-shell mtime still runs synchronously (it's a fast local filesystem call), while the curl + metadata file write happens asynchronously without blocking the install.

Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com>
Copilot AI requested a review from wdconinc March 14, 2026 16:23
@wdconinc wdconinc marked this pull request as ready for review March 14, 2026 17:57
Copilot AI review requested due to automatic review settings March 14, 2026 17:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an offline-safe, non-blocking update notification system to the generated eic-shell launcher (Singularity and Docker), plus a self-upgrade path via re-running the installer and additional metadata/cache files under $PREFIX.

Changes:

  • Add background GitHub release checks with 24h caching and single-line update notifications in both launcher variants.
  • Add --upgrade and enhanced --version behavior to the launchers.
  • Persist install metadata ($PREFIX/.eic-shell-metadata) and version-check cache ($PREFIX/.eic-shell-version-check), with installer recording original launcher mtime.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +218 to +223
function read_metadata() {
local metadata_file="\${PREFIX}/.eic-shell-metadata"
if [ -f "\${metadata_file}" ]; then
source "\${metadata_file}"
fi
}
Comment on lines +438 to +440
curl -L \${INSTALL_URL} \
| bash -s -- \${FLAGS}
echo "eic-shell upgrade sucessful"
echo "eic-shell upgrade successful"
Comment on lines +510 to +515
function read_metadata() {
local metadata_file="\${PREFIX}/.eic-shell-metadata"
if [ -f "\${metadata_file}" ]; then
source "\${metadata_file}"
fi
}
Comment on lines +700 to +702
curl -L \${INSTALL_URL} \
| bash -s -- \${FLAGS}
echo "eic-shell upgrade successful"
Comment on lines +761 to +767
{
echo "INSTALLED_VERSION=$INSTALLED_VERSION"
echo "INSTALLED_DATE=$(date +%s)"
echo "CONTAINER=$CONTAINER"
echo "ORGANIZATION=$ORGANIZATION"
echo "EIC_SHELL_ORIGINAL_MTIME=$EIC_SHELL_MTIME"
} > "${PREFIX}/.eic-shell-metadata"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants