From 2d8bdd365886104a1e6d0c624ae672d1a50778cf Mon Sep 17 00:00:00 2001
From: Thiflict <121az348@gmail.com>
Date: Tue, 14 Apr 2026 23:06:10 +0500
Subject: [PATCH 01/11] =?UTF-8?q?#2:=20=D0=A1=D0=BA=D1=80=D0=B8=D0=BF?=
=?UTF-8?q?=D1=82=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B7=D0=B0?=
=?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8F=D0=B5=D1=82=20=D0=BD=D0=B5=D0=BE=D0=B1?=
=?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B8=D0=BC=D1=8B=D0=B5=20=D1=81=D1=82=D1=80?=
=?UTF-8?q?=D0=BE=D0=BA=D0=B8=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8?=
=?UTF-8?q?=D0=B3=D0=B5=20clamd.conf.=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?=
=?UTF-8?q?=D0=B8=D0=BB=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=20samba=20=D0=B4?=
=?UTF-8?q?=D0=BB=D1=8F=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8?=
=?UTF-8?q?.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
install_script.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
create mode 100644 install_script.sh
diff --git a/install_script.sh b/install_script.sh
new file mode 100644
index 0000000..a380366
--- /dev/null
+++ b/install_script.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+# Description: Скрипт для корректной загрузки и установки программы RPIVirusScanner
+# Author: Шафеев "Thiflict" Марат
+# Date: 2026-04-14
+
+# Так как скрипт не тестировался должным образом, необходимо запросить у пользователя о его намерениях продолжать выполнение скрипта.
+read -p "ВНИМАНИЕ!!! Данный скрипт установки не тестировался должным образом! Это значит, что скрипт может поломать некоторые конфиги ClamAV КАК МИНИМУМ! Для продолжения введите: 'i understand all the risks and want to continue'. Это будет означать, что вы понимаете риски и хотите продолжить выполнение программы! " answer
+answer=${answer,,}
+
+if [[ "$answer" != "i understand all the risks and want to continue" ]]; then
+ echo "Неправильно набрана фраза для продолжена. Отменяю..."
+ exit 0
+fi
+echo "Выполняю..."
+
+# Обновление списков пакетов и зарузка зависимостей
+apt update;
+apt install openjdk-21-jdk gpiod libgpiod-dev clamav clamav-daemon ntfs-3g usbmount samba -y; # Загрузка нужных пактов
+
+# Настройка либы для взаимодействия с GPIO
+echo "Подготовка библиотек взаимодействия с GPIO..."
+sudo usermod -a -G gpio,spi,i2c $USER;
+newgrp gpio;
+
+# Настройка ClamAV
+echo "Настройка ClamAV"
+{
+ echo "PrivateMirror https://clamav-mirror.ru";
+ echo "PrivateMirror https://mirror.truenetwork.ru/clamav/";
+ echo "PrivateMirror http://mirror.truenetwork.ru/clamav/";
+ echo "ScriptedUpdates no";
+} >> /etc/clamav/freshclam.conf;
+rm /var/lib/clamav/freshclam.dat;
+freshclam -vvv;
+
+CONFIG_FILE="/etc/clamav/clamd.conf"; # Путь к файлу конфига
+NEW_VALUE_MT="10"; # Новое значение MaxThreads
+NEW_VALUE_MF="10M"; # Новое значение MaxFileSize
+NEW_VALUE_MS="30M"; # Новое значение MaxScanSize
+
+cp "$CONFIG_FILE" "$CONFIG_FILE.bak"; # Создание бекапа конфига
+sed -i -E "
+ s/^(MaxThreads[[:space:]]+).*/\1$NEW_VALUE_MT/
+ s/^(MaxFileSize[[:space:]]+).*/\1$NEW_VALUE_MF/
+ s/^(MaxScanSize[[:space:]]+).*/\1$NEW_VALUE_MS/
+" "$CONFIG_FILE"; # Изменение конфига
+
+# Загрузка временных файлов
+echo "Загрузка необходиых временных файлов..."
+rm -rf /tmp/rpivs;
+mkdir /tmp/rpivs;
+wget https://static1.thiflict.ru/raspberrypi_virus_scanner/rpivirusscanner_v1.0.jar -o /tmp/rpivs/rpivirusscanner.jar;
+wget https://static1.thiflict.ru/raspberrypi_virus_scanner/v1.0/rpi_virus_scanner_service -o /tmp/rpivs/rpi_virus_scanner.service;
+
+# Установка программы
+echo "Установка программы..."
+rm -rf /opt/thiflict-dev/rpi-virus-scanner/
+mkdir -p /opt/thiflict-dev/rpi-virus-scanner/
+mv /tmp/rpivs/rpivirusscanner.jar /opt/thiflict-dev/rpi-virus-scanner/;
+
+# Создание демона
+echo "Создание демона RPIVirusScanner..."
+mv /tmp/rpivs/rpi_virus_scanner.service /etc/systemd/system/;
+systemctl daemon-reload;
+systemctl enable rpi_virus_scanner.service;
+
+# Авторство:
+echo "RaspberryPi успешно установлен! Рекомендуется перезагрузить устройство.";
+echo " ";
+echo "==== Об авторе: ====";
+echo "Репозиторий проекта: https://git.ds1.thiflict.ru/Shafeev-CourseWork/Practice-Part";
+echo "Телеграм-канал: https://t.me/Thiflict_tg";
+echo "YouTube канал: https://youtube.com/@Thiflict";
\ No newline at end of file
--
2.49.1
From a655f026b4e583bf736355d6b0f161f47c620235 Mon Sep 17 00:00:00 2001
From: thiflict <121az348@gmail.com>
Date: Wed, 15 Apr 2026 08:01:05 +0500
Subject: [PATCH 02/11] =?UTF-8?q?#2:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?=
=?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D1=83=D0=BB=D1=8C=D1=82?=
=?UTF-8?q?=D0=B8=D0=BF=D0=BE=D1=82=D0=BE=D1=87=D0=BD=D0=BE=D1=81=D1=82?=
=?UTF-8?q?=D0=B8=20=D1=83=20=D0=B0=D0=BD=D1=82=D0=B8=D0=B2=D0=B8=D1=80?=
=?UTF-8?q?=D1=83=D1=81=D0=B0.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/gradle.xml | 1 +
src/main/kotlin/Main.kt | 8 +++-----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index ce1c62c..3a0665a 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -12,5 +12,6 @@
+
\ No newline at end of file
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index ba880e5..b7eb689 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -30,7 +30,7 @@ enum class SystemState {
IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT
}
-class USBVirusScanner {
+class USBVirusScanner {
private var currentState = SystemState.INIT
private var scanJob: Job? = null
@@ -345,12 +345,10 @@ class USBVirusScanner {
// Запускаем ClamAV
val processBuilder = ProcessBuilder(
- "clamscan",
- "-r",
+ "clamdscan",
+ "--multiscan",
"--stdout",
"--infected",
- "--max-filesize=1M",
- "--max-scansize=10M",
path
)
--
2.49.1
From e622c95666ed1a1bca5f38078b5b19bfe3c1f911 Mon Sep 17 00:00:00 2001
From: thiflict <121az348@gmail.com>
Date: Wed, 15 Apr 2026 10:35:59 +0500
Subject: [PATCH 03/11] =?UTF-8?q?#2:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?=
=?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=82=D1=81=D0=BB=D0=B5=D0=B6?=
=?UTF-8?q?=D0=B8=D0=B2=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BB=D0=B8=D0=BD?=
=?UTF-8?q?=D1=8B=20=D0=BD=D0=B0=D0=B6=D0=B0=D1=82=D0=B8=D0=B9=20=D0=BA?=
=?UTF-8?q?=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8.=20=D0=AD=D1=82=D0=BE=20=D0=BD?=
=?UTF-8?q?=D1=83=D0=B6=D0=BD=D0=BE=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82?=
=?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B0?=
=?UTF-8?q?=D0=BC=D0=B1=D1=8B=20=D0=B8=20=D1=80=D0=B0=D0=B7=D0=BC=D0=BE?=
=?UTF-8?q?=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?=
=?UTF-8?q?=D1=84=D0=BB=D0=B5=D1=88=D0=BA=D0=B8.=20(=D1=81=D0=BF=D1=83?=
=?UTF-8?q?=D1=81=D1=82=D1=8F=20=D0=B4=D0=B2=D0=B0=20=D1=87=D0=B0=D1=81?=
=?UTF-8?q?=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B9?=
=?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/kotlin/ButtonListener.kt | 109 ++++++++++++++++++++++++------
src/main/kotlin/Main.kt | 21 +++++-
2 files changed, 106 insertions(+), 24 deletions(-)
diff --git a/src/main/kotlin/ButtonListener.kt b/src/main/kotlin/ButtonListener.kt
index 4aa9077..fd38e1e 100644
--- a/src/main/kotlin/ButtonListener.kt
+++ b/src/main/kotlin/ButtonListener.kt
@@ -7,11 +7,11 @@ import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.concurrent.atomic.AtomicBoolean
-// Событие клика по кнопке
class ButtonClickEvent
+class ButtonLongPressEvent
-// Слушатель событий клика
typealias ButtonClickListener = (ButtonClickEvent) -> Unit
+typealias ButtonLongPressListener = (ButtonLongPressEvent) -> Unit
class ButtonListener(
private var process: Process? = null,
@@ -19,63 +19,128 @@ class ButtonListener(
private var isListening: AtomicBoolean = AtomicBoolean(false),
private var listenerJob: Job? = null
) {
-
private val clickListeners = mutableListOf()
+ private val longPressListeners = mutableListOf()
+
+ var shortPressThresholdMs: Long = 100
+ var longPressThresholdMs: Long = 1000
+
+ private var pressStartTime: Long = 0
fun addClickListener(listener: ButtonClickListener) {
clickListeners.add(listener)
}
+ fun removeClickListener(listener: ButtonClickListener) {
+ clickListeners.remove(listener)
+ }
+
+ fun addLongPressListener(listener: ButtonLongPressListener) {
+ longPressListeners.add(listener)
+ }
+
+ fun removeLongPressListener(listener: ButtonLongPressListener) {
+ longPressListeners.remove(listener)
+ }
+
private fun notifyClick() {
+ println("=== [CLICK] Короткое нажатие ===")
val event = ButtonClickEvent()
clickListeners.forEach { it.invoke(event) }
}
+ private fun notifyLongPress() {
+ println("=== [LONG] Длинное нажатие ===")
+ val event = ButtonLongPressEvent()
+ longPressListeners.forEach { it.invoke(event) }
+ }
+
fun startListening(onStateChange: ((Boolean) -> Unit)? = null): Boolean {
if (isListening.get()) {
return currentButtonState.get()
}
+ startListeningInternal(onStateChange)
+ return currentButtonState.get()
+ }
+
+ private fun startListeningInternal(onStateChange: ((Boolean) -> Unit)? = null) {
try {
val cmd = listOf("gpiomon", "--chip=0", "$BUTTON")
val processBuilder = ProcessBuilder(cmd)
.redirectErrorStream(true)
- // Сохраняем процесс в поле
process = processBuilder.start()
isListening.set(true)
listenerJob = CoroutineScope(Dispatchers.IO).launch {
- // Используем process, который теперь не null
val reader = BufferedReader(InputStreamReader(process!!.inputStream))
var line: String?
- while (reader.readLine().also { line = it } != null) {
- println(if (isDebug) "$line" else "")
- when {
- line?.contains("rising") == true -> {
- currentButtonState.set(true)
- onStateChange?.invoke(true)
- println(if (isDebug) "Кнопка нажата" else "")
- // Генерируем событие клика при нажатии
- notifyClick()
- }
- line?.contains("falling") == true -> {
- currentButtonState.set(false)
- onStateChange?.invoke(false)
- println(if (isDebug) "Кнопка разжата" else "")
- // Убрана проверка на разжатие для генерации события
+ try {
+ while (reader.readLine().also { line = it } != null) {
+ println(if (isDebug) "$line" else "")
+ when {
+ line?.contains("rising") == true -> {
+ currentButtonState.set(true)
+ onStateChange?.invoke(true)
+ pressStartTime = System.currentTimeMillis()
+ println(if (isDebug) "Кнопка нажата, время: $pressStartTime" else "")
+ }
+ line?.contains("falling") == true -> {
+ val pressDuration = System.currentTimeMillis() - pressStartTime
+ currentButtonState.set(false)
+ onStateChange?.invoke(false)
+ println(if (isDebug) "Кнопка отпущена, длительность: ${pressDuration}ms" else "")
+
+ // Определяем тип нажатия по длительности
+ when {
+ pressDuration >= longPressThresholdMs -> {
+ println(if (isDebug) "Длинное нажатие (${pressDuration}ms)" else "")
+ notifyLongPress()
+ }
+ pressDuration >= shortPressThresholdMs -> {
+ println(if (isDebug) "Короткое нажатие (${pressDuration}ms)" else "")
+ notifyClick()
+ }
+ else -> {
+ println(if (isDebug) "Слишком короткое нажатие (${pressDuration}ms) - игнорируем" else "")
+ }
+ }
+ }
}
}
+ } catch (e: Exception) {
+ println("Ошибка чтения процесса: ${e.message}")
}
+
val exitCode = process!!.waitFor()
- println(if (isDebug) "Процесс завершён ($exitCode)" else "")
+ println("Процесс завершён ($exitCode)")
isListening.set(false)
+
+ // Автоматически перезапускаем прослушивание, если оно должно быть активно
+ if (isListening.get()) {
+ println("Перезапуск прослушивания...")
+ delay(100)
+ startListeningInternal(onStateChange)
+ }
}
} catch (e: Exception) {
e.printStackTrace()
isListening.set(false)
}
- return currentButtonState.get()
+ }
+
+ fun stopListening() {
+ isListening.set(false)
+ listenerJob?.cancel()
+ process?.destroy()
+ process = null
+ }
+
+ fun restartListening(onStateChange: ((Boolean) -> Unit)? = null) {
+ stopListening()
+ Thread.sleep(200)
+ startListening(onStateChange)
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index b7eb689..3a720f5 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -27,7 +27,7 @@ object DebugMode {
// Состояния системы
enum class SystemState {
- IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT
+ IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT, SAMBA
}
class USBVirusScanner {
@@ -159,6 +159,11 @@ class USBVirusScanner {
yellowLed.setValue(0)
blinkLed(redLed, 500)
}
+ SystemState.SAMBA -> {
+ blinkLed(greenLed, 1000)
+ blinkLed(yellowLed, 1000)
+ redLed.setValue(0)
+ }
}
}
}
@@ -316,7 +321,7 @@ class USBVirusScanner {
try {
// Проверяем установлен ли ClamAV
- val checkProcess = ProcessBuilder("which", "clamscan").start()
+ val checkProcess = ProcessBuilder("which", "clamdscan").start()
val checkExitCode = checkProcess.waitFor()
if (checkExitCode != 0) {
@@ -538,9 +543,20 @@ fun main(args: Array) {
scanner.initialize()
val buttonListener = ButtonListener()
+
+ buttonListener.shortPressThresholdMs = 100
+ buttonListener.longPressThresholdMs = 1000
+
buttonListener.addClickListener { event ->
scanner.startScan()
}
+
+ buttonListener.addLongPressListener { event ->
+ println(if (isDebug) "ДЛИННОЕ НАЖАТИЕ МЯУ" else "")
+ println("TODO(\"Добавить отключение samba и размонтирование флешки\")")
+
+ }
+
buttonListener.startListening()
println(if (isDebug) """
@@ -564,4 +580,5 @@ fun main(args: Array) {
scanner.shutdown()
exitProcess(1)
}
+
}
\ No newline at end of file
--
2.49.1
From 17e19250340cc6d507c34e8c9c9ea402ad9be4b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=BE=D1=88=D0=BA=D0=BE=D1=84=D0=BB=D0=B8=D0=BA?=
=?UTF-8?q?=D1=82?= <121az348@gmail.com>
Date: Wed, 15 Apr 2026 05:41:21 +0000
Subject: [PATCH 04/11] revert e622c95666ed1a1bca5f38078b5b19bfe3c1f911
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
revert #2: Добавлено отслеживение длины нажатий кнопки. Это нужно для отключения самбы и размонтирования флешки. (спустя два часа страданий)
---
src/main/kotlin/ButtonListener.kt | 109 ++++++------------------------
src/main/kotlin/Main.kt | 21 +-----
2 files changed, 24 insertions(+), 106 deletions(-)
diff --git a/src/main/kotlin/ButtonListener.kt b/src/main/kotlin/ButtonListener.kt
index fd38e1e..4aa9077 100644
--- a/src/main/kotlin/ButtonListener.kt
+++ b/src/main/kotlin/ButtonListener.kt
@@ -7,11 +7,11 @@ import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.concurrent.atomic.AtomicBoolean
+// Событие клика по кнопке
class ButtonClickEvent
-class ButtonLongPressEvent
+// Слушатель событий клика
typealias ButtonClickListener = (ButtonClickEvent) -> Unit
-typealias ButtonLongPressListener = (ButtonLongPressEvent) -> Unit
class ButtonListener(
private var process: Process? = null,
@@ -19,128 +19,63 @@ class ButtonListener(
private var isListening: AtomicBoolean = AtomicBoolean(false),
private var listenerJob: Job? = null
) {
+
private val clickListeners = mutableListOf()
- private val longPressListeners = mutableListOf()
-
- var shortPressThresholdMs: Long = 100
- var longPressThresholdMs: Long = 1000
-
- private var pressStartTime: Long = 0
fun addClickListener(listener: ButtonClickListener) {
clickListeners.add(listener)
}
- fun removeClickListener(listener: ButtonClickListener) {
- clickListeners.remove(listener)
- }
-
- fun addLongPressListener(listener: ButtonLongPressListener) {
- longPressListeners.add(listener)
- }
-
- fun removeLongPressListener(listener: ButtonLongPressListener) {
- longPressListeners.remove(listener)
- }
-
private fun notifyClick() {
- println("=== [CLICK] Короткое нажатие ===")
val event = ButtonClickEvent()
clickListeners.forEach { it.invoke(event) }
}
- private fun notifyLongPress() {
- println("=== [LONG] Длинное нажатие ===")
- val event = ButtonLongPressEvent()
- longPressListeners.forEach { it.invoke(event) }
- }
-
fun startListening(onStateChange: ((Boolean) -> Unit)? = null): Boolean {
if (isListening.get()) {
return currentButtonState.get()
}
- startListeningInternal(onStateChange)
- return currentButtonState.get()
- }
-
- private fun startListeningInternal(onStateChange: ((Boolean) -> Unit)? = null) {
try {
val cmd = listOf("gpiomon", "--chip=0", "$BUTTON")
val processBuilder = ProcessBuilder(cmd)
.redirectErrorStream(true)
+ // Сохраняем процесс в поле
process = processBuilder.start()
isListening.set(true)
listenerJob = CoroutineScope(Dispatchers.IO).launch {
+ // Используем process, который теперь не null
val reader = BufferedReader(InputStreamReader(process!!.inputStream))
var line: String?
- try {
- while (reader.readLine().also { line = it } != null) {
- println(if (isDebug) "$line" else "")
- when {
- line?.contains("rising") == true -> {
- currentButtonState.set(true)
- onStateChange?.invoke(true)
- pressStartTime = System.currentTimeMillis()
- println(if (isDebug) "Кнопка нажата, время: $pressStartTime" else "")
- }
- line?.contains("falling") == true -> {
- val pressDuration = System.currentTimeMillis() - pressStartTime
- currentButtonState.set(false)
- onStateChange?.invoke(false)
- println(if (isDebug) "Кнопка отпущена, длительность: ${pressDuration}ms" else "")
-
- // Определяем тип нажатия по длительности
- when {
- pressDuration >= longPressThresholdMs -> {
- println(if (isDebug) "Длинное нажатие (${pressDuration}ms)" else "")
- notifyLongPress()
- }
- pressDuration >= shortPressThresholdMs -> {
- println(if (isDebug) "Короткое нажатие (${pressDuration}ms)" else "")
- notifyClick()
- }
- else -> {
- println(if (isDebug) "Слишком короткое нажатие (${pressDuration}ms) - игнорируем" else "")
- }
- }
- }
+ while (reader.readLine().also { line = it } != null) {
+ println(if (isDebug) "$line" else "")
+ when {
+ line?.contains("rising") == true -> {
+ currentButtonState.set(true)
+ onStateChange?.invoke(true)
+ println(if (isDebug) "Кнопка нажата" else "")
+ // Генерируем событие клика при нажатии
+ notifyClick()
+ }
+ line?.contains("falling") == true -> {
+ currentButtonState.set(false)
+ onStateChange?.invoke(false)
+ println(if (isDebug) "Кнопка разжата" else "")
+ // Убрана проверка на разжатие для генерации события
}
}
- } catch (e: Exception) {
- println("Ошибка чтения процесса: ${e.message}")
}
-
val exitCode = process!!.waitFor()
- println("Процесс завершён ($exitCode)")
+ println(if (isDebug) "Процесс завершён ($exitCode)" else "")
isListening.set(false)
-
- // Автоматически перезапускаем прослушивание, если оно должно быть активно
- if (isListening.get()) {
- println("Перезапуск прослушивания...")
- delay(100)
- startListeningInternal(onStateChange)
- }
}
} catch (e: Exception) {
e.printStackTrace()
isListening.set(false)
}
- }
-
- fun stopListening() {
- isListening.set(false)
- listenerJob?.cancel()
- process?.destroy()
- process = null
- }
-
- fun restartListening(onStateChange: ((Boolean) -> Unit)? = null) {
- stopListening()
- Thread.sleep(200)
- startListening(onStateChange)
+ return currentButtonState.get()
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 3a720f5..b7eb689 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -27,7 +27,7 @@ object DebugMode {
// Состояния системы
enum class SystemState {
- IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT, SAMBA
+ IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT
}
class USBVirusScanner {
@@ -159,11 +159,6 @@ class USBVirusScanner {
yellowLed.setValue(0)
blinkLed(redLed, 500)
}
- SystemState.SAMBA -> {
- blinkLed(greenLed, 1000)
- blinkLed(yellowLed, 1000)
- redLed.setValue(0)
- }
}
}
}
@@ -321,7 +316,7 @@ class USBVirusScanner {
try {
// Проверяем установлен ли ClamAV
- val checkProcess = ProcessBuilder("which", "clamdscan").start()
+ val checkProcess = ProcessBuilder("which", "clamscan").start()
val checkExitCode = checkProcess.waitFor()
if (checkExitCode != 0) {
@@ -543,20 +538,9 @@ fun main(args: Array) {
scanner.initialize()
val buttonListener = ButtonListener()
-
- buttonListener.shortPressThresholdMs = 100
- buttonListener.longPressThresholdMs = 1000
-
buttonListener.addClickListener { event ->
scanner.startScan()
}
-
- buttonListener.addLongPressListener { event ->
- println(if (isDebug) "ДЛИННОЕ НАЖАТИЕ МЯУ" else "")
- println("TODO(\"Добавить отключение samba и размонтирование флешки\")")
-
- }
-
buttonListener.startListening()
println(if (isDebug) """
@@ -580,5 +564,4 @@ fun main(args: Array) {
scanner.shutdown()
exitProcess(1)
}
-
}
\ No newline at end of file
--
2.49.1
From 34ddd60a0a6972c36adb0c1e6a724bfa9a3ea4e1 Mon Sep 17 00:00:00 2001
From: thiflict <121az348@gmail.com>
Date: Wed, 15 Apr 2026 10:45:30 +0500
Subject: [PATCH 05/11] =?UTF-8?q?#1:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?=
=?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=82=D1=81=D0=BB=D0=B5=D0=B6?=
=?UTF-8?q?=D0=B8=D0=B2=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BB=D0=B8=D0=BD?=
=?UTF-8?q?=D1=8B=20=D0=BD=D0=B0=D0=B6=D0=B0=D1=82=D0=B8=D0=B9=20=D0=BA?=
=?UTF-8?q?=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8.=20=D0=AD=D1=82=D0=BE=20=D0=BD?=
=?UTF-8?q?=D1=83=D0=B6=D0=BD=D0=BE=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82?=
=?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B0?=
=?UTF-8?q?=D0=BC=D0=B1=D1=8B=20=D0=B8=20=D1=80=D0=B0=D0=B7=D0=BC=D0=BE?=
=?UTF-8?q?=D0=BD=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?=
=?UTF-8?q?=D1=84=D0=BB=D0=B5=D1=88=D0=BA=D0=B8.=20(=D1=81=D0=BF=D1=83?=
=?UTF-8?q?=D1=81=D1=82=D1=8F=20=D0=B4=D0=B2=D0=B0=20=D1=87=D0=B0=D1=81?=
=?UTF-8?q?=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B9?=
=?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/kotlin/ButtonListener.kt | 109 ++++++++++++++++++++++++------
src/main/kotlin/Main.kt | 6 ++
2 files changed, 93 insertions(+), 22 deletions(-)
diff --git a/src/main/kotlin/ButtonListener.kt b/src/main/kotlin/ButtonListener.kt
index 4aa9077..fd38e1e 100644
--- a/src/main/kotlin/ButtonListener.kt
+++ b/src/main/kotlin/ButtonListener.kt
@@ -7,11 +7,11 @@ import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.concurrent.atomic.AtomicBoolean
-// Событие клика по кнопке
class ButtonClickEvent
+class ButtonLongPressEvent
-// Слушатель событий клика
typealias ButtonClickListener = (ButtonClickEvent) -> Unit
+typealias ButtonLongPressListener = (ButtonLongPressEvent) -> Unit
class ButtonListener(
private var process: Process? = null,
@@ -19,63 +19,128 @@ class ButtonListener(
private var isListening: AtomicBoolean = AtomicBoolean(false),
private var listenerJob: Job? = null
) {
-
private val clickListeners = mutableListOf()
+ private val longPressListeners = mutableListOf()
+
+ var shortPressThresholdMs: Long = 100
+ var longPressThresholdMs: Long = 1000
+
+ private var pressStartTime: Long = 0
fun addClickListener(listener: ButtonClickListener) {
clickListeners.add(listener)
}
+ fun removeClickListener(listener: ButtonClickListener) {
+ clickListeners.remove(listener)
+ }
+
+ fun addLongPressListener(listener: ButtonLongPressListener) {
+ longPressListeners.add(listener)
+ }
+
+ fun removeLongPressListener(listener: ButtonLongPressListener) {
+ longPressListeners.remove(listener)
+ }
+
private fun notifyClick() {
+ println("=== [CLICK] Короткое нажатие ===")
val event = ButtonClickEvent()
clickListeners.forEach { it.invoke(event) }
}
+ private fun notifyLongPress() {
+ println("=== [LONG] Длинное нажатие ===")
+ val event = ButtonLongPressEvent()
+ longPressListeners.forEach { it.invoke(event) }
+ }
+
fun startListening(onStateChange: ((Boolean) -> Unit)? = null): Boolean {
if (isListening.get()) {
return currentButtonState.get()
}
+ startListeningInternal(onStateChange)
+ return currentButtonState.get()
+ }
+
+ private fun startListeningInternal(onStateChange: ((Boolean) -> Unit)? = null) {
try {
val cmd = listOf("gpiomon", "--chip=0", "$BUTTON")
val processBuilder = ProcessBuilder(cmd)
.redirectErrorStream(true)
- // Сохраняем процесс в поле
process = processBuilder.start()
isListening.set(true)
listenerJob = CoroutineScope(Dispatchers.IO).launch {
- // Используем process, который теперь не null
val reader = BufferedReader(InputStreamReader(process!!.inputStream))
var line: String?
- while (reader.readLine().also { line = it } != null) {
- println(if (isDebug) "$line" else "")
- when {
- line?.contains("rising") == true -> {
- currentButtonState.set(true)
- onStateChange?.invoke(true)
- println(if (isDebug) "Кнопка нажата" else "")
- // Генерируем событие клика при нажатии
- notifyClick()
- }
- line?.contains("falling") == true -> {
- currentButtonState.set(false)
- onStateChange?.invoke(false)
- println(if (isDebug) "Кнопка разжата" else "")
- // Убрана проверка на разжатие для генерации события
+ try {
+ while (reader.readLine().also { line = it } != null) {
+ println(if (isDebug) "$line" else "")
+ when {
+ line?.contains("rising") == true -> {
+ currentButtonState.set(true)
+ onStateChange?.invoke(true)
+ pressStartTime = System.currentTimeMillis()
+ println(if (isDebug) "Кнопка нажата, время: $pressStartTime" else "")
+ }
+ line?.contains("falling") == true -> {
+ val pressDuration = System.currentTimeMillis() - pressStartTime
+ currentButtonState.set(false)
+ onStateChange?.invoke(false)
+ println(if (isDebug) "Кнопка отпущена, длительность: ${pressDuration}ms" else "")
+
+ // Определяем тип нажатия по длительности
+ when {
+ pressDuration >= longPressThresholdMs -> {
+ println(if (isDebug) "Длинное нажатие (${pressDuration}ms)" else "")
+ notifyLongPress()
+ }
+ pressDuration >= shortPressThresholdMs -> {
+ println(if (isDebug) "Короткое нажатие (${pressDuration}ms)" else "")
+ notifyClick()
+ }
+ else -> {
+ println(if (isDebug) "Слишком короткое нажатие (${pressDuration}ms) - игнорируем" else "")
+ }
+ }
+ }
}
}
+ } catch (e: Exception) {
+ println("Ошибка чтения процесса: ${e.message}")
}
+
val exitCode = process!!.waitFor()
- println(if (isDebug) "Процесс завершён ($exitCode)" else "")
+ println("Процесс завершён ($exitCode)")
isListening.set(false)
+
+ // Автоматически перезапускаем прослушивание, если оно должно быть активно
+ if (isListening.get()) {
+ println("Перезапуск прослушивания...")
+ delay(100)
+ startListeningInternal(onStateChange)
+ }
}
} catch (e: Exception) {
e.printStackTrace()
isListening.set(false)
}
- return currentButtonState.get()
+ }
+
+ fun stopListening() {
+ isListening.set(false)
+ listenerJob?.cancel()
+ process?.destroy()
+ process = null
+ }
+
+ fun restartListening(onStateChange: ((Boolean) -> Unit)? = null) {
+ stopListening()
+ Thread.sleep(200)
+ startListening(onStateChange)
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index b7eb689..9efccab 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -538,9 +538,15 @@ fun main(args: Array) {
scanner.initialize()
val buttonListener = ButtonListener()
+
buttonListener.addClickListener { event ->
scanner.startScan()
}
+
+ buttonListener.addLongPressListener { event ->
+ println("TODO: Сделать отключение samba и отмонтирование накопителя.")
+ }
+
buttonListener.startListening()
println(if (isDebug) """
--
2.49.1
From 2734c06fb1e4acce43ca4a345bcf4e6be4265a5f Mon Sep 17 00:00:00 2001
From: thiflict <121az348@gmail.com>
Date: Wed, 15 Apr 2026 15:34:20 +0500
Subject: [PATCH 06/11] =?UTF-8?q?#1:=20=D0=A7=D1=83=D1=82=D1=8C-=D1=87?=
=?UTF-8?q?=D1=83=D1=82=D1=8C=20=D0=BF=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?=
=?UTF-8?q?=20samba.=20=D0=9E=D1=81=D1=82=D0=B0=D0=BB=D0=BE=D1=81=D1=8C=20?=
=?UTF-8?q?=D1=81=D0=BE=D0=B2=D1=81=D0=B5=D0=BC=20=D0=BD=D0=B5=D0=BC=D0=BD?=
=?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=BE=D0=BF=D0=B8=D0=BB=D0=B8=D1=82?=
=?UTF-8?q?=D1=8C.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/kotlin/Main.kt | 114 +++++++++++++++++++++++++++++++++-------
1 file changed, 96 insertions(+), 18 deletions(-)
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 9efccab..a38f3bd 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -8,6 +8,7 @@ import java.io.InputStreamReader
import kotlin.system.exitProcess
import java.util.*
import java.util.concurrent.*
+import kotlin.time.Duration.Companion.milliseconds
// Конфигурация GPIO (BCM номера)
object PinConfig {
@@ -27,10 +28,10 @@ object DebugMode {
// Состояния системы
enum class SystemState {
- IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT
+ IDLE, SCANNING, CLEAN, INFECTED, ERROR, INIT, SAMBA
}
-class USBVirusScanner {
+class USBVirusScanner {
private var currentState = SystemState.INIT
private var scanJob: Job? = null
@@ -120,45 +121,56 @@ class USBVirusScanner {
greenLed.setValue(1)
yellowLed.setValue(1)
redLed.setValue(1)
- delay(200)
+ delay(200.milliseconds)
greenLed.setValue(0)
yellowLed.setValue(0)
redLed.setValue(0)
- delay(200)
+ delay(200.milliseconds)
}
+
SystemState.IDLE -> {
// Зелёный медленно мигает
blinkLed(greenLed, 1000)
yellowLed.setValue(0)
redLed.setValue(0)
}
+
SystemState.SCANNING -> {
// Жёлтый быстро мигает
greenLed.setValue(0)
blinkLed(yellowLed, 150)
redLed.setValue(0)
}
+
SystemState.CLEAN -> {
// Зелёный горит
greenLed.setValue(1)
yellowLed.setValue(0)
redLed.setValue(0)
- delay(100)
+ delay(100.milliseconds)
}
+
SystemState.INFECTED -> {
// Красный горит
greenLed.setValue(0)
yellowLed.setValue(0)
redLed.setValue(1)
- delay(100)
+ delay(100.milliseconds)
}
+
SystemState.ERROR -> {
// Красный мигает
greenLed.setValue(0)
yellowLed.setValue(0)
blinkLed(redLed, 500)
}
+
+ SystemState.SAMBA -> {
+ blinkLed(greenLed, 1000)
+ blinkLed(yellowLed, 1000)
+ redLed.setValue(0)
+ }
}
}
}
@@ -166,9 +178,9 @@ class USBVirusScanner {
private suspend fun blinkLed(led: GPIOController, intervalMs: Long) {
led.setValue(1)
- delay(intervalMs / 2)
+ delay((intervalMs / 2).milliseconds)
led.setValue(0)
- delay(intervalMs / 2)
+ delay((intervalMs / 2).milliseconds)
}
fun startScan() {
@@ -188,7 +200,7 @@ class USBVirusScanner {
if (usbDevices.isEmpty()) {
println(if (isDebug) "Устройства не найдены" else "")
currentState = SystemState.ERROR
- delay(5000)
+ delay(5000.milliseconds)
currentState = SystemState.IDLE
return@launch
}
@@ -241,14 +253,22 @@ class USBVirusScanner {
println(if (isDebug) message else "")
// Держим состояние 5 секунд
- delay(5000)
+ delay(10000.milliseconds)
+
+ if (!hasVirus) {
+ currentState = SystemState.SAMBA
+ sambaStartSharing()
+
+ while (isUsbSharing()) {}
+ }
+
currentState = SystemState.IDLE
} catch (e: Exception) {
println(if (isDebug) "❌ Критическая ошибка: ${e.message}" else "")
e.printStackTrace()
currentState = SystemState.ERROR
- delay(5000)
+ delay(10000.milliseconds)
currentState = SystemState.IDLE
}
@@ -295,7 +315,8 @@ class USBVirusScanner {
if ((mountPoint.startsWith("/media")) &&
File(mountPoint).exists() &&
- devices.none { it.mountPoint == mountPoint }) {
+ devices.none { it.mountPoint == mountPoint }
+ ) {
devices.add(USBDevice("auto", mountPoint))
}
@@ -337,7 +358,7 @@ class USBVirusScanner {
infectedFiles = emptyList(),
virusNames = emptyMap(),
exitCode = -1,
- error = if (isDebug)"Путь не существует или не является директорией: $path" else ""
+ error = if (isDebug) "Путь не существует или не является директорией: $path" else ""
)
}
@@ -380,7 +401,7 @@ class USBVirusScanner {
)
} catch (e: Exception) {
- println(if (isDebug) " Ошибка при выполнении clamscan: ${e.message}" else "")
+ println(if (isDebug) "Ошибка при выполнении clamscan: ${e.message}" else "")
return ScanResult(
isInfected = false,
infectedFiles = emptyList(),
@@ -432,6 +453,62 @@ class USBVirusScanner {
}
}
+ fun isUsbSharing(isActive: Boolean): Boolean {
+ var defaultState: Boolean = false
+ defaultState = isActive
+ return defaultState
+ }
+
+ suspend fun sambaStartSharing() {
+ try {
+ currentState = SystemState.SAMBA
+
+ var process: Process? = null
+ val sambaStartServiceCmd = listOf("systemctl", "start", "smbd")
+ val processBuilder = ProcessBuilder(sambaStartServiceCmd)
+ .redirectErrorStream(true)
+
+ process = withContext(Dispatchers.IO) {
+ processBuilder.start()
+ }
+ } catch (e: Exception) {
+ e.printStackTrace()
+ currentState = SystemState.ERROR
+ delay(10000.milliseconds)
+ }
+ }
+
+ fun sambaShutdown() {
+ unmount()
+ try {
+ var process: Process? = null
+ val sambaStopServiceCmd = listOf("systemctl", "stop", "smbd")
+ val processBuilder = ProcessBuilder(sambaStopServiceCmd)
+ .redirectErrorStream(true)
+ process = processBuilder.start()
+ currentState = SystemState.IDLE
+ } catch (e: Exception) {}
+ }
+
+
+ fun unmount() {
+ for (i in 0..9) {
+ val path = if (i == 0) "/media/usb" else "/media/usb$i"
+ try {
+ val processBuilder = ProcessBuilder("umount", "-f", path)
+ .redirectErrorStream(true)
+ val process = processBuilder.start()
+ val exitCode = process.waitFor()
+ if (exitCode == 0) {
+ println(if (isDebug) "Успешно размонтировано: $path" else "")
+ }
+ } catch (e: Exception) {
+ println(if (isDebug) "Ошибка при размонтировании $path: ${e.message}" else "")
+ }
+ }
+
+ }
+
fun shutdown() {
println(if (isDebug) "\nЗавершение работы..." else "")
isRunning = false
@@ -527,7 +604,6 @@ fun main(args: Array) {
println(if (isDebug) "Красный - ${PinConfig.RED_LED}" else "")
println(if (isDebug) "Кнопка - ${PinConfig.BUTTON}" else "")
- val defaultButtonState = false
val scanner = USBVirusScanner()
Runtime.getRuntime().addShutdownHook(Thread {
@@ -544,12 +620,13 @@ fun main(args: Array) {
}
buttonListener.addLongPressListener { event ->
- println("TODO: Сделать отключение samba и отмонтирование накопителя.")
+ scanner.sambaShutdown()
}
buttonListener.startListening()
- println(if (isDebug) """
+ println(
+ if (isDebug) """
═══════════════════════════════════════
USB Virus Scanner готов к работе
═══════════════════════════════════════
@@ -559,7 +636,8 @@ fun main(args: Array) {
📌 Зелёный LED горит - флешка чиста
📌 Красный LED горит - найдены вирусы
📌 Для выхода нажмите Ctrl+C
- """.trimIndent() else "")
+ """.trimIndent() else ""
+ )
while (true) {
Thread.sleep(1000)
--
2.49.1
From 279a4bf802d14f83e2785246c6ed43ca9b2d85d6 Mon Sep 17 00:00:00 2001
From: Thiflict <121az348@gmail.com>
Date: Thu, 16 Apr 2026 00:09:03 +0500
Subject: [PATCH 07/11] =?UTF-8?q?#1:=20TODO:=20=D0=94=D0=BE=D0=B4=D0=B5?=
=?UTF-8?q?=D0=BB=D0=B0=D1=82=D1=8C=20=D0=BE=D1=82=D0=BC=D0=BE=D0=BD=D1=82?=
=?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20Samba?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/kotlin/Main.kt | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index a38f3bd..570549a 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -167,8 +167,8 @@ class USBVirusScanner {
}
SystemState.SAMBA -> {
- blinkLed(greenLed, 1000)
- blinkLed(yellowLed, 1000)
+ blinkLed(greenLed, 200)
+ blinkLed(yellowLed, 200)
redLed.setValue(0)
}
}
@@ -228,6 +228,7 @@ class USBVirusScanner {
if (result.infectedFiles.size > 10) {
println(if (isDebug) " ... и ещё ${result.infectedFiles.size - 10} файлов" else "")
}
+ unmount()
} else if (result.error != null) {
println(if (isDebug) "❌ Ошибка сканирования: ${result.error}" else "")
} else {
@@ -259,7 +260,16 @@ class USBVirusScanner {
currentState = SystemState.SAMBA
sambaStartSharing()
- while (isUsbSharing()) {}
+ val buttonListener = ButtonListener()
+ var isEventHappened = false
+
+ buttonListener.addLongPressListener { event ->
+ isEventHappened = true
+ }
+ buttonListener.startListening()
+ while (!isEventHappened) {
+ delay(500.milliseconds)
+ }
}
currentState = SystemState.IDLE
@@ -453,12 +463,6 @@ class USBVirusScanner {
}
}
- fun isUsbSharing(isActive: Boolean): Boolean {
- var defaultState: Boolean = false
- defaultState = isActive
- return defaultState
- }
-
suspend fun sambaStartSharing() {
try {
currentState = SystemState.SAMBA
--
2.49.1
From 6a28281d1ca88452b1f255f074029407382c3465 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=9A=D0=BE=D1=88=D0=BA=D0=BE=D1=84=D0=BB=D0=B8=D0=BA?=
=?UTF-8?q?=D1=82?= <121az348@gmail.com>
Date: Wed, 15 Apr 2026 19:13:00 +0000
Subject: [PATCH 08/11] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8?=
=?UTF-8?q?=D1=82=D1=8C=20readme.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Кошкофликт <121az348@gmail.com>
---
readme.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/readme.md b/readme.md
index 8a231f8..7bffbb9 100644
--- a/readme.md
+++ b/readme.md
@@ -43,4 +43,6 @@ sudo chmod +x install_script.sh
Затем, выполнить его от имени суперпользователя:
```bash
sudo ./install_script.sh
-```
\ No newline at end of file
+```
+
+# Development: stable коммит сейчас является [a655f026](https://git.ds1.thiflict.ru/Shafeev-CourseWork/Practice-Part/commit/a655f026b4e583bf736355d6b0f161f47c620235)
\ No newline at end of file
--
2.49.1
From 9aaa0a3d257475a7dc17baa3c249eaacc96a6a3e Mon Sep 17 00:00:00 2001
From: thiflict <121az348@gmail.com>
Date: Fri, 17 Apr 2026 09:18:06 +0500
Subject: [PATCH 09/11] =?UTF-8?q?#1:=20=D0=94=D0=BE=D0=B4=D0=B5=D0=BB?=
=?UTF-8?q?=D0=B0=D0=BB=20Samba?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/gradle.xml | 1 -
src/main/kotlin/Main.kt | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 3a0665a..ce1c62c 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -12,6 +12,5 @@
-
\ No newline at end of file
diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt
index 570549a..de75146 100644
--- a/src/main/kotlin/Main.kt
+++ b/src/main/kotlin/Main.kt
@@ -490,6 +490,7 @@ class USBVirusScanner {
val processBuilder = ProcessBuilder(sambaStopServiceCmd)
.redirectErrorStream(true)
process = processBuilder.start()
+ scanJob?.cancel()
currentState = SystemState.IDLE
} catch (e: Exception) {}
}
--
2.49.1
From d41b133885ffa0c8046e485097bee2d32c9cfb12 Mon Sep 17 00:00:00 2001
From: thiflict <121az348@gmail.com>
Date: Sun, 19 Apr 2026 21:13:52 +0500
Subject: [PATCH 10/11] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?=
=?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B2=20./install=5Fscript.sh.=20=D0=9F?=
=?UTF-8?q?=D0=BE=D0=B4=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BA?=
=?UTF-8?q?=20=D1=80=D0=B5=D0=BB=D0=B8=D0=B7=D1=83=20V2.0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
install_script.sh | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/install_script.sh b/install_script.sh
index a380366..fd3aed8 100644
--- a/install_script.sh
+++ b/install_script.sh
@@ -4,11 +4,11 @@
# Date: 2026-04-14
# Так как скрипт не тестировался должным образом, необходимо запросить у пользователя о его намерениях продолжать выполнение скрипта.
-read -p "ВНИМАНИЕ!!! Данный скрипт установки не тестировался должным образом! Это значит, что скрипт может поломать некоторые конфиги ClamAV КАК МИНИМУМ! Для продолжения введите: 'i understand all the risks and want to continue'. Это будет означать, что вы понимаете риски и хотите продолжить выполнение программы! " answer
+read -p "ВНИМАНИЕ!!! Данный скрипт установки не тестировался должным образом! Это значит, что скрипт может поломать некоторые конфиги ClamAV и Samba КАК МИНИМУМ! Для продолжения введите: 'i understand all the risks and want to continue'. Это будет означать, что вы понимаете риски и хотите продолжить выполнение программы! " answer
answer=${answer,,}
if [[ "$answer" != "i understand all the risks and want to continue" ]]; then
- echo "Неправильно набрана фраза для продолжена. Отменяю..."
+ echo "Неправильно набрана фраза для продолжения. Отменяю..."
exit 0
fi
echo "Выполняю..."
@@ -49,8 +49,15 @@ sed -i -E "
echo "Загрузка необходиых временных файлов..."
rm -rf /tmp/rpivs;
mkdir /tmp/rpivs;
-wget https://static1.thiflict.ru/raspberrypi_virus_scanner/rpivirusscanner_v1.0.jar -o /tmp/rpivs/rpivirusscanner.jar;
-wget https://static1.thiflict.ru/raspberrypi_virus_scanner/v1.0/rpi_virus_scanner_service -o /tmp/rpivs/rpi_virus_scanner.service;
+wget https://static1.thiflict.ru/raspberrypi_virus_scanner/v2.0/smb_conf -o /tmp/rpivs/smb.conf
+wget https://static1.thiflict.ru/raspberrypi_virus_scanner/v2.0/rpivirusscanner.jar -o /tmp/rpivs/rpivirusscanner.jar;
+wget https://static1.thiflict.ru/raspberrypi_virus_scanner/v2.0/rpi_virus_scanner_service -o /tmp/rpivs/rpi_virus_scanner.service;
+
+# Настройка Samba
+echo "Выполняется настройка Samba"
+systemctl stop smbd
+systemctl disable smbd
+
# Установка программы
echo "Установка программы..."
--
2.49.1
From 80a50f0043106c565cd2301069d0ebf99f288d0d Mon Sep 17 00:00:00 2001
From: Thiflict <121az348@gmail.com>
Date: Sun, 19 Apr 2026 21:29:04 +0500
Subject: [PATCH 11/11] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=B8=D0=BB=D0=B5?=
=?UTF-8?q?=D0=BD=20install=5Fscript.sh?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
install_script.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/install_script.sh b/install_script.sh
index fd3aed8..9f72b39 100644
--- a/install_script.sh
+++ b/install_script.sh
@@ -57,7 +57,8 @@ wget https://static1.thiflict.ru/raspberrypi_virus_scanner/v2.0/rpi_virus_scanne
echo "Выполняется настройка Samba"
systemctl stop smbd
systemctl disable smbd
-
+cp /tmp/rpivs/smb.conf /etc/samba/smb.conf
+testparm # Для дебага
# Установка программы
echo "Установка программы..."
--
2.49.1