diff --git a/api/main.py b/api/main.py index 58fd358..e2c5cca 100644 --- a/api/main.py +++ b/api/main.py @@ -273,8 +273,12 @@ async def change_maintenance(action): # Enable or disable debugging only if the password matches: action = action.lower() - if action == "enable": current_app.is_under_maintenance = True - elif action == "disable": current_app.is_under_maintenance = False + if action == "enable": + current_app.is_under_maintenance = True + os.environ["IS_UNDER_MAINTENANCE"] = "True" + elif action == "disable": + current_app.is_under_maintenance = False + os.environ["IS_UNDER_MAINTENANCE"] = "False" return "ok" diff --git a/freeze_requirements.sh b/freeze_requirements.sh new file mode 100644 index 0000000..8984b3a --- /dev/null +++ b/freeze_requirements.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Just found this better than remembering the freeze command. +# This is beyond silly. +# Okay, bye! +pip3 freeze > requirements.txt \ No newline at end of file diff --git a/from_git.sh b/from_git.sh new file mode 100644 index 0000000..70c21a7 --- /dev/null +++ b/from_git.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Run this on the server. +# Not suitable for collaborative environments: +echo "Pulling from git." +git pull https://wtt.ditscentre.in/ditscentre/api_internal.git +echo "Attempt done. Exiting." \ No newline at end of file diff --git a/kill.sh b/kill.sh new file mode 100644 index 0000000..159505a --- /dev/null +++ b/kill.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Kill all the scripts: +echo "Killing the script." +pkill -9 -f "$(pwd)/api/main.py" + +# Get the name of the current directory, +# and kill the monitors of the above scripts: +echo "Killing the monitors." +PARENT_WD=$(pwd) +CURRENT_DIR_NAME=$(basename "$PARENT_WD") +pgrep -f "$CURRENT_DIR_NAME.*python" | xargs kill -9 + +# All done: +echo "Done!" +exit 0 \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..3688c40 --- /dev/null +++ b/run.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Use this to run the microservice without any docker setup. +source .venv/bin/activate +python3 "$(pwd)/api/main.py" --host "0.0.0.0" --port 5102 --script-id "yZqq2NVo" --debug & +deactivate + +# All done: +echo "Done!" +exit 0 \ No newline at end of file diff --git a/servers.txt b/servers.txt new file mode 100644 index 0000000..007c32e --- /dev/null +++ b/servers.txt @@ -0,0 +1,3 @@ +kbdev.bicree.com +wtt.ditscentre.in +del.ditscentre.in \ No newline at end of file diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..3c14ed1 --- /dev/null +++ b/setup.sh @@ -0,0 +1,20 @@ +# We create a Virtual Environment. +# The format is: +# python -m venv +echo "Making a virtual environment (if needed)" +python3 -m venv .venv + +# Next we activate the newly created Virtual Environment. +echo "Activating the virtual environment." +source .venv/bin/activate + +# Now we install the requirements. +echo "Installing pending requirements." +pip3 install -r requirements.txt + +# Now we deactivate the Virtual Environment. +echo "Deactivation the virtual environment." +deactivate + +# Setup Done. +echo "Attempt done. Exiting." \ No newline at end of file diff --git a/ssh_server.sh b/ssh_server.sh new file mode 100644 index 0000000..1991711 --- /dev/null +++ b/ssh_server.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# A quick command to connect to any of the available servers. + +# Read the servers from the file into an array: +mapfile -t SERVERS < servers.txt + +# Display the numbered list of server options: +echo "Please select a server:" +for i in "${!SERVERS[@]}"; do + echo "$((i + 1)). ${SERVERS[i]}" +done + +# Prompt the user for their selection +read -rp "Select a server by the number ... : " SELECTION + +# Validate the selection +if [[ $SELECTION -gt 0 && $SELECTION -le ${#SERVERS[@]} ]]; then + + # Note down the selection in a variable: + SELECTED_SERVER=${SERVERS[$((SELECTION - 1))]} + + # Ask the user which directory he wants to upload and his username on the server: + read -rp "Your username on the server ..... : " USER + + # Run the command: + ssh -p 19991 "$USER@$SELECTED_SERVER" + + # Exit with success (assuming that the actual data sending went well): + echo "session ended" + exit 0 + +else + + # In case of a wrong server selection, exit with failure. + echo "Invalid selection. Please run the script again." + exit 1 + +fi diff --git a/to_git.sh b/to_git.sh new file mode 100644 index 0000000..eda8f3d --- /dev/null +++ b/to_git.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# NOTES: +# Run this on the development machine. +# NOT to be used in a collaborative environment: + +# Accept a comment from the terminal: +echo "Comment: " +read -r COMMENT + +# Add all the modified files to the intended commit: +git add . +echo "File added." + +# Make the commit: +git commit -m "$COMMENT" +echo "Commit done." + +# Push th commit to git: +git push -u https://wtt.ditscentre.in/ditscentre/api_internal.git master +echo "Attempt done. Exiting." \ No newline at end of file diff --git a/utils_v2/api/__pycache__/async_quart.cpython-310.pyc b/utils_v2/api/__pycache__/async_quart.cpython-310.pyc index b773a45..b8bf0a8 100644 Binary files a/utils_v2/api/__pycache__/async_quart.cpython-310.pyc and b/utils_v2/api/__pycache__/async_quart.cpython-310.pyc differ diff --git a/utils_v2/api/async_quart.py b/utils_v2/api/async_quart.py index ffcd260..8749a76 100644 --- a/utils_v2/api/async_quart.py +++ b/utils_v2/api/async_quart.py @@ -55,10 +55,7 @@ import datetime # System-level activities: import io -<<<<<<< HEAD -======= import os ->>>>>>> 0450b2a445509ef536ccf8598ab31a0e4ba09f18 # For Pydantic data-behaviour_models: import pydantic