Compare commits

17 Commits

Author SHA1 Message Date
601cd2c7cd Update .gitea/workflows/lint.yaml
Some checks failed
/ Lint Check Shellscripts (push) Failing after 3s
2026-02-14 11:51:22 +00:00
1566bc3a05 make ci platform agnostic
Some checks failed
/ Lint Check Shellscripts (push) Failing after 3s
2026-02-14 11:49:03 +00:00
Phani Pavan K
46f327436f added update function for penv, to impl for jconf
Some checks failed
/ Lint Check Shellscripts (push) Failing after 4s
2026-02-14 17:07:02 +05:30
Phani Pavan K
a9f3b3ac37 add refs
All checks were successful
/ Lint Check Shellscripts (push) Successful in 16s
2026-02-06 13:27:01 +05:30
Phani Pavan K
2d42297d00 added deactivate command, name can be better, fixes #11
All checks were successful
/ Lint Check Shellscripts (push) Successful in 12s
2026-02-06 13:24:23 +05:30
Phani Pavan K
fb0257d60f fixes #12
All checks were successful
/ Lint Check Shellscripts (push) Successful in 16s
2026-02-06 13:14:47 +05:30
Phani Pavan K
a64bd7c8a6 add multi shell init, fixes #8
All checks were successful
/ Lint Check Shellscripts (push) Successful in 16s
2026-02-06 13:09:17 +05:30
Phani Pavan K
43350eaa41 print reclaimed size when uninstalling env, fixed #10
Some checks failed
/ Lint Check Shellscripts (push) Failing after 13s
2026-02-06 13:02:29 +05:30
Phani Pavan K
782ef16107 change ls to find for pyls 2026-02-06 12:52:52 +05:30
Phani Pavan K
0edc8467fd implement pylist, fixes #2
Some checks failed
/ Lint Check Shellscripts (push) Failing after 32s
2026-02-06 12:50:27 +05:30
Phani Pavan K
a8ecdb60a5 fixed #1 and stderr perm issue
All checks were successful
/ Lint Check Shellscripts (push) Successful in 16s
2026-01-13 20:58:20 +05:30
Phani Pavan K
928e8b2d2d added small commands, lowercasing env names
All checks were successful
/ Lint Check Shellscripts (push) Successful in 13s
2026-01-13 20:47:10 +05:30
eb96776e3c Merge pull request 'jbomb-automate' (#4) from jbomb-automate into master
All checks were successful
/ Lint Check Shellscripts (push) Successful in 11s
Reviewed-on: #4
2026-01-13 15:03:35 +00:00
Phani Pavan K
0d0b3477cd lowercase usernames
All checks were successful
/ Lint Check Shellscripts (push) Successful in 16s
/ Lint Check Shellscripts (pull_request) Successful in 12s
2026-01-13 20:32:34 +05:30
Phani Pavan K
e1f056a294 run only as root, remove read loop, add double question for deluser
All checks were successful
/ Lint Check Shellscripts (push) Successful in 28s
/ Lint Check Shellscripts (pull_request) Successful in 11s
2026-01-13 19:32:19 +05:30
e4f761b133 lint fixed
All checks were successful
/ Lint Check Shellscripts (push) Successful in 12s
/ Lint Check Shellscripts (pull_request) Successful in 11s
2026-01-12 09:20:20 +05:30
aa297095b0 lint error corrected
Some checks failed
/ Lint Check Shellscripts (push) Failing after 16s
/ Lint Check Shellscripts (pull_request) Failing after 11s
2026-01-12 09:19:32 +05:30
3 changed files with 125 additions and 48 deletions

View File

@@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v4
- name: Install Linter
run: |
wget -qO- 'https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.aarch64.tar.xz' | tar -xJv
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.$(uname -m).tar.xz" | tar -xJv
cp 'shellcheck-v0.11.0/shellcheck' /usr/local/bin
rm -rf "shellcheck-v0.11.0"
shellcheck --version

88
jconf Normal file → Executable file
View File

@@ -11,6 +11,10 @@
# deluser: deletes jupyterhub user, deletes user home, deletes user profile from system.
# start: starts the server, systemd call
# stop: stops the server, systemd call
# 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."
@@ -39,59 +43,73 @@ if [ "$#" -lt 1 ]; then
exit 1
fi
if [[ "$EUID" -ne 0 ]]; then
echo "Run the script as root"
exit 2
fi
cmd=$1
case "$cmd" in
adduser)
exist=$(awk -F: -v username="$2" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
adduser|mku)
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
if [ "$exist" -eq 1 ]; then
echo "$2 user already exists"
echo "$USER user already exists"
else
while true; do
read -p "Do you want to create an user account $2 [Y/n]:" yn
read -rp "Do you want to create an user account $USER [y/N]:" yn
case $yn in
[Yy]* )
useradd $2;
echo "Enter the password for $2:";
passwd $2
echo "$2 user account created successfully";
break;;
[Nn]* ) exit 1;;
* ) echo "Please answer Y or N.";;
[Yy])
useradd "$USER"
echo "Enter the password for $USER"
passwd "$USER"
echo "$USER user account created successfully"
;;
[Nn])
exit 1
;;
* )
echo "Please answer Y or N."
;;
esac
done
fi
exit 1
;;
deluser)
exist=$(awk -F: -v username="$2" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
deluser|rmu)
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
exist=$(awk -F: -v username="$USER" '{if ($1 == username && $3 >= 1000 && $1 != "nobody") {print 1; found=1; exit}} END {if (!found) print 0}' /etc/passwd)
if [ "$exist" -eq 0 ]; then
echo "$2 user doesn't exist"
echo "$USER user doesn't exist"
exit 1
else
while true; do
read -p "Do you want to delete $2 user account? [Y/n]:" yn
read -rp "Do you want to delete $USER user account? [y/N]:" yn
case $yn in
[Yy]* )
userdel -rRZ $2;
echo "$2 user account deleted successfully";
break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
[Yy])
;;
*)
exit 1
;;
esac
read -rp "This DELETES $USER's data, are you sure? [y/N]:" yn
case $yn in
[Yy])
userdel -rRZ "$USER";
echo "$USER user account deleted successfully"
;;
[Nn])
exit 1
;;
* )
echo "Please answer Y or N."
;;
esac
done
fi
exit 1
;;
listusers)
husers= awk -F: '{ if ($3 >= 1000 && $1 != "nobody" ) {print $1}}' /etc/passwd
echo $husers
listusers|ls)
husers=$(awk -F: '{ if ($3 >= 1000 && $1 != "nobody" ) {print $1}}' /etc/passwd)
echo "$husers"
;;
start)
echo
;;

75
penv Normal file → Executable file
View File

@@ -5,21 +5,25 @@
# 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 <command> <args>"
echo "Commands:"
echo " - new <name> <opt:version> - Create a new environment, optional, defaults to system's default python"
echo " - new <name> <ver=default> - Create a new environment, optional, defaults to system's default python"
echo " ex: penv new tools 3.13 -> creates new environment by the name tools, using Python 3.13"
echo " ex: penv new main -> creates new env with the name main, using the default Python version on the system"
echo " - del <name> - Delete existing environment"
# echo " - setdef <name> - Use an existing environment as the default kernel"
echo " - activate <name> - Activates an existing environment (depricated, use pact)"
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
@@ -28,7 +32,9 @@ usage() {
echo " - del -> rm"
# echo " - setdef -> sd"
echo " - activate -> ac, act"
echo " - pylist -> pyls"
echo " - list -> ls"
echo " - update -> up"
}
title(){
@@ -62,9 +68,10 @@ create(){
mkdir -p "$HOME"/.envs
/usr/bin/python"$vers" -m venv "$HOME"/.envs/"$name"
source "$HOME"/.envs/"$name"/bin/activate
python -m pip install ipykernel ipywidgets > /dev/stderr
python -m ipykernel install --user --name "$name" > /dev/stderr
python -m pip install ipykernel ipywidgets
python -m ipykernel install --user --name "$name"
echo
echo "--------------------------------------------------------------"
echo "Created \"$name\". It should be available as a Jupyter Kernel."
echo "Use \"pact $name\" to activate in command line."
deactivate
@@ -84,12 +91,14 @@ delete(){
read -r -n 1 -p "Remove environment $name (y/N)? " choise
case $choise in
[yY])
size=$(du "$HOME"/.envs/"$name" -sh | cut -f1)
source "$HOME"/.envs/"$name"/bin/activate
echo
echo Spec $(jupyter-kernelspec remove -f -y "$name")
deactivate
rm -r "$HOME/.envs/$name"
echo "Data Removed $HOME/.envs/$name"
echo "Reclaimed $size"
;;
[nN])
echo ""
@@ -130,6 +139,7 @@ install() {
echo PENV already installed
exit 10
fi
mkdir -p "$HOME/.local/bin"
cp $(realpath "$0") "$HOME"/.local/bin/
mkdir -p "$HOME"/.envs/
echo "
@@ -143,12 +153,30 @@ install() {
return;
fi
. \$HOME/.envs/\$1/bin/activate
echo Activated.
echo Deactivate using \\\"deactivate\\\" or \\\"pdct\\\"
}
pdct () {
if [[ ! -n \"\$VIRTUAL_ENV\" ]]; then
echo \"No environment active\"
return;
fi
deactivate
}
" > "$HOME"/.envs/.penv.funcs
grep -qxF "source \$HOME/.envs/.penv.funcs" "$HOME"/.bashrc || echo "source \$HOME/.envs/.penv.funcs" >> "$HOME"/.bashrc
add2RC bashrc
add2RC zshrc
chmod +x "$HOME/.local/bin/penv"
echo "Initialized PENV. Restart the shell"
}
add2RC(){
if [[ -f "$HOME/.$1" ]]; then
grep -qxF "source \$HOME/.envs/.penv.funcs" "$HOME/.$1" || echo "source \$HOME/.envs/.penv.funcs" >> "$HOME/.$1"
fi
}
uninstall() {
if [[ -n "$VIRTUAL_ENV" ]]; then
echo "Deactivate the existing environment before uninstalling"
@@ -176,6 +204,31 @@ uninstall() {
echo "Uninstalled PENV"
}
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
@@ -186,20 +239,23 @@ cmd=$1
case "$cmd" in
new|mk)
create "$2" "$3"
create "$(echo "$2" | tr "[:upper:]" "[:lower:]")" "$3"
;;
del|rm)
delete "$2"
delete "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
;;
# setdef|sd)
# setdef $2
# ;;
act|ac)
activate "$2"
activate "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
;;
list|ls)
list
;;
pylist|pyls)
pyls
;;
help)
title
usage
@@ -210,6 +266,9 @@ case "$cmd" in
uninstall)
uninstall
;;
update|up)
update
;;
*)
echo "invalid command: \"$1\"" >&2
echo "$SCRIPT"