Skip to content

Instantly share code, notes, and snippets.

@otzoran
Last active October 1, 2021 11:30
Show Gist options
  • Select an option

  • Save otzoran/0214f5f9e817c54c597da31dd86c9162 to your computer and use it in GitHub Desktop.

Select an option

Save otzoran/0214f5f9e817c54c597da31dd86c9162 to your computer and use it in GitHub Desktop.

Revisions

  1. otzoran revised this gist Oct 1, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion brewupd.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/usr/bin/env bash
    # https://gist.github.com/otzoran/0214f5f9e817c54c597da31dd86c9162
    # curl -o xx https://gist.githubusercontent.com/otzoran/0214f5f9e817c54c597da31dd86c9162/raw

    TIM=60
    PROG=$(basename $0)
  2. otzoran revised this gist Oct 1, 2021. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions brewupd.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,11 @@
    #!/usr/bin/env bash
    # https://gist.github.com/otzoran/0214f5f9e817c54c597da31dd86c9162

    TIM=60
    PROG=$(basename $0)

    trap 'echo "ERROR $? at ${PROG}:$LINENO - [$BASH_COMMAND]"' err

    function wait_confirmation
    {
    set +e # without it, timeout will provoke exit from the shell...
    @@ -32,6 +37,7 @@ function wait_confirmation
    }

    set -ex
    trap -p
    brew update
    fm=$(brew outdated --formula)
    fm=${fm//$'\n'/ } # suppress \n replace by space
    @@ -49,6 +55,10 @@ pkk=${pkk//$'\n'/ } # suppress \n replace by space
    set +x

    #test pkk='opera postman'
    #TODO: brew info $pkg, ==> Artifacts
    # Brave Browser.app (App)
    # pgrep -f "Brave Browser.app" => list of pid's, one per line {pgrep -fl = long}

    if [[ -n "$pkk" ]]; then
    printf "fetch outdated:\n$pkk\n"
    brew fetch --cask $pkk
  3. otzoran revised this gist Sep 24, 2021. 1 changed file with 59 additions and 12 deletions.
    71 changes: 59 additions & 12 deletions brewupd.sh
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,66 @@
    #!/usr/bin/env bash

    TIM=60
    function wait_confirmation
    {
    set +e # without it, timeout will provoke exit from the shell...
    casks="$1"
    ANS=''
    for ii in seq 1 5; do
    # play sound brew_end_fetch.m4a
    #set -x
    /usr/bin/afplay -v 0.3 ~/Music/brew_end_fetch.m4a
    read -t $TIM -p "Finished brew fetch $casks. Install? [y]: " ANS
    exstat=$?
    if [[ $exstat > 128 ]]; then
    HHMM=$(date '+%T')
    printf "\n%2d [%s] timeout\n" $ii $HHMM
    continue
    elif [[ $exstat == 0 ]]; then
    [[ -z $ANS ]] && ANS="y";
    else
    printf "%2d in loop, read exstat == $exstat\n"
    fi

    if [[ $ANS == "y" ]]; then
    return 0
    fi
    done
    set +e
    return 1

    }

    set -ex
    brew update
    fm=$(brew outdated --formula)
    ck=$(brew outdated --cask)
    printf "\n\n=====\n\n"
    brew upgrade --formula
    # upd 2020-11-05
    pkk=$(brew outdated --cask --greedy --quiet | grep -v android-file-transfer)
    if [[ -n $pkk ]]; then
    printf "outdated:\n$pkk\n"
    fm=${fm//$'\n'/ } # suppress \n replace by space
    set +x
    #ck=$(brew outdated --cask)
    printf "\n=====\n"
    if [[ -n "$fm" ]]; then
    /usr/bin/afplay -v 0.3 ~/Music/brew_start_upg_formula.m4a
    brew upgrade --formula
    fi

    set -x
    pkk=$(brew outdated --cask --greedy --quiet | grep -v android-file-transfer | paste -s -d ' ' -)
    pkk=${pkk//$'\n'/ } # suppress \n replace by space
    set +x

    #test pkk='opera postman'
    if [[ -n "$pkk" ]]; then
    printf "fetch outdated:\n$pkk\n"
    brew fetch --cask $pkk
    printf "installing:\n$pkk\n"
    # 2021-01 upd switch
    brew reinstall --cask $pkk
    wait_confirmation "$pkk"
    if [[ $? == 0 ]]; then
    printf "installing: $pkk\n"
    # 2021-01 upd switch
    brew reinstall --cask $pkk
    else
    printf "Bailed out, run brew reinstall --cask $pkk"
    fi
    fi
    printf "\n\n===== updated formula:\n$fm\n"
    printf "\n\n===== updated casks:\n$ck\n"

    printf "\n===== updated formula:\n$fm\n"
    printf "\n===== updated casks:\n$pkk\n"
  4. otzoran revised this gist Aug 20, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions brewupd.sh
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    set -ex
    brew update
    fm=$(brew outdated --formula)
    ck=$(brew outdated --cask)
    printf "\n\n=====\n\n"
    brew upgrade --formula
    # upd 2020-11-05
  5. otzoran revised this gist Aug 20, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions brewupd.sh
    Original file line number Diff line number Diff line change
    @@ -13,3 +13,5 @@ if [[ -n $pkk ]]; then
    # 2021-01 upd switch
    brew reinstall --cask $pkk
    fi
    printf "\n\n===== updated formula:\n$fm\n"
    printf "\n\n===== updated casks:\n$ck\n"
  6. otzoran created this gist Aug 20, 2021.
    15 changes: 15 additions & 0 deletions brewupd.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/usr/bin/env bash

    set -ex
    brew update
    printf "\n\n=====\n\n"
    brew upgrade --formula
    # upd 2020-11-05
    pkk=$(brew outdated --cask --greedy --quiet | grep -v android-file-transfer)
    if [[ -n $pkk ]]; then
    printf "outdated:\n$pkk\n"
    brew fetch --cask $pkk
    printf "installing:\n$pkk\n"
    # 2021-01 upd switch
    brew reinstall --cask $pkk
    fi