Skip to content

Instantly share code, notes, and snippets.

@ageis
Last active February 9, 2018 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ageis/8b231bdb76ca8c7a7e0aede551cc53c5 to your computer and use it in GitHub Desktop.
Save ageis/8b231bdb76ca8c7a7e0aede551cc53c5 to your computer and use it in GitHub Desktop.
Update gems, nodejs, Perl, PyPi modules and apt packages
function updateall() {
#set -o pipefail noclobber erexit
set -v
#set -e
#set -x
function exit_error() {
echo "You can only run updateall() once at a time." >&2
}
function status() {
echo "Exit code is $1"
echo "Process ID is $2"
#kill $2
jobs -n
if [[ $? -gt 0 ]]; then
cat <&"${updates[0]}"
#read output <&"${updates[0]}"
#echo "$output"
fi
}
function lock() {
if [ -e /proc/"${UPDATES_COPROC_PID}" ] && [ -a /proc/"${UPDATES_COPROC_PID}"/exe ]; then
exit_error; return 1
fi
exec 200>/tmp/updates.lock
flock --exclusive --nonblock 200 && return 0 || return 1
}
#lock || exit_error; return 1
#trap "rm -f /tmp/updates.lock" EXIT SIGABRT SIGTERM
trap 'status $? $$' ERR SIGHUP SIGINT SIGTERM
coproc updates {
sudo --preserve-env --login /bin/bash;
}
export UPDATES_COPROC_PID="${updates_PID}"
dependencies=(
"export PERL_MM_USE_DEFAULT=1; perl -MCPAN -e 'install Bundle::CPAN'"
"curl -L http://cpanmin.us | perl - App::cpanminus"
"cpanm App::cpanoutdated"
"wget -qO- https://bootstrap.pypa.io/get-pip.py | python2"
"pip2 install -U pip_review"
"wget -qO- https://bootstrap.pypa.io/get-pip.py | python3"
"pip3 install -U pip_review"
)
declare -i deps=$(expr "${#dependencies[@]}" - 1)
#for i in $(seq 0 "$deps"); do
# sudo --preserve-env --login /bin/bash -c "${dependencies[$i]}" &
#done
commands=(
"gem list | cut -d ' ' -f 1 | gem update"
"npm update -g"
"cpan-outdated -p | cpanm"
"python2 -m pip_review --auto"
"python3 -m pip_review --auto"
#"pip2 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip2 install -U"
#"pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U"
"apt-get -qy update"
"export DEBIAN_FRONTEND=noninteractive; export DEBIAN_PRIORITY=critical; apt-get -qy -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" upgrade"
)
declare -i cmds=$(expr "${#commands[@]}" - 1)
for i in $(seq 0 "$cmds"); do
echo "(${commands[$i]})&" >&"${updates[1]}"
done
wait;
#flock --unlock 200
}
@ageis
Copy link
Author

ageis commented Feb 9, 2018

The ENV gets all screwed up in the coproc subshell.

Error loading RubyGems plugin "/var/lib/gems/2.3.0/gems/gitian-0.0.3/lib/rubygems_plugin.rb": cannot load such file -- /var/lib/gems/2.3.0/gems/gitian-0.0.3/lib/rubygems_plugin.rb (LoadError)
Could not parse requirement: -lxc
bash: line 4: addressable: command not found
bash: line 5: atk: command not found
bash: line 6: bales: command not found
bash: line 7: bigdecimal: command not found
bash: line 8: builder: command not found
bash: line 10: cairo: command not found
bash: line 11: cairo-gobject: command not found
bash: line 12: childprocess: command not found
bash: line 13: coffee-script: command not found
bash: line 14: coffee-script-source: command not found
bash: line 15: colorator: command not found
bash: line 17: concurrent-ruby: command not found
bash: line 18: connection_pool: command not found
bash: line 19: crack: command not found
bash: line 20: did_you_mean: command not found
bash: line 21: diff-lcs: command not found
bash: line 22: digitalocean: command not found
bash: line 23: domain_name: command not found
bash: line 24: em-websocket: command not found
bash: line 26: ethon: command not found
bash: line 27: eventmachine: command not found
bash: line 28: execjs: command not found
bash: line 29: fake_ftp: command not found
bash: line 30: faraday: command not found
bash: line 31: faraday_middleware: command not found
bash: line 32: ffi: command not found
bash: line 33: forwardable-extended: command not found
bash: line 34: gdk_pixbuf2: command not found
Usage: gemoji extract <path> [--size=64]
gettext: missing arguments
bash: line 37: gio2: command not found
bash: line 39: github-pages-health-check: command not found
bash: line 40: gitian: command not found
bash: line 41: glib2: command not found
bash: line 42: gobject-introspection: command not found
bash: line 43: gssapi: command not found
bash: line 44: gtk2: command not found
bash: line 45: gyoku: command not found
bash: line 46: hashdiff: command not found
bash: line 47: hashicorp-checkpoint: command not found
bash: line 48: html-pipeline: command not found
bash: line 49: http-cookie: command not found
bash: line 50: http_parser.rb: command not found
bash: line 52: i18n: command not found
bash: line 53: io-console: command not found
A subcommand is required. 
bash: line 55: jekyll-avatar: command not found
bash: line 56: jekyll-coffeescript: command not found
bash: line 57: jekyll-commonmark: command not found
bash: line 58: jekyll-commonmark-ghpages: command not found
bash: line 59: jekyll-default-layout: command not found
bash: line 60: jekyll-feed: command not found
bash: line 61: jekyll-gist: command not found
bash: line 62: jekyll-github-metadata: command not found
bash: line 63: jekyll-mentions: command not found
bash: line 64: jekyll-optional-front-matter: command not found
bash: line 65: jekyll-paginate: command not found
bash: line 66: jekyll-readme-index: command not found
bash: line 67: jekyll-redirect-from: command not found
bash: line 68: jekyll-relative-links: command not found
bash: line 69: jekyll-remote-theme: command not found
bash: line 70: jekyll-sass-converter: command not found
bash: line 71: jekyll-seo-tag: command not found
bash: line 72: jekyll-sitemap: command not found
bash: line 73: jekyll-swiss: command not found
bash: line 74: jekyll-theme-architect: command not found
bash: line 75: jekyll-theme-cayman: command not found
bash: line 76: jekyll-theme-dinky: command not found
bash: line 77: jekyll-theme-hacker: command not found
bash: line 78: jekyll-theme-leap-day: command not found
bash: line 79: jekyll-theme-merlot: command not found
bash: line 80: jekyll-theme-midnight: command not found
bash: line 81: jekyll-theme-minimal: command not found
bash: line 82: jekyll-theme-modernist: command not found
bash: line 83: jekyll-theme-primer: command not found
bash: line 84: jekyll-theme-slate: command not found
bash: line 85: jekyll-theme-tactile: command not found
bash: line 86: jekyll-theme-time-machine: command not found
bash: line 87: jekyll-titles-from-headings: command not found
bash: line 88: jekyll-watch: command not found
bash: line 89: jemoji: command not found
bash: line 90: json: command not found
bash: line 92: liquid: command not found
Expected array default value for '--directory'; got "." (string)
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/lib/python2.7/logging/__init__.py", line 852, in flush
    self.stream.flush()
IOError: [Errno 11] Resource temporarily unavailable
Logged from file req_set.py, line 496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment