mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-10 22:07:10 +01:00
`pre-commit run --all-files` is green. The config only carries hooks whose subject is already clean, so it stays green at every commit -- file-length, ruff/mypy and dependency-freshness are listed as blocked, each on its own cleanup, and the file-REWRITING hooks (trailing-whitespace, end-of-file-fixer) are held back for their own reviewed commit. Turning it on found four real things: 1. A committed private key: ERSMS-project/nginx/ssl/nginx.key. It is a self-signed CN=localhost cert that had already expired (notAfter 2025-06-16), so the risk is nil -- but it is regenerable in one openssl call, so it is replaced by generate-cert.sh rather than excluded from the hook. The script says plainly that removing it from HEAD does NOT unpublish it: history is deliberately not rewritten, which is acceptable only because nothing ever trusted this key. 2. Four files with unresolved merge conflict markers committed, left over from the subtree merges. EARIN/.gitignore and .vscode/extensions.json are resolved as the union of both sides. The two Unity folder .meta files each had two candidate GUIDs; grepping showed neither is referenced anywhere (folder GUIDs rarely are), so either is safe and the HEAD side is kept -- an arbitrary choice, but a checked one rather than a guess. 3. 62 shellcheck findings across 11 scripts, all fixed, no disables added. The interesting pattern was `cd X; cmd &; PID=$!; cd ..`, which trips both SC2164 and SC2103 and cannot use a plain subshell without losing the PID. `( cd X && exec cmd ) &` keeps the directory, the PID and the semantics. EOPSY lab1's submitted solution was verified by RUNNING it afterwards: a->A, B->b, foldera->FOLDERA, FOLDERB->folderb, exactly as before. 4. check-json failing on 11 files, which was the wrong parser rather than a defect -- tsconfig*.json and .vscode/*.json are JSONC, where TypeScript and VS Code both allow comments. Those two path classes are excluded and every other .json is still checked. Excluding them is what surfaced the merge conflict in (2) as the one genuine failure. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0172dj34FDpao6wsix8ZuCzE
98 lines
2.7 KiB
Bash
Executable File
98 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Function to run a script in the background and save its PID
|
|
run_script() {
|
|
python "$1" &
|
|
echo $!
|
|
}
|
|
|
|
# Function to install Kafka
|
|
install_kafka() {
|
|
if ! command -v kafka-server-start &> /dev/null; then
|
|
echo "Kafka is not installed. Installing Kafka..."
|
|
sudo pacman -Syu --noconfirm
|
|
sudo pacman -S --noconfirm kafka
|
|
else
|
|
echo "Kafka is already installed."
|
|
fi
|
|
}
|
|
|
|
# Function to install Flink using yay
|
|
install_flink() {
|
|
if ! command -v flink &> /dev/null; then
|
|
echo "Flink is not installed. Installing Flink..."
|
|
if ! command -v yay &> /dev/null; then
|
|
echo "yay is not installed. Installing yay..."
|
|
sudo pacman -S --noconfirm git
|
|
git clone https://aur.archlinux.org/yay.git
|
|
( cd yay && makepkg -si --noconfirm )
|
|
rm -rf yay
|
|
fi
|
|
yay -S --noconfirm apache-flink
|
|
else
|
|
echo "Flink is already installed."
|
|
fi
|
|
}
|
|
|
|
# Ensure Kafka and Flink are installed
|
|
#install_kafka
|
|
#install_flink
|
|
|
|
# Ensure Kafka and Flink services are running
|
|
echo "Starting Kafka and Flink services..."
|
|
sudo systemctl start kafka
|
|
start-cluster.sh
|
|
|
|
# Give some time for Kafka and Flink to start
|
|
sleep 1
|
|
|
|
# Start the Kafka producer (Transaction Simulator)
|
|
echo "Starting transaction simulator..."
|
|
producer_pid=$(run_script './kafka/generate_and_send.py')
|
|
echo "Started transaction simulator with PID $producer_pid"
|
|
|
|
# Give some time for the producer to start and produce initial transactions
|
|
sleep 1
|
|
|
|
# Start the Kafka consumer for testing
|
|
echo "Starting Kafka consumer for testing..."
|
|
consumer_pid=$(run_script './kafka/kafka_consumer.py')
|
|
echo "Started Kafka consumer for testing with PID $consumer_pid"
|
|
|
|
# Give some time for the consumer to read initial transactions
|
|
sleep 1
|
|
|
|
# Start the Flink job (Anomaly Detector)
|
|
echo "Starting Flink anomaly detector..."
|
|
flink_pid=$(run_script './flink/anomaly_detector.py')
|
|
echo "Started Flink anomaly detector with PID $flink_pid"
|
|
|
|
# Give some time for the Flink job to start processing
|
|
sleep 1
|
|
|
|
# Start the Flask application (Alarm Reader and Visualizer)
|
|
echo "Starting Flask alarm reader..."
|
|
flask_pid=$(run_script './webinterface/webinterface.py')
|
|
echo "Started Flask alarm reader with PID $flask_pid"
|
|
|
|
# Function to handle script termination
|
|
terminate_scripts() {
|
|
echo "Shutting down..."
|
|
kill "$producer_pid"
|
|
kill "$consumer_pid"
|
|
kill "$flink_pid"
|
|
kill "$flask_pid"
|
|
echo "All processes terminated."
|
|
# Optionally stop Kafka and Flink services
|
|
sudo systemctl stop kafka
|
|
sudo systemctl stop flink
|
|
}
|
|
|
|
# Trap SIGINT (Ctrl+C) to terminate all subprocesses
|
|
trap terminate_scripts SIGINT
|
|
|
|
# Keep the main script running to allow all subprocesses to continue executing
|
|
while true; do
|
|
sleep 1
|
|
done
|