Skip to content

Instantly share code, notes, and snippets.

@jtmoon79
Last active October 26, 2022 02:23
Show Gist options
  • Save jtmoon79/1b5a806b3e71874542c21b1578156a42 to your computer and use it in GitHub Desktop.
Save jtmoon79/1b5a806b3e71874542c21b1578156a42 to your computer and use it in GitHub Desktop.
install glances system monitor on a Debian system
#!/usr/bin/env bash
#
# install glances system monitor onto a Debian-based System under user "glances"
# https://github.com/nicolargo/glances
#
# This creates user "glances" (which glances presumes to do) but for the purpose of install the program glances (and the
# required libraries) under permissions of user glances. This way,
# - glances programs are slightly better contained under user glances permissions
# - glances (and related programs) are not added to shared $PATH directories
#
# followed by https://gist.github.com/jtmoon79/1bd435862f7fd06cf1ed98ce9b05f672
set -e
set -u
# add user glances and create home directory
# (glances program does this, but it is unable to do it under constrained permissions)
adduser --home /var/lib/glances --shell $(which false) --disabled-password glances
mkdir /var/lib/glances
chown glances /var/lib/glances
# install the necessary python software (may not be necessary)
apt install -y python-pip python3-pip virtualenv
# remaining runs as user glances for python 3
sudo -Hu glances -- bash << EOF
export VENV_GLANCES=/var/lib/glances/.venv-3.glances
virtualenv --python python3 "${VENV_GLANCES}"
# remaining runs inside virtualenv
source "${VENV_GLANCES}/bin/activate"
pip3 install 'glances[web]' # adjust this as needed, see https://github.com/nicolargo/glances#pypi-the-simple-way
glances -w &
EOF
# (optional) add to /etc/rc.local or your preferred way of starting a program at boot-time
# see https://gist.github.com/jtmoon79/1bd435862f7fd06cf1ed98ce9b05f672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment