Compare commits
4 Commits
jbomb-auto
...
0edc8467fd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0edc8467fd | ||
|
|
a8ecdb60a5 | ||
|
|
928e8b2d2d | ||
| eb96776e3c |
4
jconf
4
jconf
@@ -47,7 +47,7 @@ fi
|
|||||||
|
|
||||||
cmd=$1
|
cmd=$1
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
adduser)
|
adduser|mku)
|
||||||
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
|
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)
|
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
|
if [ "$exist" -eq 1 ]; then
|
||||||
@@ -71,7 +71,7 @@ case "$cmd" in
|
|||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
deluser)
|
deluser|rmu)
|
||||||
USER=$(echo "$2" | tr "[:upper:]" "[:lower:]")
|
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)
|
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
|
if [ "$exist" -eq 0 ]; then
|
||||||
|
|||||||
20
penv
Normal file → Executable file
20
penv
Normal file → Executable file
@@ -19,6 +19,7 @@ usage() {
|
|||||||
# echo " - setdef <name> - Use an existing environment as the default kernel"
|
# echo " - setdef <name> - Use an existing environment as the default kernel"
|
||||||
echo " - activate <name> - Activates an existing environment (depricated, use pact)"
|
echo " - activate <name> - Activates an existing environment (depricated, use pact)"
|
||||||
echo " - list - List available environments"
|
echo " - list - List available environments"
|
||||||
|
echo " - pylist - List available PYTHON versions"
|
||||||
echo " - install - Initialize user's profile"
|
echo " - install - Initialize user's profile"
|
||||||
echo " - uninstall - Remove ALL the environments installed using PENV"
|
echo " - uninstall - Remove ALL the environments installed using PENV"
|
||||||
echo " - help - Print this message"
|
echo " - help - Print this message"
|
||||||
@@ -28,6 +29,7 @@ usage() {
|
|||||||
echo " - del -> rm"
|
echo " - del -> rm"
|
||||||
# echo " - setdef -> sd"
|
# echo " - setdef -> sd"
|
||||||
echo " - activate -> ac, act"
|
echo " - activate -> ac, act"
|
||||||
|
echo " - pylist -> pyls"
|
||||||
echo " - list -> ls"
|
echo " - list -> ls"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,8 +64,8 @@ create(){
|
|||||||
mkdir -p "$HOME"/.envs
|
mkdir -p "$HOME"/.envs
|
||||||
/usr/bin/python"$vers" -m venv "$HOME"/.envs/"$name"
|
/usr/bin/python"$vers" -m venv "$HOME"/.envs/"$name"
|
||||||
source "$HOME"/.envs/"$name"/bin/activate
|
source "$HOME"/.envs/"$name"/bin/activate
|
||||||
python -m pip install ipykernel ipywidgets > /dev/stderr
|
python -m pip install ipykernel ipywidgets
|
||||||
python -m ipykernel install --user --name "$name" > /dev/stderr
|
python -m ipykernel install --user --name "$name"
|
||||||
echo
|
echo
|
||||||
echo "Created \"$name\". It should be available as a Jupyter Kernel."
|
echo "Created \"$name\". It should be available as a Jupyter Kernel."
|
||||||
echo "Use \"pact $name\" to activate in command line."
|
echo "Use \"pact $name\" to activate in command line."
|
||||||
@@ -130,6 +132,7 @@ install() {
|
|||||||
echo PENV already installed
|
echo PENV already installed
|
||||||
exit 10
|
exit 10
|
||||||
fi
|
fi
|
||||||
|
mkdir -p "$HOME/.local/bin"
|
||||||
cp $(realpath "$0") "$HOME"/.local/bin/
|
cp $(realpath "$0") "$HOME"/.local/bin/
|
||||||
mkdir -p "$HOME"/.envs/
|
mkdir -p "$HOME"/.envs/
|
||||||
echo "
|
echo "
|
||||||
@@ -176,6 +179,10 @@ uninstall() {
|
|||||||
echo "Uninstalled PENV"
|
echo "Uninstalled PENV"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pyls(){
|
||||||
|
ls /usr/bin/python3.* /usr/local/bin/python3.* 2> /dev/null | tr " " "\n" | grep "3.*" --color=always
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$#" -lt 1 ]; then
|
if [ "$#" -lt 1 ]; then
|
||||||
title
|
title
|
||||||
usage
|
usage
|
||||||
@@ -186,20 +193,23 @@ cmd=$1
|
|||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
new|mk)
|
new|mk)
|
||||||
create "$2" "$3"
|
create "$(echo "$2" | tr "[:upper:]" "[:lower:]")" "$3"
|
||||||
;;
|
;;
|
||||||
del|rm)
|
del|rm)
|
||||||
delete "$2"
|
delete "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
|
||||||
;;
|
;;
|
||||||
# setdef|sd)
|
# setdef|sd)
|
||||||
# setdef $2
|
# setdef $2
|
||||||
# ;;
|
# ;;
|
||||||
act|ac)
|
act|ac)
|
||||||
activate "$2"
|
activate "$(echo "$2" | tr "[:upper:]" "[:lower:]")"
|
||||||
;;
|
;;
|
||||||
list|ls)
|
list|ls)
|
||||||
list
|
list
|
||||||
;;
|
;;
|
||||||
|
pylist|pyls)
|
||||||
|
pyls
|
||||||
|
;;
|
||||||
help)
|
help)
|
||||||
title
|
title
|
||||||
usage
|
usage
|
||||||
|
|||||||
Reference in New Issue
Block a user