Compare commits
84 Commits
feature/ta
...
24839dc3fe
| Author | SHA1 | Date | |
|---|---|---|---|
| 24839dc3fe | |||
| 2b8a5f326c | |||
| 180e1e6be4 | |||
| 1a1fca9325 | |||
| e416a84bf7 | |||
| dcd357c6e0 | |||
| 43958b0d7c | |||
| c8ff9725e5 | |||
| bac9f84092 | |||
| 38a989e223 | |||
| 2b782867c9 | |||
| 3a0866dfa4 | |||
| 386dceed36 | |||
| 5d4370d932 | |||
| 23effc5fe6 | |||
| e259bb0262 | |||
| 9849a46a40 | |||
| 757850aae6 | |||
| 431e777988 | |||
| 8b8833cd2b | |||
| 754ae67714 | |||
| 7d929254dd | |||
| d822059e4e | |||
| 0fecaa501b | |||
| 034387af16 | |||
| 07b27cb6de | |||
| 28ec8dcd64 | |||
| de303fcd8e | |||
| 35a8d6a8c7 | |||
| bf070c29a1 | |||
| 395da1739b | |||
| 34744f93ec | |||
| a20b0c4963 | |||
| 94485ab9d2 | |||
| 204dbc5f73 | |||
| 98bc9633be | |||
| 8bdc56bd8a | |||
| 051e201525 | |||
| b68520ffa4 | |||
| 74078b120c | |||
| 94285d88b7 | |||
| 008b173b70 | |||
| 0ba76e16b2 | |||
| bdb19c81ca | |||
| d56b5a5617 | |||
| 182f850a3b | |||
| 11c0b4f369 | |||
| a6151fb01e | |||
| 3c53ea17a5 | |||
| 3b505398e4 | |||
| ead94bea2f | |||
| ecfd0a9ae5 | |||
| 7a0c2fde66 | |||
| 56a74a8b49 | |||
| 0863650ddc | |||
| 02a4b5081f | |||
| 9ef9ad18cf | |||
| fd39b88296 | |||
| 74f02e7827 | |||
| dc07591612 | |||
| 0f9721f562 | |||
| 742d246cdb | |||
| 0ac12deed3 | |||
| 9a4652b8f2 | |||
| edd29ea029 | |||
| 7838e60a82 | |||
| 02a56ee434 | |||
| d60187cc07 | |||
| 6359c59af9 | |||
| c84e935f05 | |||
| f9ad7fddbd | |||
| f011205a22 | |||
| 5920067b02 | |||
| 9e6cba52f6 | |||
| 638dc42a46 | |||
| fd4248d722 | |||
| b71b4db66e | |||
| 9ee1a4de3c | |||
| c42781c5ee | |||
| daf9e9cb06 | |||
| d0be1f0a62 | |||
| e75c496ea8 | |||
| 32147b0e52 | |||
| 99d06bb3bc |
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Используем официальный образ OpenJDK 17 как базовый образ
|
||||||
|
FROM openjdk:17
|
||||||
|
|
||||||
|
# Установка рабочей директории внутри контейнера
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Копируем JAR-файл приложения из локальной директории внутрь контейнера
|
||||||
|
COPY ServerMonitorBot-0.0.1-SNAPSHOT.jar app.jar
|
||||||
|
|
||||||
|
# Команда для запуска Spring Boot приложения при старте контейнера
|
||||||
|
CMD ["java", "-jar", "app.jar"]
|
||||||
64
Jenkinsfile_CD
Normal file
64
Jenkinsfile_CD
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'maven:3.9.5-eclipse-temurin-17'
|
||||||
|
args '-v /root/.m2:/root/.m2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
SSH_HOST = credentials('ROCK_PI_5_SSH_HOST')
|
||||||
|
SSH_PORT = credentials('ROCK_PI_5_SSH_PORT')
|
||||||
|
SSH_USER = credentials('ROCK_PI_5_SSH_USER')
|
||||||
|
SSH_PASS = credentials('ROCK_PI_5_SSH_PASS')
|
||||||
|
PATH_TO_DEV_FOLDER = credentials('SERVERMONITORBOT_PATH_TO_DEV_FOLDER')
|
||||||
|
IMAGE_NAME = 'servermonitorbot'
|
||||||
|
IMAGE_VERSION = 'latest'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Init container') {
|
||||||
|
steps {
|
||||||
|
sh 'apt-get update && apt-get install -y sshpass openssh-client'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
withCredentials([file(credentialsId: 'SERVERMONITORBOT_APPLICATION_YAML', variable: 'application_yaml')]) {
|
||||||
|
sh "cp -f \$application_yaml src/main/resources/application.yml"
|
||||||
|
}
|
||||||
|
sh 'mvn -B -DskipTests -X clean package spring-boot:repackage'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Prune images pre') {
|
||||||
|
steps {
|
||||||
|
sh """
|
||||||
|
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'docker image prune --all --force'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
sh """
|
||||||
|
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'mkdir -p ${PATH_TO_DEV_FOLDER}'
|
||||||
|
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'rm -f ${PATH_TO_DEV_FOLDER}/{*.*}'
|
||||||
|
sshpass -p ${SSH_PASS} scp -o StrictHostKeyChecking=no -P ${SSH_PORT} target/*.jar ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
|
||||||
|
sshpass -p ${SSH_PASS} scp -o StrictHostKeyChecking=no -P ${SSH_PORT} Dockerfile ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
|
||||||
|
sshpass -p ${SSH_PASS} scp -o StrictHostKeyChecking=no -P ${SSH_PORT} docker-compose.yml ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
|
||||||
|
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker build --no-cache -t ${IMAGE_NAME}:${IMAGE_VERSION} .'
|
||||||
|
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker compose up -d'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Prune images post') {
|
||||||
|
steps {
|
||||||
|
sh """
|
||||||
|
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'docker image prune --all --force'
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
15
Jenkinsfile_CI
Normal file
15
Jenkinsfile_CI
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
docker {
|
||||||
|
image 'maven:3.9.5-eclipse-temurin-17'
|
||||||
|
args '-v /root/.m2:/root/.m2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
sh 'mvn -B -DskipTests -X clean package spring-boot:repackage'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
docker-compose.yml
Normal file
21
docker-compose.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:latest
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: servermonitorbot
|
||||||
|
POSTGRES_PASSWORD: servermonitorbot
|
||||||
|
POSTGRES_DB: servermonitorbot
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
51
pom.xml
51
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.1.3</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>ru.ldeloff</groupId>
|
<groupId>ru.ldeloff</groupId>
|
||||||
@@ -15,6 +15,11 @@
|
|||||||
<description>ServerMonitorBot</description>
|
<description>ServerMonitorBot</description>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
|
<flyway.version>9.16.0</flyway.version>
|
||||||
|
<db.url>${database.url}</db.url>
|
||||||
|
<db.user>${database.username}</db.user>
|
||||||
|
<db.password>${database.password}</db.password>
|
||||||
|
<start-class>ru.ldeloff.servermonitorbot.ServerMonitorBotApplication</start-class>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -40,7 +45,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.telegram</groupId>
|
<groupId>org.telegram</groupId>
|
||||||
<artifactId>telegrambots</artifactId>
|
<artifactId>telegrambots</artifactId>
|
||||||
<version>6.7.0</version>
|
<version>6.8.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jcraft</groupId>
|
<groupId>com.jcraft</groupId>
|
||||||
@@ -51,14 +56,15 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.liquibase</groupId>
|
|
||||||
<artifactId>liquibase-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.postgresql</groupId>
|
<groupId>org.postgresql</groupId>
|
||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-core</artifactId>
|
||||||
|
<version>${flyway.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -75,6 +81,39 @@
|
|||||||
</excludes>
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.flywaydb</groupId>
|
||||||
|
<artifactId>flyway-maven-plugin</artifactId>
|
||||||
|
<version>${flyway.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>migrate</id>
|
||||||
|
<phase>deploy</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>migrate</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<url>${database.url}</url>
|
||||||
|
<user>${database.username}</user>
|
||||||
|
<password>${database.password}</password>
|
||||||
|
<locations>
|
||||||
|
<location>classpath:db/migration</location>
|
||||||
|
</locations>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
@@ -4,167 +4,95 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
||||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
|
||||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
|
||||||
import ru.ldeloff.servermonitorbot.model.Role;
|
|
||||||
import ru.ldeloff.servermonitorbot.model.TelegramBot;
|
import ru.ldeloff.servermonitorbot.model.TelegramBot;
|
||||||
import ru.ldeloff.servermonitorbot.model.User;
|
|
||||||
import ru.ldeloff.servermonitorbot.repository.SshRepository;
|
import ru.ldeloff.servermonitorbot.repository.SshRepository;
|
||||||
import ru.ldeloff.servermonitorbot.service.TelegramBotService;
|
import ru.ldeloff.servermonitorbot.service.command.FirstUseCommand;
|
||||||
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
import ru.ldeloff.servermonitorbot.service.command.GetStatusSessions;
|
||||||
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
import ru.ldeloff.servermonitorbot.service.command.SwitchToMainMenu;
|
||||||
import ru.ldeloff.servermonitorbot.utils.ui.TelegramBotKeyboard;
|
import ru.ldeloff.servermonitorbot.service.command.cputemp.CpuTempAggregateCommand;
|
||||||
import ru.ldeloff.servermonitorbot.utils.ui.uname.UnameChatButtonAggregate;
|
import ru.ldeloff.servermonitorbot.service.command.cputemp.CpuTempCommand;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.hddtemp.HddTempAggregateCommand;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.hddtemp.HddTempCommand;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.uname.UnameAggregateCommand;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.uname.UnameCommand;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class TelegramBotController extends TelegramLongPollingBot {
|
public class TelegramBotController extends TelegramLongPollingBot {
|
||||||
|
|
||||||
final TelegramBot telegramBot;
|
final TelegramBot telegramBot;
|
||||||
final SshRepository sshRepository;
|
final SshRepository sshRepository;
|
||||||
final TelegramBotService telegramBotService;
|
|
||||||
final UserService userService;
|
final FirstUseCommand firstUseCommand;
|
||||||
final RoleService roleService;
|
final GetStatusSessions getStatusSessions;
|
||||||
|
final UnameAggregateCommand unameAggregateCommand;
|
||||||
|
final SwitchToMainMenu switchToMainMenu;
|
||||||
|
final UnameCommand unameCommand;
|
||||||
|
final CpuTempAggregateCommand cpuTempAggregateCommand;
|
||||||
|
final CpuTempCommand cpuTempCommand;
|
||||||
|
final HddTempAggregateCommand hddTempAggregateCommand;
|
||||||
|
final HddTempCommand hddTempCommand;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateReceived(Update update) {
|
public void onUpdateReceived(Update update) {
|
||||||
Role role = getRole(update);
|
|
||||||
if (update.hasMessage()) {
|
if (update.hasMessage()) {
|
||||||
if (update.getMessage().hasText()) {
|
if (update.getMessage().hasText()) {
|
||||||
String messageText = update.getMessage().getText();
|
String messageText = update.getMessage().getText();
|
||||||
switch (messageText) {
|
switch (messageText) {
|
||||||
case "/start" -> {
|
case "/start" -> {
|
||||||
if (role.getId() < 3) {
|
firstUseCommand.execute(update, this);
|
||||||
log.info("Получена команда '" + messageText
|
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). OK");
|
|
||||||
telegramBotService.firstUse(update, this);
|
|
||||||
} else {
|
|
||||||
log.warn("Получена команда '" + messageText
|
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). Нет прав");
|
|
||||||
telegramBotService.notAuthorization(update, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "Статус" -> {
|
case "Статус" -> {
|
||||||
if (role.getId() < 3) {
|
getStatusSessions.execute(update, this);
|
||||||
log.info("Получена команда '" + messageText
|
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). OK");
|
|
||||||
telegramBotService.getStatusSessions(update, this);
|
|
||||||
} else {
|
|
||||||
log.warn("Получена команда '" + messageText
|
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). Нет прав");
|
|
||||||
telegramBotService.notAuthorization(update, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case "uname" -> {
|
case "uname" -> {
|
||||||
if (role.getId() < 3) {
|
unameAggregateCommand.execute(update, this);
|
||||||
log.info("Получена команда '" + messageText
|
}
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
case "CPU.temp" -> {
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). OK");
|
cpuTempAggregateCommand.execute(update, this);
|
||||||
telegramBotService.sendUnameAggregate(update, this);
|
}
|
||||||
} else {
|
case "HDD.temp" -> {
|
||||||
log.warn("Получена команда '" + messageText
|
hddTempAggregateCommand.execute(update, this);
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). Нет прав");
|
|
||||||
telegramBotService.notAuthorization(update, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
if (role.getId() < 3) {
|
switchToMainMenu.execute(update, this);
|
||||||
log.warn("Неизвестная команда '" + messageText
|
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). ОК");
|
|
||||||
telegramBotService.switchToMainMenu(update, this);
|
|
||||||
} else {
|
|
||||||
log.warn("Неизвестная команда '" + messageText
|
|
||||||
+ "' от " + update.getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getMessage().getChat().getId() + "). Нет прав");
|
|
||||||
telegramBotService.notAuthorization(update, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (update.hasCallbackQuery()) {
|
} else if (update.hasCallbackQuery()) {
|
||||||
String messageText = update.getCallbackQuery().getData();
|
String [] tags = update.getCallbackQuery().getData().split(":");
|
||||||
String [] tags = messageText.split(":");
|
|
||||||
if (tags.length > 1) {
|
if (tags.length > 1) {
|
||||||
switch (tags[0]) {
|
switch (tags[0]) {
|
||||||
case "uname":
|
case "uname" -> {
|
||||||
if (role.getId() < 3) {
|
unameCommand.execute(update, this);
|
||||||
log.info("Получена команда '" + messageText
|
}
|
||||||
+ "' от " + update.getCallbackQuery().getMessage().getChat().getUserName()
|
case "CPU.temp" -> {
|
||||||
+ " (" + update.getCallbackQuery().getMessage().getChat().getId() + "). ОК");
|
cpuTempCommand.execute(update, this);
|
||||||
telegramBotService.uname(update, this);
|
}
|
||||||
} else {
|
case "HDD.temp" -> {
|
||||||
log.info("Получена команда '" + messageText
|
hddTempCommand.execute(update, this);
|
||||||
+ "' от " + update.getCallbackQuery().getMessage().getChat().getUserName()
|
}
|
||||||
+ " (" + update.getCallbackQuery().getMessage().getChat().getId() + "). Нет прав");
|
default -> {
|
||||||
telegramBotService.notAuthorization(update, this);
|
switchToMainMenu.execute(update, this);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (role.getId() < 3) {
|
|
||||||
log.warn("Неизвестная команда '" + messageText
|
|
||||||
+ "' от " + update.getCallbackQuery().getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getCallbackQuery().getMessage().getChat().getId() + "). ОК");
|
|
||||||
telegramBotService.switchToMainMenu(update, this);
|
|
||||||
} else {
|
|
||||||
log.warn("Неизвестная команда '" + messageText
|
|
||||||
+ "' от " + update.getCallbackQuery().getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getCallbackQuery().getMessage().getChat().getId() + "). Нет прав");
|
|
||||||
telegramBotService.notAuthorization(update, this);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (role.getId() < 3) {
|
switchToMainMenu.execute(update, this);
|
||||||
log.warn("Неверный формат команды '" + messageText
|
|
||||||
+ "' от " + update.getCallbackQuery().getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getCallbackQuery().getMessage().getChat().getId() + "). ОК");
|
|
||||||
telegramBotService.switchToMainMenu(update, this);
|
|
||||||
} else {
|
|
||||||
log.warn("Неверный формат команды '" + messageText
|
|
||||||
+ "' от " + update.getCallbackQuery().getMessage().getChat().getUserName()
|
|
||||||
+ " (" + update.getCallbackQuery().getMessage().getChat().getId() + "). Нет прав");
|
|
||||||
telegramBotService.notAuthorization(update, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBotUsername() {
|
public String getBotUsername() {
|
||||||
return telegramBot.getBotUsername();
|
return telegramBot.getBotUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBotToken() {
|
public String getBotToken() {
|
||||||
return telegramBot.getBotToken();
|
return telegramBot.getBotToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClosing() {
|
public void onClosing() {
|
||||||
super.onClosing();
|
super.onClosing();
|
||||||
sshRepository.disconnectSessions();
|
sshRepository.disconnectSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Role getRole(Update update) {
|
|
||||||
Long id = null;
|
|
||||||
if (update.hasMessage()) {
|
|
||||||
id = update.getMessage().getChat().getId();
|
|
||||||
} else if (update.hasCallbackQuery()) {
|
|
||||||
id = update.getCallbackQuery().getMessage().getChat().getId();
|
|
||||||
}
|
|
||||||
User user = userService.getByTelegramId(id);
|
|
||||||
if (user == null) {
|
|
||||||
return roleService.findRoleById(3L);
|
|
||||||
} else {
|
|
||||||
return user.getRole();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,4 +18,7 @@ public class User {
|
|||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "role_id")
|
@JoinColumn(name = "role_id")
|
||||||
private Role role;
|
private Role role;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private String login;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package ru.ldeloff.servermonitorbot.service;
|
|
||||||
|
|
||||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
|
||||||
import ru.ldeloff.servermonitorbot.controller.TelegramBotController;
|
|
||||||
|
|
||||||
public interface TelegramBotService {
|
|
||||||
|
|
||||||
void switchToMainMenu(Update update, TelegramBotController bot);
|
|
||||||
void getStatusSessions(Update update, TelegramBotController bot);
|
|
||||||
void sendUnameAggregate(Update update, TelegramBotController bot);
|
|
||||||
void uname(Update update, TelegramBotController bot);
|
|
||||||
void firstUse(Update update, TelegramBotController bot);
|
|
||||||
void notAuthorization(Update update, TelegramBotController bot);
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
package ru.ldeloff.servermonitorbot.service;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
|
||||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
|
||||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
|
||||||
import ru.ldeloff.servermonitorbot.controller.TelegramBotController;
|
|
||||||
import ru.ldeloff.servermonitorbot.repository.SshRepository;
|
|
||||||
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
|
||||||
import ru.ldeloff.servermonitorbot.service.uname.UnameService;
|
|
||||||
import ru.ldeloff.servermonitorbot.utils.ui.TelegramBotKeyboard;
|
|
||||||
import ru.ldeloff.servermonitorbot.utils.ui.uname.UnameChatButtonAggregate;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class TelegramBotServiceImpl implements TelegramBotService {
|
|
||||||
final TelegramBotKeyboard telegramBotKeyboard;
|
|
||||||
final UnameChatButtonAggregate unameChatButtonAggregate;
|
|
||||||
final UnameService unameService;
|
|
||||||
final SshService sshService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void firstUse(Update update, TelegramBotController bot) {
|
|
||||||
SendMessage message = new SendMessage();
|
|
||||||
long chatId = 0L;
|
|
||||||
chatId = update.getMessage().getChatId();
|
|
||||||
message.setText("Добро пожаловать " + update.getMessage().getChat().getUserName() + "!");
|
|
||||||
message.setChatId(chatId);
|
|
||||||
sendMessage(telegramBotKeyboard.uiForm(message), bot);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notAuthorization(Update update, TelegramBotController bot) {
|
|
||||||
long id = 0L;
|
|
||||||
String login = null;
|
|
||||||
long chatId = 0L;
|
|
||||||
if (update.hasMessage()) {
|
|
||||||
id = update.getMessage().getChat().getId();
|
|
||||||
login = update.getMessage().getChat().getUserName();
|
|
||||||
chatId = update.getMessage().getChatId();
|
|
||||||
} else if (update.hasCallbackQuery()) {
|
|
||||||
id = update.getCallbackQuery().getMessage().getChat().getId();
|
|
||||||
login = update.getCallbackQuery().getMessage().getChat().getUserName();
|
|
||||||
chatId = update.getCallbackQuery().getMessage().getChatId();
|
|
||||||
}
|
|
||||||
SendMessage message = new SendMessage();
|
|
||||||
message.setText("У пользователя " + login
|
|
||||||
+ " (" + id + ") недостаточно прав для выполнения этой команды");
|
|
||||||
message.setChatId(chatId);
|
|
||||||
sendMessage(message, bot);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void switchToMainMenu(Update update, TelegramBotController bot) {
|
|
||||||
SendMessage message = new SendMessage();
|
|
||||||
long chatId = 0L;
|
|
||||||
try {
|
|
||||||
chatId = update.getMessage().getChatId();
|
|
||||||
} catch (Exception e) {
|
|
||||||
chatId = update.getCallbackQuery().getMessage().getChatId();
|
|
||||||
}
|
|
||||||
message.setText("Неверная команда и или формат. Попробуем сначала.");
|
|
||||||
message.setChatId(chatId);
|
|
||||||
sendMessage(telegramBotKeyboard.uiForm(message), bot);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void getStatusSessions(Update update, TelegramBotController bot) {
|
|
||||||
sendMessage(sshService.getStatusSessions(update), bot);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void sendUnameAggregate(Update update, TelegramBotController bot) {
|
|
||||||
sendMessage(unameService.sendUnameAggregate(update), bot);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uname(Update update, TelegramBotController bot) {
|
|
||||||
sendMessage(unameService.uname(update), bot);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendMessage(SendMessage message, TelegramBotController bot) {
|
|
||||||
try {
|
|
||||||
bot.execute(message);
|
|
||||||
} catch (TelegramApiException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
log.warn(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||||
|
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||||
|
import ru.ldeloff.servermonitorbot.controller.TelegramBotController;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public abstract class CommandTemplate {
|
||||||
|
final UserService userService;
|
||||||
|
final RoleService roleService;
|
||||||
|
long expectedRole = 2L;
|
||||||
|
public abstract SendMessage actionForAuth(User user, SendMessage message);
|
||||||
|
|
||||||
|
public SendMessage actionForNotAuth(User user, SendMessage message) {
|
||||||
|
message.setText("У пользователя " + user.getLogin() + " (" + user.getTelegramId()
|
||||||
|
+ ") недостаточно прав для выполнения этой команды");
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
public void execute(Update update, TelegramBotController bot) {
|
||||||
|
User user = getUser(update);
|
||||||
|
String message = getMessage(update);
|
||||||
|
SendMessage answer = new SendMessage();
|
||||||
|
answer.setChatId(user.getTelegramId());
|
||||||
|
answer.setText(message);
|
||||||
|
if (user.getRole().getId() <= expectedRole) {
|
||||||
|
logSuccess(user, message);
|
||||||
|
sendMessage(actionForAuth(user, answer), bot);
|
||||||
|
} else {
|
||||||
|
logNotAuth(user, message);
|
||||||
|
sendMessage(actionForNotAuth(user, answer), bot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void logSuccess(User user, String message) {
|
||||||
|
log.info("Получена команда '" + message + "' от " + user.getLogin()
|
||||||
|
+ " (" + user.getTelegramId() + "). OK");
|
||||||
|
}
|
||||||
|
protected void logNotAuth(User user, String message) {
|
||||||
|
log.warn("Получена команда '" + message + "' от " + user.getLogin()
|
||||||
|
+ " (" + user.getTelegramId() + "). Нет прав");
|
||||||
|
}
|
||||||
|
private User getUser(Update update) {
|
||||||
|
long id = -1L;
|
||||||
|
String login = null;
|
||||||
|
if (update.hasMessage()) {
|
||||||
|
id = update.getMessage().getChat().getId();
|
||||||
|
login = update.getMessage().getChat().getUserName();
|
||||||
|
} else if (update.hasCallbackQuery()) {
|
||||||
|
id = update.getCallbackQuery().getMessage().getChat().getId();
|
||||||
|
login = update.getCallbackQuery().getMessage().getChat().getUserName();
|
||||||
|
}
|
||||||
|
User user = userService.getByTelegramId(id);
|
||||||
|
if (user == null) {
|
||||||
|
user = new User();
|
||||||
|
user.setTelegramId(id);
|
||||||
|
user.setRole(roleService.findRoleById(3L));
|
||||||
|
}
|
||||||
|
user.setLogin(login);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getMessage(Update update) {
|
||||||
|
if (update.hasMessage()) {
|
||||||
|
return update.getMessage().getText();
|
||||||
|
} else if (update.hasCallbackQuery()) {
|
||||||
|
return update.getCallbackQuery().getData();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMessage(SendMessage message, TelegramBotController bot) {
|
||||||
|
try {
|
||||||
|
bot.execute(message);
|
||||||
|
} catch (TelegramApiException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.warn(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
import ru.ldeloff.servermonitorbot.utils.ui.TelegramBotKeyboard;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FirstUseCommand extends CommandTemplate {
|
||||||
|
final TelegramBotKeyboard telegramBotKeyboard;
|
||||||
|
|
||||||
|
public FirstUseCommand(UserService userService, RoleService roleService, TelegramBotKeyboard telegramBotKeyboard) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.telegramBotKeyboard = telegramBotKeyboard;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
message.setText("Добро пожаловать " + user.getLogin() + "!");
|
||||||
|
return telegramBotKeyboard.uiForm(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GetStatusSessions extends CommandTemplate {
|
||||||
|
final SshService sshService;
|
||||||
|
|
||||||
|
public GetStatusSessions(UserService userService, RoleService roleService, SshService sshService) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.sshService = sshService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
return sshService.getStatusSessions(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
import ru.ldeloff.servermonitorbot.utils.ui.TelegramBotKeyboard;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SwitchToMainMenu extends CommandTemplate {
|
||||||
|
final TelegramBotKeyboard telegramBotKeyboard;
|
||||||
|
|
||||||
|
public SwitchToMainMenu(UserService userService, RoleService roleService, TelegramBotKeyboard telegramBotKeyboard) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.telegramBotKeyboard = telegramBotKeyboard;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
message.setText("Неверная команда. Попробуем сначала.");
|
||||||
|
return telegramBotKeyboard.uiForm(message);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void logSuccess(User user, String message) {
|
||||||
|
log.warn("Получена несуществующая команда '" + message + "' от " + user.getLogin()
|
||||||
|
+ " (" + user.getTelegramId() + "). OK");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void logNotAuth(User user, String message) {
|
||||||
|
log.warn("Получена несуществующая команда '" + message + "' от " + user.getLogin()
|
||||||
|
+ " (" + user.getTelegramId() + "). Нет прав");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command.cputemp;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
import ru.ldeloff.servermonitorbot.utils.ui.uname.ServerListButtons;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CpuTempAggregateCommand extends CommandTemplate {
|
||||||
|
final ServerListButtons serverListButtons;
|
||||||
|
|
||||||
|
public CpuTempAggregateCommand(UserService userService, RoleService roleService, ServerListButtons serverListButtons) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.serverListButtons = serverListButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
return serverListButtons.uiForm(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command.cputemp;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.Command;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.SshServer;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
import ru.ldeloff.servermonitorbot.utils.SshServerUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class CpuTempCommand extends CommandTemplate {
|
||||||
|
final SshService sshService;
|
||||||
|
public CpuTempCommand(UserService userService, RoleService roleService, SshService sshService) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.sshService = sshService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
String [] tags = Arrays.stream(message.getText().split(":"))
|
||||||
|
.map(String::trim)
|
||||||
|
.toArray(String[]::new);
|
||||||
|
|
||||||
|
if (tags[1].equals("all")) {
|
||||||
|
message.setText(hddTempAllHost());
|
||||||
|
} else {
|
||||||
|
message.setText(Objects.requireNonNull(hddTempSpecificHost(tags[1])));
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String hddTempAllHost() {
|
||||||
|
List<SshServer> servers = SshServerUtils.filterGoodServers(sshService.getSshServers());
|
||||||
|
StringBuilder response = new StringBuilder();
|
||||||
|
servers.forEach(server -> response.append(hddTempSpecificHost(server.getName())).append("\n"));
|
||||||
|
return response.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String hddTempSpecificHost(String serverName) {
|
||||||
|
Optional<SshServer> server = sshService.getSshServers()
|
||||||
|
.stream()
|
||||||
|
.filter(x -> x.getName().equals(serverName))
|
||||||
|
.findFirst();
|
||||||
|
if (server.isPresent()) {
|
||||||
|
Command result = sshService.execute(new Command("cat /sys/class/thermal/thermal_zone0/temp", 100, server.get()));
|
||||||
|
return server.get().getName() + ": \n" +
|
||||||
|
(Objects.isNull(result.getResponse()) ? "ошибка при выполнении команды" :
|
||||||
|
String.format("%.1f",
|
||||||
|
Double.parseDouble(result.getResponse().replaceAll("\n", ""))/1000))
|
||||||
|
+ "°C";
|
||||||
|
} else {
|
||||||
|
log.error("Ошибка при выполнении команды 'CPUtemp'. Искомый сервер (" + serverName + ") не найден");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command.hddtemp;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
import ru.ldeloff.servermonitorbot.utils.ui.uname.ServerListButtons;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class HddTempAggregateCommand extends CommandTemplate {
|
||||||
|
final ServerListButtons serverListButtons;
|
||||||
|
|
||||||
|
public HddTempAggregateCommand(UserService userService, RoleService roleService, ServerListButtons serverListButtons) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.serverListButtons = serverListButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
return serverListButtons.uiForm(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command.hddtemp;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.Command;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.SshServer;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
import ru.ldeloff.servermonitorbot.utils.SshServerUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class HddTempCommand extends CommandTemplate {
|
||||||
|
final SshService sshService;
|
||||||
|
public HddTempCommand(UserService userService, RoleService roleService, SshService sshService) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.sshService = sshService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
String [] tags = Arrays.stream(message.getText().split(":"))
|
||||||
|
.map(String::trim)
|
||||||
|
.toArray(String[]::new);
|
||||||
|
|
||||||
|
if (tags[1].equals("all")) {
|
||||||
|
message.setText(hddTempAllHost());
|
||||||
|
} else {
|
||||||
|
message.setText(Objects.requireNonNull(hddTempSpecificHost(tags[1])));
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String hddTempAllHost() {
|
||||||
|
List<SshServer> servers = SshServerUtils.filterGoodServers(sshService.getSshServers());
|
||||||
|
StringBuilder response = new StringBuilder();
|
||||||
|
servers.forEach(server -> response.append(hddTempSpecificHost(server.getName())).append("\n"));
|
||||||
|
return response.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String hddTempSpecificHost(String serverName) {
|
||||||
|
Optional<SshServer> server = sshService.getSshServers()
|
||||||
|
.stream()
|
||||||
|
.filter(x -> x.getName().equals(serverName))
|
||||||
|
.findFirst();
|
||||||
|
if (server.isPresent()) {
|
||||||
|
Command result = sshService.execute(new Command("hddtemp /dev/sd*", 500, server.get()));
|
||||||
|
return server.get().getName() + ": \n" +
|
||||||
|
(Objects.isNull(result.getResponse()) ? "ошибка при выполнении команды" : result.getResponse());
|
||||||
|
} else {
|
||||||
|
log.error("Ошибка при выполнении команды 'hddtemp'. Искомый сервер (" + serverName + ") не найден");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package ru.ldeloff.servermonitorbot.service.command.uname;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
|
import ru.ldeloff.servermonitorbot.utils.ui.uname.ServerListButtons;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UnameAggregateCommand extends CommandTemplate {
|
||||||
|
final ServerListButtons serverListButtons;
|
||||||
|
|
||||||
|
public UnameAggregateCommand(UserService userService, RoleService roleService, ServerListButtons serverListButtons) {
|
||||||
|
super(userService, roleService);
|
||||||
|
this.serverListButtons = serverListButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
|
return serverListButtons.uiForm(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
package ru.ldeloff.servermonitorbot.service.uname;
|
package ru.ldeloff.servermonitorbot.service.command.uname;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
|
||||||
import ru.ldeloff.servermonitorbot.model.Command;
|
import ru.ldeloff.servermonitorbot.model.Command;
|
||||||
import ru.ldeloff.servermonitorbot.model.SshServer;
|
import ru.ldeloff.servermonitorbot.model.SshServer;
|
||||||
|
import ru.ldeloff.servermonitorbot.model.User;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.role.RoleService;
|
||||||
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
||||||
|
import ru.ldeloff.servermonitorbot.service.user.UserService;
|
||||||
import ru.ldeloff.servermonitorbot.utils.SshServerUtils;
|
import ru.ldeloff.servermonitorbot.utils.SshServerUtils;
|
||||||
import ru.ldeloff.servermonitorbot.utils.ui.uname.UnameChatButtonAggregate;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -17,46 +18,32 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class UnameServiceImpl implements UnameService {
|
public class UnameCommand extends CommandTemplate {
|
||||||
final SshService sshService;
|
final SshService sshService;
|
||||||
final UnameChatButtonAggregate unameChatButtonAggregate;
|
public UnameCommand(UserService userService, RoleService roleService, SshService sshService) {
|
||||||
@Override
|
super(userService, roleService);
|
||||||
public SendMessage sendUnameAggregate(Update update) {
|
this.sshService = sshService;
|
||||||
SendMessage message = new SendMessage();
|
|
||||||
long chatId = update.getMessage().getChatId();
|
|
||||||
message.setChatId(chatId);
|
|
||||||
return unameChatButtonAggregate.uiForm(message);
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public SendMessage uname(Update update) {
|
public SendMessage actionForAuth(User user, SendMessage message) {
|
||||||
String messageText = update.getCallbackQuery().getData();
|
String [] tags = Arrays.stream(message.getText().split(":"))
|
||||||
|
|
||||||
String [] tags = Arrays.stream(messageText.split(":"))
|
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
|
|
||||||
String result;
|
|
||||||
if (tags[1].equals("all")) {
|
if (tags[1].equals("all")) {
|
||||||
result = unameAllHost();
|
message.setText(unameAllHost());
|
||||||
} else {
|
} else {
|
||||||
result = unameSpecificHost(tags[1]);
|
message.setText(Objects.requireNonNull(unameSpecificHost(tags[1])));
|
||||||
}
|
}
|
||||||
SendMessage message = new SendMessage();
|
|
||||||
long chatId = update.getCallbackQuery().getMessage().getChatId();
|
|
||||||
message.setChatId(chatId);
|
|
||||||
message.setText(result);
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String unameAllHost() {
|
private String unameAllHost() {
|
||||||
List<SshServer> servers = SshServerUtils.filterGoodServers(sshService.getSshServers());
|
List<SshServer> servers = SshServerUtils.filterGoodServers(sshService.getSshServers());
|
||||||
StringBuilder response = new StringBuilder();
|
StringBuilder response = new StringBuilder();
|
||||||
servers.forEach(server -> {
|
servers.forEach(server -> response.append(unameSpecificHost(server.getName())).append("\n"));
|
||||||
response.append(unameSpecificHost(server.getName())).append("\n");
|
return response.toString();
|
||||||
});
|
|
||||||
return response.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String unameSpecificHost(String serverName) {
|
private String unameSpecificHost(String serverName) {
|
||||||
@@ -2,14 +2,14 @@ package ru.ldeloff.servermonitorbot.service.ssh;
|
|||||||
|
|
||||||
|
|
||||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
|
||||||
import ru.ldeloff.servermonitorbot.model.Command;
|
import ru.ldeloff.servermonitorbot.model.Command;
|
||||||
import ru.ldeloff.servermonitorbot.model.SshServer;
|
import ru.ldeloff.servermonitorbot.model.SshServer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface SshService {
|
public interface SshService {
|
||||||
SendMessage getStatusSessions(Update update);
|
SendMessage getStatusSessions(SendMessage update);
|
||||||
|
|
||||||
List<SshServer> getSshServers();
|
List<SshServer> getSshServers();
|
||||||
Command execute(Command command);
|
Command execute(Command command);
|
||||||
List<Command> execute(List<Command> commands);
|
List<Command> execute(List<Command> commands);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
|
||||||
import ru.ldeloff.servermonitorbot.model.Command;
|
import ru.ldeloff.servermonitorbot.model.Command;
|
||||||
import ru.ldeloff.servermonitorbot.model.SshServer;
|
import ru.ldeloff.servermonitorbot.model.SshServer;
|
||||||
import ru.ldeloff.servermonitorbot.repository.SshRepository;
|
import ru.ldeloff.servermonitorbot.repository.SshRepository;
|
||||||
@@ -19,14 +18,11 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SshServiceImpl implements SshService {
|
public class SshServiceImpl implements SshService {
|
||||||
final SshRepository sshRepository;
|
final SshRepository sshRepository;
|
||||||
@Override
|
@Override
|
||||||
public SendMessage getStatusSessions(Update update) {
|
public SendMessage getStatusSessions(SendMessage message) {
|
||||||
SendMessage message = new SendMessage();
|
|
||||||
long chatId = update.getMessage().getChatId();
|
|
||||||
message.setText(sshRepository.getStatusSessions());
|
message.setText(sshRepository.getStatusSessions());
|
||||||
message.setChatId(chatId);
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package ru.ldeloff.servermonitorbot.service.uname;
|
|
||||||
|
|
||||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
|
||||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
|
||||||
|
|
||||||
public interface UnameService {
|
|
||||||
SendMessage sendUnameAggregate(Update update);
|
|
||||||
|
|
||||||
SendMessage uname(Update update);
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,9 @@ import java.util.ArrayList;
|
|||||||
public class TelegramBotKeyboard implements UiFormer {
|
public class TelegramBotKeyboard implements UiFormer {
|
||||||
private final String STATUS = "Статус";
|
private final String STATUS = "Статус";
|
||||||
private final String UNAME = "uname";
|
private final String UNAME = "uname";
|
||||||
|
private final String CPU_TEMP = "CPU.temp";
|
||||||
|
private final String HDD_TEMP = "HDD.temp";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessage uiForm(SendMessage message) {
|
public SendMessage uiForm(SendMessage message) {
|
||||||
@@ -27,6 +30,8 @@ public class TelegramBotKeyboard implements UiFormer {
|
|||||||
|
|
||||||
keyboardRow.add(new KeyboardButton(STATUS));
|
keyboardRow.add(new KeyboardButton(STATUS));
|
||||||
keyboardRow.add(new KeyboardButton(UNAME));
|
keyboardRow.add(new KeyboardButton(UNAME));
|
||||||
|
keyboardRow.add(new KeyboardButton(CPU_TEMP));
|
||||||
|
keyboardRow.add(new KeyboardButton(HDD_TEMP));
|
||||||
|
|
||||||
replyKeyboardMarkup.setKeyboard(keyboardRows);
|
replyKeyboardMarkup.setKeyboard(keyboardRows);
|
||||||
message.setReplyMarkup(replyKeyboardMarkup);
|
message.setReplyMarkup(replyKeyboardMarkup);
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package ru.ldeloff.servermonitorbot.utils.ui.uname;
|
package ru.ldeloff.servermonitorbot.utils.ui.uname;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
||||||
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKeyboardButton;
|
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKeyboardButton;
|
||||||
import ru.ldeloff.servermonitorbot.repository.SshRepository;
|
|
||||||
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
|
||||||
import ru.ldeloff.servermonitorbot.utils.ui.UiFormer;
|
import ru.ldeloff.servermonitorbot.utils.ui.UiFormer;
|
||||||
|
|
||||||
@@ -16,7 +14,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class UnameChatButtonAggregate implements UiFormer {
|
public class ServerListButtons implements UiFormer {
|
||||||
|
|
||||||
private final SshService sshService;
|
private final SshService sshService;
|
||||||
|
|
||||||
@@ -32,7 +30,7 @@ public class UnameChatButtonAggregate implements UiFormer {
|
|||||||
List<InlineKeyboardButton> keyboardRow = new ArrayList<>();
|
List<InlineKeyboardButton> keyboardRow = new ArrayList<>();
|
||||||
InlineKeyboardButton inlineKeyboardButton = new InlineKeyboardButton();
|
InlineKeyboardButton inlineKeyboardButton = new InlineKeyboardButton();
|
||||||
inlineKeyboardButton.setText(sshServer.getName());
|
inlineKeyboardButton.setText(sshServer.getName());
|
||||||
inlineKeyboardButton.setCallbackData("uname: " + sshServer.getName());
|
inlineKeyboardButton.setCallbackData(message.getText() + ": " + sshServer.getName());
|
||||||
keyboardRow.add(inlineKeyboardButton);
|
keyboardRow.add(inlineKeyboardButton);
|
||||||
keyboard.add(keyboardRow);
|
keyboard.add(keyboardRow);
|
||||||
}
|
}
|
||||||
@@ -43,14 +41,14 @@ public class UnameChatButtonAggregate implements UiFormer {
|
|||||||
List<InlineKeyboardButton> keyboardRow = new ArrayList<>();
|
List<InlineKeyboardButton> keyboardRow = new ArrayList<>();
|
||||||
InlineKeyboardButton inlineKeyboardButton = new InlineKeyboardButton();
|
InlineKeyboardButton inlineKeyboardButton = new InlineKeyboardButton();
|
||||||
inlineKeyboardButton.setText("Все сервера");
|
inlineKeyboardButton.setText("Все сервера");
|
||||||
inlineKeyboardButton.setCallbackData("uname: all");
|
inlineKeyboardButton.setCallbackData(message.getText() + ": all");
|
||||||
keyboardRow.add(inlineKeyboardButton);
|
keyboardRow.add(inlineKeyboardButton);
|
||||||
keyboard.add(keyboardRow);
|
keyboard.add(keyboardRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
inlineKeyboardMarkup.setKeyboard(keyboard);
|
inlineKeyboardMarkup.setKeyboard(keyboard);
|
||||||
message.setReplyMarkup(inlineKeyboardMarkup);
|
message.setReplyMarkup(inlineKeyboardMarkup);
|
||||||
message.setText("Выполнить uname для");
|
message.setText("Выполнить " + message.getText() + " для");
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@@ -2,20 +2,14 @@ spring:
|
|||||||
application:
|
application:
|
||||||
name: ServerMonitorBot
|
name: ServerMonitorBot
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:postgresql://localhost:5432/servermonitorbot
|
url: jdbc:postgresql://db:5432/servermonitorbot
|
||||||
username: servermonitorbot
|
username: servermonitorbot
|
||||||
password: servermonitorbot
|
password: servermonitorbot
|
||||||
jpa:
|
jpa:
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: none
|
ddl-auto: none
|
||||||
liquibase:
|
flyway:
|
||||||
enabled: true
|
locations: classpath:db/migration
|
||||||
change-log: classpath:db/scripts/changelog-master.xml
|
|
||||||
url: jdbc:postgresql://localhost:5432/servermonitorbot
|
|
||||||
user: servermonitorbot
|
|
||||||
password: servermonitorbot
|
|
||||||
liquibase-schema: "liquibase"
|
|
||||||
default-schema: "servermonitorbot"
|
|
||||||
bot:
|
bot:
|
||||||
name: "ServerMonitorBot"
|
name: "ServerMonitorBot"
|
||||||
token: "token"
|
token: "token"
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
--liquibase formatted sql
|
|
||||||
|
|
||||||
--changeset L_DelOff:create_table_users rollbackSplitStatements:true
|
--changeset L_DelOff:create_table_users rollbackSplitStatements:true
|
||||||
--comment: Создание таблицы пользователей
|
--comment: Создание таблицы пользователей
|
||||||
CREATE TABLE users
|
CREATE TABLE users
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
--liquibase formatted sql
|
|
||||||
|
|
||||||
--changeset L_DelOff:create_table_roles rollbackSplitStatements:true
|
--changeset L_DelOff:create_table_roles rollbackSplitStatements:true
|
||||||
--comment: Создание таблицы ролей
|
--comment: Создание таблицы ролей
|
||||||
CREATE TABLE roles
|
CREATE TABLE roles
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<databaseChangeLog
|
|
||||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
|
||||||
|
|
||||||
<include file="release_0_0_1/changelog.xml" relativeToChangelogFile="true"/>
|
|
||||||
|
|
||||||
|
|
||||||
</databaseChangeLog>
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<databaseChangeLog
|
|
||||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
|
||||||
|
|
||||||
<include file="scripts/01_create_table_users.sql" relativeToChangelogFile="true"/>
|
|
||||||
<include file="scripts/02_create_table_roles.sql" relativeToChangelogFile="true"/>
|
|
||||||
<include file="scripts/03_add_FK_users_to_roles.sql" relativeToChangelogFile="true"/>
|
|
||||||
<include file="scripts/04_add_roles.sql" relativeToChangelogFile="true"/>
|
|
||||||
<include file="scripts/05_add_anonymous_role.sql" relativeToChangelogFile="true"/>
|
|
||||||
<include file="scripts/06_refactor_users_table.sql" relativeToChangelogFile="true"/>
|
|
||||||
<include file="scripts/07_refactor_roles_table.sql" relativeToChangelogFile="true"/>
|
|
||||||
<include file="scripts/08_add_roles.sql" relativeToChangelogFile="true"/>
|
|
||||||
|
|
||||||
</databaseChangeLog>
|
|
||||||
Reference in New Issue
Block a user