101 Commits

Author SHA1 Message Date
23b5f02438 Merge pull request 'feature/task-38-roles' (#39) from feature/task-38-roles into master
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Reviewed-on: #39
2024-01-21 20:17:35 +03:00
a03a6abdfc Отображаются только доступные для роли команды
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2024-01-21 20:16:27 +03:00
0fe1d7e670 Паттерн цепочка с автоподтягиванием классов-команд
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2024-01-21 18:46:56 +03:00
c3711bb571 Рефактор
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2024-01-21 15:38:00 +03:00
39c2d6e6fc Статус теперь пытается реконнект сделать
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2023-12-17 17:20:12 +03:00
21f4a71c63 Уведомление о перезапуске
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2023-12-17 16:41:24 +03:00
25b73feb48 Таймауты на соединение 2023-12-17 15:11:13 +03:00
3a967e399b Авторестарт контейнеров при падении 2023-12-17 14:57:12 +03:00
bebf1b2916 Merge pull request 'fix' (#37) from feature/task-11-mdadm_status into master
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Reviewed-on: #37
2023-11-22 20:49:51 +03:00
62a473000a fix
Some checks are pending
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master Build queued...
2023-11-22 20:48:51 +03:00
b842114bb3 Merge pull request 'fix' (#36) from feature/task-11-mdadm_status into master
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Reviewed-on: #36
2023-11-22 20:43:28 +03:00
187e20ad9d fix
Some checks are pending
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master Build queued...
2023-11-22 20:42:47 +03:00
6545e01f9b Merge pull request 'feature/task-11-mdadm_status' (#35) from feature/task-11-mdadm_status into master
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Reviewed-on: #35
2023-11-22 20:10:07 +03:00
f2a74b9f84 добавил mdadm
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2023-11-22 20:08:23 +03:00
15d6894013 уточнил пример ямлика 2023-11-22 19:11:03 +03:00
5bd78701e9 hotfix
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-22 18:58:53 +03:00
74e5e2b017 hotfix
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-22 18:55:42 +03:00
30772ec123 Merge pull request 'fix' (#33) from feature/task-30-docker into master
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Reviewed-on: #33
2023-11-22 18:51:11 +03:00
c5d7689b97 Удаление старых образов перед деплоем
Some checks are pending
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master Build queued...
2023-11-22 18:50:36 +03:00
5b0decff19 Merge pull request 'Удаление старых образов перед деплоем' (#32) from feature/task-30-docker into master
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Reviewed-on: #32
2023-11-22 18:48:16 +03:00
2bca814b3f Удаление старых образов перед деплоем
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2023-11-22 18:45:22 +03:00
24839dc3fe Merge pull request 'feature/task-30-docker' (#31) from feature/task-30-docker into master
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Reviewed-on: #31
2023-11-22 11:36:39 +03:00
2b8a5f326c убрал лишние шаги
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2023-11-22 11:32:44 +03:00
180e1e6be4 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:21:59 +03:00
1a1fca9325 fix 2023-11-21 23:21:34 +03:00
e416a84bf7 fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:13:21 +03:00
dcd357c6e0 fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:07:59 +03:00
43958b0d7c fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 23:06:14 +03:00
c8ff9725e5 fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:02:25 +03:00
bac9f84092 fix
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:01:20 +03:00
38a989e223 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:59:24 +03:00
2b782867c9 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 22:57:56 +03:00
3a0866dfa4 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:54:57 +03:00
386dceed36 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:52:56 +03:00
5d4370d932 fix 2023-11-21 22:52:17 +03:00
23effc5fe6 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:49:46 +03:00
e259bb0262 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 22:32:46 +03:00
9849a46a40 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:22:40 +03:00
757850aae6 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:16:55 +03:00
431e777988 add application.yml
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 22:15:43 +03:00
8b8833cd2b fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 17:53:32 +03:00
754ae67714 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 14:05:11 +03:00
7d929254dd fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 14:02:48 +03:00
d822059e4e fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 14:00:18 +03:00
0fecaa501b fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 13:59:29 +03:00
034387af16 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 13:57:58 +03:00
07b27cb6de очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:53:25 +03:00
28ec8dcd64 очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:50:35 +03:00
de303fcd8e очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:47:06 +03:00
35a8d6a8c7 очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 13:43:36 +03:00
bf070c29a1 CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:33:21 +03:00
395da1739b CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:28:03 +03:00
34744f93ec CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 22:13:19 +03:00
a20b0c4963 CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 22:07:30 +03:00
94485ab9d2 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 22:02:23 +03:00
204dbc5f73 CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:50:45 +03:00
98bc9633be CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:47:54 +03:00
8bdc56bd8a CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:32:28 +03:00
051e201525 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:30:28 +03:00
b68520ffa4 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:25:10 +03:00
74078b120c CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:22:50 +03:00
94285d88b7 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:20:56 +03:00
008b173b70 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:19:20 +03:00
0ba76e16b2 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:17:34 +03:00
bdb19c81ca CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:06:00 +03:00
d56b5a5617 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:59:34 +03:00
182f850a3b CI/CD fix
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 20:58:23 +03:00
11c0b4f369 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:55:01 +03:00
a6151fb01e CI/CD fix
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 20:53:40 +03:00
3c53ea17a5 CI/CD
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:49:56 +03:00
3b505398e4 build docker stage
All checks were successful
Hedgehog_server/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 20:08:55 +03:00
ead94bea2f build docker stage
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:06:34 +03:00
ecfd0a9ae5 build docker stage
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 19:59:20 +03:00
7a0c2fde66 fix
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 19:54:58 +03:00
56a74a8b49 Добавил стадию теста
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 19:52:32 +03:00
0863650ddc log errors
All checks were successful
Hedgehog_server/ServerMonitorBot/pipeline/head This commit looks good
2023-11-19 22:20:29 +03:00
02a4b5081f log errors
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:16:52 +03:00
9ef9ad18cf fix
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:15:16 +03:00
fd39b88296 fix
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:12:16 +03:00
74f02e7827 Merge remote-tracking branch 'origin/devops' into feature/task-30-docker
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:10:39 +03:00
dc07591612 агент
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:03:19 +03:00
0f9721f562 агент
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:02:30 +03:00
742d246cdb агент
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 21:53:21 +03:00
0ac12deed3 агент
Some checks failed
ServerMonitorBot/test/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 20:45:21 +03:00
9a4652b8f2 агент 2023-11-19 20:40:53 +03:00
edd29ea029 агент 2023-11-19 20:33:11 +03:00
7838e60a82 агент 2023-11-19 20:31:37 +03:00
02a56ee434 агент 2023-11-19 20:29:09 +03:00
d60187cc07 test 2023-11-19 15:10:55 +00:00
6359c59af9 агент 2023-11-19 18:07:57 +03:00
c84e935f05 агент 2023-11-19 17:54:15 +03:00
f9ad7fddbd агент 2023-11-19 17:38:39 +03:00
f011205a22 агент 2023-11-19 17:32:19 +03:00
5920067b02 тестю билд 2023-11-19 14:27:46 +00:00
9e6cba52f6 Коммит от ТУЗ 2023-11-19 14:20:11 +00:00
638dc42a46 KAKASIKI 2023-11-19 14:11:02 +00:00
fd4248d722 KUKUSIKI 2023-11-19 14:07:01 +00:00
b71b4db66e Flyway 2023-11-17 09:29:19 +03:00
9ee1a4de3c Merge pull request 'Добавил кнопку слежения за температурой CPU' (#29) from feature/task-8-CPUtemp into master
Reviewed-on: L_DelOff/ServerMonitorBot#29
2023-08-13 21:01:29 +03:00
c42781c5ee Добавил кнопку слежения за температурой CPU 2023-08-13 21:00:43 +03:00
daf9e9cb06 Merge pull request 'Добавил кнопку слежения за температурой дисков' (#28) from feature/task-10-hddtemp into master
Reviewed-on: L_DelOff/ServerMonitorBot#28
2023-08-13 20:06:53 +03:00
44 changed files with 757 additions and 350 deletions

11
Dockerfile Normal file
View 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"]

71
Jenkinsfile_CD Normal file
View File

@@ -0,0 +1,71 @@
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('Stop container') {
steps {
sh """
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker compose down'
"""
}
}
stage('Remove old image') {
steps {
sh """
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'docker image rm -f ${IMAGE_NAME}-app:${IMAGE_VERSION} || true'
"""
}
}
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('Remove useless images') {
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
View 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'
}
}
}
}

23
docker-compose.yml Normal file
View File

@@ -0,0 +1,23 @@
version: '3'
services:
app:
build:
context: .
depends_on:
- db
restart: always
networks:
default:
db:
image: postgres:latest
environment:
POSTGRES_USER: servermonitorbot
POSTGRES_PASSWORD: servermonitorbot
POSTGRES_DB: servermonitorbot
restart: always
networks:
default:
networks:
default:

49
pom.xml
View File

@@ -15,6 +15,11 @@
<description>ServerMonitorBot</description>
<properties>
<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>
<dependencies>
<dependency>
@@ -40,7 +45,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.7.0</version>
<version>6.8.0</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
@@ -51,14 +56,15 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>
</dependencies>
<build>
@@ -75,6 +81,39 @@
</excludes>
</configuration>
</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>
</build>

View File

@@ -1,77 +1,42 @@
package ru.ldeloff.servermonitorbot.controller;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
import org.telegram.telegrambots.meta.api.objects.Message;
import org.telegram.telegrambots.meta.api.objects.Update;
import ru.ldeloff.servermonitorbot.model.TelegramBot;
import ru.ldeloff.servermonitorbot.repository.SshRepository;
import ru.ldeloff.servermonitorbot.service.command.FirstUseCommand;
import ru.ldeloff.servermonitorbot.service.command.GetStatusSessions;
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
import ru.ldeloff.servermonitorbot.service.command.SwitchToMainMenu;
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;
import java.util.Map;
@Service
@Slf4j
@RequiredArgsConstructor
public class TelegramBotController extends TelegramLongPollingBot {
private final Map<String, CommandTemplate> commands;
final TelegramBot telegramBot;
final SshRepository sshRepository;
final FirstUseCommand firstUseCommand;
final GetStatusSessions getStatusSessions;
final UnameAggregateCommand unameAggregateCommand;
final SwitchToMainMenu switchToMainMenu;
final UnameCommand unameCommand;
final HddTempAggregateCommand hddTempAggregateCommand;
final HddTempCommand hddTempCommand;
@Override
public void onUpdateReceived(Update update) {
if (update.hasMessage()) {
if (update.getMessage().hasText()) {
String messageText = update.getMessage().getText();
switch (messageText) {
case "/start" -> {
firstUseCommand.execute(update, this);
boolean result = false;
for (Map.Entry<String, CommandTemplate> entry : commands.entrySet()) {
result = entry.getValue().execute(update, this);
if (result) {
break;
}
case "Статус" -> {
getStatusSessions.execute(update, this);
}
case "uname" -> {
unameAggregateCommand.execute(update, this);
if (!result) {
Message message = update.getMessage();
if (message!=null) {
message.setText("Not found");
}
case "HDD.temp" -> {
hddTempAggregateCommand.execute(update, this);
}
default -> {
update.setMessage(message);
switchToMainMenu.execute(update, this);
}
}
}
} else if (update.hasCallbackQuery()) {
String [] tags = update.getCallbackQuery().getData().split(":");
if (tags.length > 1) {
switch (tags[0]) {
case "uname" -> {
unameCommand.execute(update, this);
}
case "HDD.temp" -> {
hddTempCommand.execute(update, this);
}
default -> {
switchToMainMenu.execute(update, this);
}
}
} else {
switchToMainMenu.execute(update, this);
}
}
}
@Override
public String getBotUsername() {
return telegramBot.getBotUsername();

View File

@@ -0,0 +1,7 @@
package ru.ldeloff.servermonitorbot.init;
public class AddCommands {
public static void fillCommandTable() {
}
}

View File

@@ -7,30 +7,47 @@ import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
import ru.ldeloff.servermonitorbot.controller.TelegramBotController;
import ru.ldeloff.servermonitorbot.model.User;
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
import ru.ldeloff.servermonitorbot.service.user.UserService;
import ru.ldeloff.servermonitorbot.utils.ui.TelegramBotKeyboard;
import static ru.ldeloff.servermonitorbot.init.AddCommands.fillCommandTable;
@Slf4j
@Component
@NoArgsConstructor
public class StartBot implements ApplicationRunner {
private TelegramBotController telegramBot;
private TelegramBotKeyboard telegramBotKeyboard;
private UserService userService;
@Autowired
public StartBot(TelegramBotController telegramBot) {
public StartBot(TelegramBotController telegramBot, TelegramBotKeyboard telegramBotKeyboard, UserService userService) {
this.telegramBot = telegramBot;
this.telegramBotKeyboard = telegramBotKeyboard;
this.userService = userService;
}
@Override
public void run(ApplicationArguments args) {
try {
fillCommandTable();
TelegramBotsApi botsApi = new TelegramBotsApi(DefaultBotSession.class);
botsApi.registerBot(telegramBot);
userService.getAllUsers().forEach(this::SendInitMessage);
log.info("Бот запущен");
} catch (TelegramApiException e) {
e.printStackTrace();
log.error(e.getMessage());
}
}
private void SendInitMessage(User user) {
SendMessage answer = new SendMessage();
answer.setChatId(user.getTelegramId());
answer.setText("Бот перезапущен");
CommandTemplate.sendMessage(telegramBotKeyboard.uiForm(answer), telegramBot);
}
}

View File

@@ -0,0 +1,28 @@
package ru.ldeloff.servermonitorbot.model;
import jakarta.annotation.PostConstruct;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
import ru.ldeloff.servermonitorbot.utils.CommandUtil;
import java.util.HashMap;
import java.util.Map;
@Component
@RequiredArgsConstructor
public class CommandList {
private final Map<String, CommandTemplate> services;
@Getter
private HashMap<String, Long> commands;
@PostConstruct
private void setCommands() {
commands = new HashMap<>();
for (Map.Entry<String, CommandTemplate> entry : services.entrySet()) {
commands.put(entry.getValue().getName(), entry.getValue().getExpectedRole());
}
CommandUtil.setCommands(commands);
}
}

View File

@@ -7,7 +7,7 @@ import lombok.Setter;
@Getter
@Setter
public class Command {
public class SshCommand {
@NotNull
private String command;
@NotNull
@@ -17,7 +17,7 @@ public class Command {
private SshServer sshServer;
private String response;
public Command(String command, int timeout, SshServer sshServer) {
public SshCommand(String command, int timeout, SshServer sshServer) {
this.command = command;
this.timeout = timeout;
this.sshServer = sshServer;

View File

@@ -5,14 +5,13 @@ import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import ru.ldeloff.servermonitorbot.config.SshConfig;
import ru.ldeloff.servermonitorbot.model.SshServer;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
@Slf4j
@Repository
@@ -20,12 +19,15 @@ public class SshRepositoryImpl implements SshRepository {
private final List<SshServer> sshServers;
@Value("${ssh.timeout:5000}")
private int TIMEOUT;
@Autowired
public SshRepositoryImpl(SshConfig sshConfig) {
this.sshServers = sshConfig.getServers();
}
private List<Session> sessions = new ArrayList<>();
private Set<Session> sessions = new HashSet<>();
@Override
public void connectToAllServer() {
@@ -34,7 +36,6 @@ public class SshRepositoryImpl implements SshRepository {
Session session = connectToServer(sshServer);
sshServer.setSession(session);
log.info("Успешно подключён к " + sshServer.getHost());
sessions.add(session);
} catch (JSchException e) {
log.warn("Не удалось соединиться с " + sshServer.getHost() + ": " + e.getMessage());
}
@@ -48,7 +49,9 @@ public class SshRepositoryImpl implements SshRepository {
sshServer.getPort());
session.setPassword(sshServer.getPassword());
session.setConfig("StrictHostKeyChecking", "no");
session.setTimeout(TIMEOUT);
session.connect();
sessions.add(session);
return session;
}
@@ -62,7 +65,7 @@ public class SshRepositoryImpl implements SshRepository {
@Override
public String getStatusSessions() {
StringBuilder text = new StringBuilder("Статус соединения: \n");
StringBuilder text = new StringBuilder("Статус соединения (может выполняться долго): \n");
sshServers.forEach(server -> {
text.append(server.getName())
.append(": ")
@@ -79,10 +82,27 @@ public class SshRepositoryImpl implements SshRepository {
private String checkStatusServer(SshServer server) {
if (Objects.isNull(server.getSession())) {
try {
connectToServer(server);
return "OK";
} catch (JSchException e) {
log.warn("Не удалось соединиться с " + server.getHost() + ": " + e.getMessage());
return "нет соединения";
}
}
if (server.getSession().isConnected()) {
return "OK";
} else {
return server.getSession().isConnected() ? "OK" : "отключён";
try {
connectToServer(server);
return "OK";
} catch (JSchException e) {
log.warn("Не удалось соединиться с " + server.getHost() + ": " + e.getMessage());
return "потеряно соединение";
}
}
}
}

View File

@@ -1,10 +1,15 @@
package ru.ldeloff.servermonitorbot.repository;
import jakarta.validation.constraints.NotNull;
import org.springframework.data.domain.Example;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import ru.ldeloff.servermonitorbot.model.User;
import java.util.List;
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
User getByTelegramId(long id);
@NotNull List<User> findAll();
}

View File

@@ -1,53 +1,158 @@
package ru.ldeloff.servermonitorbot.service.command;
import lombok.Data;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
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.SshServer;
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;
import ru.ldeloff.servermonitorbot.utils.SshServerUtils;
import ru.ldeloff.servermonitorbot.utils.ui.ServerListButtons;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@Data
@Slf4j
@RequiredArgsConstructor
public abstract class CommandTemplate {
final UserService userService;
final RoleService roleService;
long expectedRole = 2L;
public abstract SendMessage actionForAuth(User user, SendMessage message);
private final UserService userService;
private final RoleService roleService;
private final ServerListButtons serverListButtons;
private final SshService sshService;
@Getter
@Setter
private long expectedRole = 1L;
@Getter
@Setter
private String name;
public SendMessage actionForNotAuth(User user, SendMessage message) {
message.setText("У пользователя " + user.getLogin() + " (" + user.getTelegramId()
+ ") недостаточно прав для выполнения этой команды");
return message;
public boolean execute(Update update, TelegramBotController bot) {
if (!isExecute(update)) {
return false;
}
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 {
if (!isAuth(update)) {
logNotAuth(user, message);
sendMessage(actionForNotAuth(user, answer), bot);
return true;
}
String type = checkTypeCommand(update);
switch (type) {
case "aggregate":
logSuccess(user, message);
sendMessage(executeAggregate(user, answer), bot);
return true;
case "command":
logSuccess(user, message);
sendMessage(executeCommand(user, answer), bot);
return true;
default:
return false;
}
}
protected void logSuccess(User user, String message) {
// Методы для проверки команды
private boolean isExecute(Update update) {
if (update.hasMessage()) {
if (update.getMessage().hasText()) {
String messageText = update.getMessage().getText();
if (Objects.equals(messageText, name)) {
log.debug("Команда " + messageText + " будет выполнена");
return true;
}
}
} else if (update.hasCallbackQuery()) {
String [] tags = update.getCallbackQuery().getData().split(":");
if (tags.length > 1) {
if (Objects.equals(tags[0], name)) {
log.debug("Команда " + tags[0] + " будет выполнена");
return true;
}
} else {
log.debug("Команда не будет выполнена");
return false;
}
}
log.debug("Команда не будет выполнена");
return false;
}
private String checkTypeCommand(Update update) {
if (update.hasMessage()) {
if (update.getMessage().hasText()) {
return "aggregate";
}
} else if (update.hasCallbackQuery()) {
String [] tags = update.getCallbackQuery().getData().split(":");
if (tags.length > 1) {
return "command";
} else {
return "error";
}
}
return "error";
}
private boolean isAuth(Update update) {
User user = getUser(update);
return user.getRole().getId() <= expectedRole;
}
// Методы при верных условиях
void logSuccess(User user, String message) {
log.info("Получена команда '" + message + "' от " + user.getLogin()
+ " (" + user.getTelegramId() + "). OK");
}
protected void logNotAuth(User user, String message) {
SendMessage executeAggregate(User user, SendMessage message) {
return serverListButtons.uiForm(message);
}
SendMessage executeCommand(User user, SendMessage message) {
String [] tags = Arrays.stream(message.getText().split(":"))
.map(String::trim)
.toArray(String[]::new);
if (tags[1].equals("all")) {
message.setText(executeCommandAllHost());
} else {
message.setText(Objects.requireNonNull(executeCommandSpecificHost(tags[1])));
}
return message;
}
private String executeCommandAllHost() {
List<SshServer> servers = SshServerUtils.filterGoodServers(sshService.getSshServers());
StringBuilder response = new StringBuilder();
servers.forEach(server -> response.append(executeCommandSpecificHost(server.getName())).append("\n"));
return response.toString();
}
public abstract String executeCommandSpecificHost(String serverName);
// Методы при неверных условиях
void logNotAuth(User user, String message) {
log.warn("Получена команда '" + message + "' от " + user.getLogin()
+ " (" + user.getTelegramId() + "). Нет прав");
}
private User getUser(Update update) {
private SendMessage actionForNotAuth(User user, SendMessage message) {
message.setText("У пользователя " + user.getLogin() + " (" + user.getTelegramId()
+ ") недостаточно прав для выполнения этой команды");
return message;
}
// Общее
// TODO: вынести в UpdateUtils
User getUser(Update update) {
long id = -1L;
String login = null;
if (update.hasMessage()) {
@@ -66,8 +171,7 @@ public abstract class CommandTemplate {
user.setLogin(login);
return user;
}
private String getMessage(Update update) {
String getMessage(Update update) {
if (update.hasMessage()) {
return update.getMessage().getText();
} else if (update.hasCallbackQuery()) {
@@ -76,7 +180,8 @@ public abstract class CommandTemplate {
return "";
}
private void sendMessage(SendMessage message, TelegramBotController bot) {
// TODO: вынести
public static void sendMessage(SendMessage message, TelegramBotController bot) {
try {
bot.execute(message);
} catch (TelegramApiException e) {

View File

@@ -0,0 +1,43 @@
package ru.ldeloff.servermonitorbot.service.command;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import ru.ldeloff.servermonitorbot.model.SshCommand;
import ru.ldeloff.servermonitorbot.model.SshServer;
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.ui.ServerListButtons;
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, ServerListButtons serverListButtons) {
super(userService, roleService, serverListButtons, sshService);
this.sshService = sshService;
setName("CPU.temp");
}
@Override
public String executeCommandSpecificHost(String serverName) {
Optional<SshServer> server = sshService.getSshServers()
.stream()
.filter(x -> x.getName().equals(serverName))
.findFirst();
if (server.isPresent()) {
SshCommand result = sshService.execute(new SshCommand("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;
}
}
}

View File

@@ -2,22 +2,36 @@ package ru.ldeloff.servermonitorbot.service.command;
import org.springframework.stereotype.Service;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.Update;
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;
import ru.ldeloff.servermonitorbot.utils.ui.ServerListButtons;
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);
public FirstUseCommand(UserService userService,
RoleService roleService,
SshService sshService,
ServerListButtons serverListButtons,
TelegramBotKeyboard telegramBotKeyboard) {
super(userService, roleService, serverListButtons, sshService);
this.telegramBotKeyboard = telegramBotKeyboard;
setName("/start");
}
@Override
public SendMessage actionForAuth(User user, SendMessage message) {
public SendMessage executeAggregate(User user, SendMessage message) {
message.setText("Добро пожаловать " + user.getLogin() + "!");
return telegramBotKeyboard.uiForm(message);
}
@Override
public String executeCommandSpecificHost(String serverName) {
return null;
}
}

View File

@@ -6,18 +6,22 @@ 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;
import ru.ldeloff.servermonitorbot.utils.ui.ServerListButtons;
@Service
public class GetStatusSessions extends CommandTemplate {
final SshService sshService;
public GetStatusSessions(UserService userService, RoleService roleService, SshService sshService) {
super(userService, roleService);
public GetStatusSessions(UserService userService, RoleService roleService, SshService sshService, ServerListButtons serverListButtons) {
super(userService, roleService, serverListButtons, sshService);
this.sshService = sshService;
setName("Статус");
}
@Override
public SendMessage actionForAuth(User user, SendMessage message) {
public SendMessage executeAggregate(User user, SendMessage message) {
return sshService.getStatusSessions(message);
}
@Override
public String executeCommandSpecificHost(String serverName) {
return null;
}
}

View File

@@ -0,0 +1,39 @@
package ru.ldeloff.servermonitorbot.service.command;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import ru.ldeloff.servermonitorbot.model.SshCommand;
import ru.ldeloff.servermonitorbot.model.SshServer;
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.ui.ServerListButtons;
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, ServerListButtons serverListButtons) {
super(userService, roleService, serverListButtons, sshService);
this.sshService = sshService;
setName("HDD.temp");
}
@Override
public String executeCommandSpecificHost(String serverName) {
Optional<SshServer> server = sshService.getSshServers()
.stream()
.filter(x -> x.getName().equals(serverName))
.findFirst();
if (server.isPresent()) {
SshCommand result = sshService.execute(new SshCommand("hddtemp /dev/sd*", 500, server.get()));
return server.get().getName() + ": \n" +
(Objects.isNull(result.getResponse()) ? "ошибка при выполнении команды" : result.getResponse());
} else {
log.error("Ошибка при выполнении команды 'hddtemp'. Искомый сервер (" + serverName + ") не найден");
return null;
}
}
}

View File

@@ -0,0 +1,84 @@
package ru.ldeloff.servermonitorbot.service.command;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import ru.ldeloff.servermonitorbot.model.SshCommand;
import ru.ldeloff.servermonitorbot.model.SshServer;
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.ui.ServerListButtons;
import java.util.*;
@Service
@Slf4j
public class MdadmStatusCommand extends CommandTemplate {
final SshService sshService;
public MdadmStatusCommand(UserService userService, RoleService roleService, SshService sshService, ServerListButtons serverListButtons) {
super(userService, roleService, serverListButtons, sshService);
this.sshService = sshService;
setName("MDADM");
}
@Override
public String executeCommandSpecificHost(String serverName) {
Optional<SshServer> server = sshService.getSshServers()
.stream()
.filter(x -> x.getName().equals(serverName))
.findFirst();
if (server.isPresent()) {
// узнаю скок рейдов
SshCommand sshCommandRaid = sshService.execute(new SshCommand("mdadm --detail --scan", 500, server.get()));
List<String> raidNames = parseRaidNames(sshCommandRaid);
// Для каждого рейда надо выяснить статус
StringBuilder result = new StringBuilder();
raidNames.forEach(raid -> {
result.append(raid).append(":\n");
SshCommand sshCommandHdd = sshService.execute(new SshCommand("mdadm --detail " + raid, 500, server.get()));
List<String> hdds = parseHddState(sshCommandHdd);
hdds.forEach(hdd -> result.append(hdd).append("\n"));
});
return server.get().getName() + ": \n" + result;
} else {
log.error("Ошибка при выполнении команды 'mdadm'. Искомый сервер (" + serverName + ") не найден");
return null;
}
}
private List<String> parseRaidNames(SshCommand result) {
List<String> names = new ArrayList<>();
Arrays.stream(result.getResponse().split("\n"))
.map(line -> line.split(" "))
.filter(lineArray -> lineArray.length >= 2)
.map(lineArray -> lineArray[1])
.forEach(names::add);
return names;
}
private List<String> parseHddState(SshCommand result) {
List<String> names = new ArrayList<>();
names.add("Number Name State");
String[] lines = result.getResponse().split("\n");
boolean foundHeader = false;
for (String line : lines) {
if (!foundHeader) {
if ( line.contains("Number") &&
line.contains("Major") &&
line.contains("Minor") &&
line.contains("RaidDevice") ) {
foundHeader = true;
}
} else {
List<String> elements = Arrays.stream(line.split(" "))
.filter(x -> !Objects.equals(x, "")).toList();
names.add(elements.get(0) + ", "
+ elements.get(6) + ", "
+ elements.get(4) + " "
+ elements.get(5));
}
}
return names;
}
}

View File

@@ -3,9 +3,13 @@ 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 org.telegram.telegrambots.meta.api.objects.Update;
import ru.ldeloff.servermonitorbot.controller.TelegramBotController;
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;
import ru.ldeloff.servermonitorbot.utils.ui.ServerListButtons;
import ru.ldeloff.servermonitorbot.utils.ui.TelegramBotKeyboard;
@Service
@@ -13,23 +17,31 @@ import ru.ldeloff.servermonitorbot.utils.ui.TelegramBotKeyboard;
public class SwitchToMainMenu extends CommandTemplate {
final TelegramBotKeyboard telegramBotKeyboard;
public SwitchToMainMenu(UserService userService, RoleService roleService, TelegramBotKeyboard telegramBotKeyboard) {
super(userService, roleService);
public SwitchToMainMenu(UserService userService,
RoleService roleService,
SshService sshService,
ServerListButtons serverListButtons,
TelegramBotKeyboard telegramBotKeyboard) {
super(userService, roleService, serverListButtons, sshService);
this.telegramBotKeyboard = telegramBotKeyboard;
setName("Not found");
}
@Override
public SendMessage actionForAuth(User user, SendMessage message) {
message.setText("Неверная команда. Попробуем сначала.");
return telegramBotKeyboard.uiForm(message);
public String executeCommandSpecificHost(String serverName) {
return null;
}
@Override
public void logSuccess(User user, String message) {
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() + "). Нет прав");
SendMessage executeAggregate(User user, SendMessage message) {
SendMessage answer = new SendMessage();
answer.setChatId(user.getTelegramId());
answer.setText("Неверная команда. Попробуем сначала.");
return telegramBotKeyboard.uiForm(answer);
}
}

View File

@@ -0,0 +1,39 @@
package ru.ldeloff.servermonitorbot.service.command;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import ru.ldeloff.servermonitorbot.model.SshCommand;
import ru.ldeloff.servermonitorbot.model.SshServer;
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.ui.ServerListButtons;
import java.util.Objects;
import java.util.Optional;
@Service
@Slf4j
public class UnameCommand extends CommandTemplate {
final SshService sshService;
public UnameCommand(UserService userService, RoleService roleService, SshService sshService, ServerListButtons serverListButtons) {
super(userService, roleService, serverListButtons, sshService);
this.sshService = sshService;
setName("uname");
}
@Override
public String executeCommandSpecificHost(String serverName) {
Optional<SshServer> server = sshService.getSshServers()
.stream()
.filter(x -> x.getName().equals(serverName))
.findFirst();
if (server.isPresent()) {
SshCommand result = sshService.execute(new SshCommand("uname -a", 100, server.get()));
return server.get().getName() + ": " +
(Objects.isNull(result.getResponse()) ? "ошибка при выполнении команды" : result.getResponse());
} else {
log.error("Ошибка при выполнении команды 'uname'. Искомый сервер (" + serverName + ") не найден");
return null;
}
}
}

View File

@@ -1,24 +0,0 @@
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);
}
}

View File

@@ -1,64 +0,0 @@
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;
}
}
}

View File

@@ -1,24 +0,0 @@
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);
}
}

View File

@@ -1,63 +0,0 @@
package ru.ldeloff.servermonitorbot.service.command.uname;
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 UnameCommand extends CommandTemplate {
final SshService sshService;
public UnameCommand(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(unameAllHost());
} else {
message.setText(Objects.requireNonNull(unameSpecificHost(tags[1])));
}
return message;
}
private String unameAllHost() {
List<SshServer> servers = SshServerUtils.filterGoodServers(sshService.getSshServers());
StringBuilder response = new StringBuilder();
servers.forEach(server -> response.append(unameSpecificHost(server.getName())).append("\n"));
return response.toString();
}
private String unameSpecificHost(String serverName) {
Optional<SshServer> server = sshService.getSshServers()
.stream()
.filter(x -> x.getName().equals(serverName))
.findFirst();
if (server.isPresent()) {
Command result = sshService.execute(new Command("uname -a", 100, server.get()));
return server.get().getName() + ": " +
(Objects.isNull(result.getResponse()) ? "ошибка при выполнении команды" : result.getResponse());
} else {
log.error("Ошибка при выполнении команды 'uname'. Искомый сервер (" + serverName + ") не найден");
return null;
}
}
}

View File

@@ -2,7 +2,7 @@ package ru.ldeloff.servermonitorbot.service.ssh;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import ru.ldeloff.servermonitorbot.model.Command;
import ru.ldeloff.servermonitorbot.model.SshCommand;
import ru.ldeloff.servermonitorbot.model.SshServer;
import java.util.List;
@@ -11,6 +11,6 @@ public interface SshService {
SendMessage getStatusSessions(SendMessage update);
List<SshServer> getSshServers();
Command execute(Command command);
List<Command> execute(List<Command> commands);
SshCommand execute(SshCommand sshCommand);
List<SshCommand> execute(List<SshCommand> sshCommands);
}

View File

@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
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.SshCommand;
import ru.ldeloff.servermonitorbot.model.SshServer;
import ru.ldeloff.servermonitorbot.repository.SshRepository;
@@ -31,21 +31,21 @@ public class SshServiceImpl implements SshService {
}
@Override
public Command execute(Command command) {
List<Command> commands = new ArrayList<>();
commands.add(command);
return execute(commands).get(0);
public SshCommand execute(SshCommand sshCommand) {
List<SshCommand> sshCommands = new ArrayList<>();
sshCommands.add(sshCommand);
return execute(sshCommands).get(0);
}
@Override
public List<Command> execute(List<Command> commands) {
Session session = commands.get(0).getSshServer().getSession(); // подразумевается, что в листе с командами сервер один и тот же
public List<SshCommand> execute(List<SshCommand> sshCommands) {
Session session = sshCommands.get(0).getSshServer().getSession(); // подразумевается, что в листе с командами сервер один и тот же
ChannelExec channel = null;
try {
channel = (ChannelExec) session.openChannel("exec");
ChannelExec finalChannel = channel;
commands.forEach(command -> {
sshCommands.forEach(command -> {
try {
finalChannel.setCommand(command.getCommand());
ByteArrayOutputStream responseStream = new ByteArrayOutputStream();
@@ -69,6 +69,6 @@ public class SshServiceImpl implements SshService {
channel.disconnect();
}
}
return commands;
return sshCommands;
}
}

View File

@@ -2,8 +2,12 @@ package ru.ldeloff.servermonitorbot.service.user;
import ru.ldeloff.servermonitorbot.model.User;
import java.util.List;
public interface UserService {
User saveOrUpdateUser(User user);
User getByTelegramId(Long id);
List<User> getAllUsers();
}

View File

@@ -6,6 +6,8 @@ import org.springframework.stereotype.Service;
import ru.ldeloff.servermonitorbot.model.User;
import ru.ldeloff.servermonitorbot.repository.UserRepository;
import java.util.List;
@Service
@RequiredArgsConstructor
@Slf4j
@@ -26,4 +28,7 @@ public class UserServiceImpl implements UserService {
public User getByTelegramId(Long id) {
return userRepository.getByTelegramId(id);
}
@Override
public List<User> getAllUsers() {return userRepository.findAll(); }
}

View File

@@ -0,0 +1,15 @@
package ru.ldeloff.servermonitorbot.utils;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.UtilityClass;
import java.util.HashMap;
@UtilityClass
public class CommandUtil {
@Setter
@Getter
private HashMap<String, Long> commands;
}

View File

@@ -0,0 +1,19 @@
package ru.ldeloff.servermonitorbot.utils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import ru.ldeloff.servermonitorbot.model.Role;
import ru.ldeloff.servermonitorbot.model.User;
import ru.ldeloff.servermonitorbot.service.user.UserService;
@RequiredArgsConstructor
@Component
public class RoleChecker {
final UserService userService;
public Role getRole(SendMessage sendMessage) {
String chatId = sendMessage.getChatId();
User user = userService.getByTelegramId(Long.parseLong(chatId));
return user.getRole();
}
}

View File

@@ -1,11 +1,13 @@
package ru.ldeloff.servermonitorbot.utils.ui.uname;
package ru.ldeloff.servermonitorbot.utils.ui;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
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.buttons.InlineKeyboardButton;
import ru.ldeloff.servermonitorbot.model.Role;
import ru.ldeloff.servermonitorbot.service.ssh.SshService;
import ru.ldeloff.servermonitorbot.utils.RoleChecker;
import ru.ldeloff.servermonitorbot.utils.ui.UiFormer;
import java.util.ArrayList;
@@ -21,7 +23,6 @@ public class ServerListButtons implements UiFormer {
@Override
public SendMessage uiForm(SendMessage message) {
List<List<InlineKeyboardButton>> keyboard = new ArrayList<>();
InlineKeyboardMarkup inlineKeyboardMarkup = new InlineKeyboardMarkup();
sshService.getSshServers().forEach(sshServer -> {

View File

@@ -1,37 +1,63 @@
package ru.ldeloff.servermonitorbot.utils.ui;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboardMarkup;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.KeyboardButton;
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.KeyboardRow;
import ru.ldeloff.servermonitorbot.model.CommandList;
import ru.ldeloff.servermonitorbot.model.Role;
import ru.ldeloff.servermonitorbot.service.command.CommandTemplate;
import ru.ldeloff.servermonitorbot.utils.CommandUtil;
import ru.ldeloff.servermonitorbot.utils.RoleChecker;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@Component
@RequiredArgsConstructor
public class TelegramBotKeyboard implements UiFormer {
private final String STATUS = "Статус";
private final String UNAME = "uname";
private final String HDD_TEMP = "HDD.temp";
private final RoleChecker roleChecker;
@Override
public SendMessage uiForm(SendMessage message) {
ReplyKeyboardMarkup replyKeyboardMarkup = new ReplyKeyboardMarkup();
replyKeyboardMarkup.setResizeKeyboard(true);
replyKeyboardMarkup.setOneTimeKeyboard(false);
ArrayList<KeyboardRow> keyboardRows = new ArrayList<>();
KeyboardRow keyboardRow = new KeyboardRow();
keyboardRows.add(keyboardRow);
keyboardRow.add(new KeyboardButton(STATUS));
keyboardRow.add(new KeyboardButton(UNAME));
keyboardRow.add(new KeyboardButton(HDD_TEMP));
ArrayList<KeyboardRow> keyboardRows = formKeyboard(
roleChecker.getRole(message).getId());
replyKeyboardMarkup.setKeyboard(keyboardRows);
message.setReplyMarkup(replyKeyboardMarkup);
return message;
}
private ArrayList<KeyboardRow> formKeyboard(long role) {
HashMap<String, Long> commands = CommandUtil.getCommands();
if (role < 3) {
commands.remove("/start");
commands.remove("Not found");
}
int buttonOnLine = 3;
ArrayList<KeyboardRow> keyboardRows = new ArrayList<>();
KeyboardRow keyboardRow = new KeyboardRow();
for (Map.Entry<String, Long> entry : commands.entrySet()) {
if (role <= entry.getValue()) {
keyboardRow.add(new KeyboardButton(entry.getKey()));
}
if (keyboardRow.size()>=buttonOnLine) {
keyboardRows.add(keyboardRow);
keyboardRow = new KeyboardRow();
}
}
if (keyboardRow.size() > 0) {
keyboardRows.add(keyboardRow);
}
return keyboardRows;
}
}

View File

@@ -2,20 +2,14 @@ spring:
application:
name: ServerMonitorBot
datasource:
url: jdbc:postgresql://localhost:5432/servermonitorbot
url: jdbc:postgresql://db:5432/servermonitorbot
username: servermonitorbot
password: servermonitorbot
jpa:
hibernate:
ddl-auto: none
liquibase:
enabled: true
change-log: classpath:db/scripts/changelog-master.xml
url: jdbc:postgresql://localhost:5432/servermonitorbot
user: servermonitorbot
password: servermonitorbot
liquibase-schema: "liquibase"
default-schema: "servermonitorbot"
flyway:
locations: classpath:db/migration
bot:
name: "ServerMonitorBot"
token: "token"
@@ -23,6 +17,7 @@ bot:
- telegramId: 123456789
role: admin
ssh:
timeout: 5000
servers:
-
name: "Server Name"
@@ -30,6 +25,12 @@ ssh:
port: 22
user: "user"
password: "pass"
-
name: "Server Name 2"
host: "url 2"
port: 22
user: "user 2"
password: "pass 2"

View File

@@ -1,5 +1,3 @@
--liquibase formatted sql
--changeset L_DelOff:create_table_users rollbackSplitStatements:true
--comment: Создание таблицы пользователей
CREATE TABLE users

View File

@@ -1,5 +1,3 @@
--liquibase formatted sql
--changeset L_DelOff:create_table_roles rollbackSplitStatements:true
--comment: Создание таблицы ролей
CREATE TABLE roles

View File

@@ -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>

View File

@@ -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>