diff --git a/VERSION b/VERSION index afaf360..7f20734 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.0.1 \ No newline at end of file diff --git a/lib/functions.sh b/lib/functions.sh index e224224..c1bab64 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -86,33 +86,31 @@ _checkroot () { # -- check_for_updates help_cmd[check-update]="Check for updates to wpst" -function tool_check-update () { - local script_name="$1" - local github_url="$2" - +function wpst_check_update () { # Get the local version from the VERSION file - local local_version + local LOCAL_VERSION if [[ -f "VERSION" ]]; then - local_version=$(cat "VERSION") + LOCAL_VERSION=$(cat "VERSION") else echo "ERROR: VERSION file not found." return 1 fi # Get the remote version from GitHub - local remote_version - remote_version=$(curl -sSL "$github_url/VERSION") - if [[ -z "$remote_version" ]]; then + local REMOTE_VERSION + REMOTE_VERSION=$(curl -sSL "$GITHUB_URL/VERSION") + if [[ -z "$REMOTE_VERSION" ]]; then echo "ERROR: Failed to retrieve remote version from GitHub." return 1 fi # Compare local and remote versions - if [[ "$local_version" == "$remote_version" ]]; then - echo "Your script ($script_name) is up to date." + if [[ "$LOCAL_VERSION" == "$REMOTE_VERSION" ]]; then + echo "Up to date. Local:$LOCAL_VERSION - Latest: $REMOTE_VERSION" + # Check if local version is higher than remote version + elif [[ "$LOCAL_VERSION" > "$REMOTE_VERSION" ]]; then + echo "Local version ($LOCAL_VERSION) is higher than latest version ($REMOTE_VERSION)." else - echo "Your script ($script_name) is out of date." - echo "Local version: $local_version" - echo "Remote version: $remote_version" + echo "Out of date. Local:$LOCAL_VERSION - Latest: $REMOTE_VERSION" fi } \ No newline at end of file diff --git a/wpst.sh b/wpst.sh index 887f724..227b8e2 100755 --- a/wpst.sh +++ b/wpst.sh @@ -6,6 +6,7 @@ SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )" WPST_VERSION="$(cat ${SCRIPT_DIR}/VERSION)" SCRIPT_NAME="wpst" +GITHUB_URL="https://raw.githubusercontent.com/managingwp/wp-shelltools/main/" source $SCRIPT_DIR/lib/functions.sh # Core Functions source $SCRIPT_DIR/lib/functions-gp.sh # GP Functions @@ -77,8 +78,8 @@ elif [[ $ACTION = "ajaxlog" ]]; then elif [[ $ACTION = gp-* ]]; then cmd_$@ -elif [[ $ACTION = "check-updates" ]]; then - wpst_check_updates +elif [[ $ACTION = "check-update" ]]; then + wpst_check_update else usage exit 1