(20241010) With some shell scripts.
This commit is contained in:
+6
-2
@@ -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"
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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."
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
kbdev.bicree.com
|
||||
wtt.ditscentre.in
|
||||
del.ditscentre.in
|
||||
@@ -0,0 +1,20 @@
|
||||
# We create a Virtual Environment.
|
||||
# The format is:
|
||||
# python<version> -m venv <virtual_env_name>
|
||||
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."
|
||||
@@ -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
|
||||
@@ -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."
|
||||
Binary file not shown.
@@ -55,10 +55,7 @@ import datetime
|
||||
|
||||
# System-level activities:
|
||||
import io
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
import os
|
||||
>>>>>>> 0450b2a445509ef536ccf8598ab31a0e4ba09f18
|
||||
|
||||
# For Pydantic data-behaviour_models:
|
||||
import pydantic
|
||||
|
||||
Reference in New Issue
Block a user