-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthenticator.sh
More file actions
executable file
·39 lines (37 loc) · 1.39 KB
/
Copy pathauthenticator.sh
File metadata and controls
executable file
·39 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# chmod +x authenticator.sh
# source authenv/bin/activate
if [ ! -f authenv/bin/activate ]; then
echo "authenv file does not exist. So Creating"
python3 -m venv authenv
fi
# Check Again after attempting to create the authenv
if [ ! -f authenv/bin/activate ]; then
echo "authenv file does not exist. Failed after attempting to create a auth env"
else
source authenv/bin/activate
echo -e "Inside authenv"
echo -e "Enter any key, if nothing shows after waiting for long time"
PYTHON_SCRIPT="authenticator.py"
output=$(python3 "$PYTHON_SCRIPT" 2>&1)
status=$?
if echo "$output" | grep -q "ModuleNotFoundError"; then
module=$(echo "$output" | grep -oE "No module named ['\"]([^'\"]+)['\"]" | sed -E "s/No module named ['\"]([^'\"]+)['\"]/\1/")
if [ "$module" = "Crypto" ]; then
echo "Installing missing module: $module"
pip3 install pycryptodome
python3 "$PYTHON_SCRIPT"
else
echo "Couldn't understand missing module: $module"
fi
else
if [ $status -eq 0 ]; then
echo "Python script ran successfully. Starting interactive session..."
# Start an interactive python3 session for the script context
python3 "$PYTHON_SCRIPT"
else
echo "Python script exited with errors:"
echo "$output"
fi
fi
fi