From 46f327436f37c52e3f241bf5c3af5310a9823a9e Mon Sep 17 00:00:00 2001 From: Phani Pavan K Date: Sat, 14 Feb 2026 17:07:02 +0530 Subject: [PATCH] added update function for penv, to impl for jconf --- jconf | 2 ++ penv | 31 ++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/jconf b/jconf index 53b8807..43ce305 100755 --- a/jconf +++ b/jconf @@ -14,6 +14,8 @@ # reference: https://medium.com/@prateekaverma/install-jupyterhub-and-jupyterlab-on-ubuntu-server-d390570b5bb6 # detect if jconf is already installed, print who the admin is if so. +VERSION=1 + title() { echo "JConf: JupyterHub Configuration Manager." } diff --git a/penv b/penv index c3e14fd..7a64e83 100755 --- a/penv +++ b/penv @@ -5,9 +5,11 @@ # MIT Licensed, by The Grammer Society # Issues: -# names are fully lower case when installed as jupyterhub spec. convert name to lower case when deleting an env. # when uninstalling, remove any jupyter specs. iterate through envs in .env, call jspec remove name. +VERSION=1 + + usage() { echo "" echo "Usage: penv " @@ -21,6 +23,7 @@ usage() { echo " - list - List available environments" echo " - pylist - List available PYTHON versions" echo " - install - Initialize user's profile" + echo " - update - Update penv to latest version" echo " - uninstall - Remove ALL the environments installed using PENV" echo " - help - Print this message" echo @@ -31,6 +34,7 @@ usage() { echo " - activate -> ac, act" echo " - pylist -> pyls" echo " - list -> ls" + echo " - update -> up" } title(){ @@ -163,6 +167,7 @@ install() { " > "$HOME"/.envs/.penv.funcs add2RC bashrc add2RC zshrc + chmod +x "$HOME/.local/bin/penv" echo "Initialized PENV. Restart the shell" } @@ -203,6 +208,27 @@ pyls(){ find /usr/local/bin /usr/bin -name "python3.*" 2> /dev/null | tr " " "\n" | grep "3.*" --color=always } +update(){ + if [[ $(realpath "$0") != "$HOME/.local/bin/penv" ]]; then + echo PENV not installed yet. Install it to use the update command. + exit 12 + fi + + if [ -x "$(command -v curl)" ]; then + curl "https://git.pvnweb.dedyn.io/phanipavank/jbomb/raw/branch/master/penv" -o "$HOME/.local/bin/penv" + elif [ -x "$(command -v wget)" ]; then + wget -o "$HOME/.local/bin/penv" "https://git.pvnweb.dedyn.io/phanipavank/jbomb/raw/branch/master/penv" + else + echo Curl or wget not found. Install either one to update penv. + fi + chmod +x "$HOME/.local/bin/penv" + sleep 0.5 + newVer=$(grep VERSION "$HOME/.local/bin/penv" | cut -d '=' -f 2) + echo "PENV updated from $VERSION to $newVer" + exit 0 +} + + if [ "$#" -lt 1 ]; then title usage @@ -240,6 +266,9 @@ case "$cmd" in uninstall) uninstall ;; + update|up) + update + ;; *) echo "invalid command: \"$1\"" >&2 echo "$SCRIPT"