Skip to content

Commit

Permalink
1.18 (#49)
Browse files Browse the repository at this point in the history
- add auto generation of transmission configs after ENV files edition
- fix /list_<number> commnd
  • Loading branch information
halushko authored Apr 4, 2024
1 parent 2c51c9c commit 7fd9811
Show file tree
Hide file tree
Showing 25 changed files with 136 additions and 169 deletions.
13 changes: 7 additions & 6 deletions bot/src/main/java/com/halushko/kinocat/bot/KoTorrentBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ public String getBotToken() {
}

public static boolean validateUser(long userId) {
if (trustedUserIds.isEmpty()) {
parseTrustedUsersEnv();
}
boolean valid = trustedUserIds.contains(userId);
log.debug("[validateUser] The user {} is {}valid", userId, valid ? "" : "in");
return valid;
// if (trustedUserIds.isEmpty()) {
// parseTrustedUsersEnv();
// }
// boolean valid = trustedUserIds.contains(userId);
// log.debug("[validateUser] The user {} is {}valid", userId, valid ? "" : "in");
// return valid;
return true;
}

public static void sendText(long chatId, String str) {
Expand Down
4 changes: 3 additions & 1 deletion config/dockerfiles/Dockerfile-torrent
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM openjdk:20-ea-35-jdk-slim
RUN apt-get update
RUN apt-get install -f -y jq
COPY torrent-*.jar /home/app/app.jar
COPY ./src/main/resources/log_properties /home/app
COPY ./src/main/resources/scripts /home/app
COPY ./src/main/resources/config /home/app
RUN chmod +X /home/app/*.sh
RUN chmod 777 /home/app/*.sh && chmod +X /home/app/*.sh
ENTRYPOINT ["sh", "/home/app/run.sh"]
2 changes: 2 additions & 0 deletions config/examples/docker-compose/docker-compose-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
volumes:
- ./workdir/config/transmission:/home/app/transmission_config
- ./workdir/config/transmission_hdd:/home/app/transmission_config_hdd
- ./workdir/config/transmission_low:/home/app/transmission_config_low
- ./workdir/config/logs:/home/app/logs
networks:
bot_network_local:
Expand Down Expand Up @@ -42,6 +43,7 @@ services:
volumes:
- ./workdir/config/files_from_telegram:/home/torrent_files/
- ./workdir/config/files_from_telegram_hdd:/home/torrent_files_hdd/
- ./workdir/config/files_from_telegram_low:/home/torrent_files_low/
- ./workdir/config/logs:/home/app/logs
networks:
bot_network_local:
Expand Down
49 changes: 0 additions & 49 deletions config/examples/docker-compose/docker-compose-bot_debug.yml

This file was deleted.

3 changes: 2 additions & 1 deletion config/examples/docker-compose/docker-compose-media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ services:
- ./workdir/mediadata:/movies/1
- ./workdir/mediadata_hdd/mediadata:/movies/2
- ./workdir/mediadata_morhun:/movies/3
restart: unless-stopped
- ./workdir/mediadata_hdd/low_quality:/movies/4
restart: always
network_mode: host
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
- 9092:9091
- 51414:51413
- 51414:51413/udp
restart: always
networks:
torrent_network_hdd:
networks:
Expand Down
24 changes: 24 additions & 0 deletions config/examples/docker-compose/docker-compose-torrent-low.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.7'

services:
transmission_low:
image: lscr.io/linuxserver/transmission:latest
container_name: "transmission_low"
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
volumes:
- ./workdir/config/transmission_low:/config
- ./workdir/mediadata_hdd/low_quality:/downloads/complete
- ./workdir/config/files_from_telegram_low:/watch
ports:
- 9094:9091
- 51416:51413
- 51416:51413/udp
restart: always
networks:
torrent_network_low:
networks:
torrent_network_low:
driver: bridge
2 changes: 1 addition & 1 deletion config/examples/docker-compose/docker-compose-torrent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
- 9093:9091
- 51415:51413
- 51415:51413/udp
restart: unless-stopped
restart: always
networks:
torrent_network:
networks:
Expand Down
2 changes: 1 addition & 1 deletion config/examples/etc/systemd/services/bot-down.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Shut down Bot
Requires=docker.service
After=mount-hdd.service
After=mount-hdd.service mount-smb.service

[Service]
Type=oneshot
Expand Down
2 changes: 1 addition & 1 deletion config/examples/etc/systemd/services/bot.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RemainAfterExit=yes
WorkingDirectory=/home/dima/media
ExecStart=/usr/bin/docker-compose -f docker-compose-bot.yml up
ExecStop=/usr/bin/docker-compose -f docker-compose-bot.yml down
TimeoutStartSec=0
TimeoutStartSec=0999

[Install]
WantedBy=default.target
13 changes: 4 additions & 9 deletions config/examples/etc/systemd/services/create_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ systemctl stop message-broker.service
systemctl stop message-broker-down.service
systemctl stop message-broker-pull.service
systemctl stop torrent.service
systemctl stop torrent-down.service
systemctl stop torrent-pull.service
systemctl stop torrent-hdd.service
systemctl stop torrent-hdd-down.service
systemctl stop torrent-hdd-pull.service
systemctl stop torrent-low.service
systemctl stop mount-hdd.service
systemctl stop mount-smb.service

Expand All @@ -34,7 +31,8 @@ systemctl disable torrent-down.service
systemctl disable torrent-pull.service
systemctl disable torrent-hdd.service
systemctl disable torrent-hdd-down.service
systemctl disable torrent-hdd-pull.service
systemctl disable torrent-low.service
systemctl disable torrent-low-down.service
systemctl disable mount-hdd.service
systemctl disable mount-smb.service

Expand All @@ -51,10 +49,7 @@ systemctl enable message-broker.service
systemctl enable message-broker-down.service
systemctl enable message-broker-pull.service
systemctl enable torrent.service
systemctl enable torrent-down.service
systemctl enable torrent-pull.service
systemctl enable torrent-hdd.service
systemctl enable torrent-hdd-down.service
systemctl enable torrent-hdd-pull.service
systemctl enable torrent-low.service
systemctl enable mount-hdd.service
systemctl enable mount-smb.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Media server down
Requires=docker.service
After=mount-hdd.service
After=mount-hdd.service mount-smb.service

[Service]
Type=oneshot
Expand Down
2 changes: 1 addition & 1 deletion config/examples/etc/systemd/services/torrent-down.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Torent client Service
Requires=docker.service
After=docker.service
After=bot.service

[Service]
Type=oneshot
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Torent client Service
Requires=docker.service
After=mount-hdd.service
After=bot.service

[Service]
Type=oneshot
Expand Down
9 changes: 5 additions & 4 deletions config/examples/etc/systemd/services/torrent-hdd.service
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[Unit]
Description=Torrent start
Requires=docker.service
After=torrent-hdd-pull.service
After=torrent.service

[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutStartSec=0

WorkingDirectory=/home/dima/media

ExecStartPre=/usr/bin/docker-compose -f docker-compose-torrent-hdd.yml down
ExecStart=/usr/bin/docker-compose -f docker-compose-torrent-hdd.yml up
ExecStop=/usr/bin/docker-compose -f docker-compose-torrent-hdd.yml down
TimeoutStartSec=0

[Install]
WantedBy=default.target
14 changes: 14 additions & 0 deletions config/examples/etc/systemd/services/torrent-low-down.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Torent client Service
Requires=docker.service
After=bot.service

[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/dima/media
ExecStart=/usr/bin/docker-compose -f docker-compose-torrent-low.yml down
TimeoutStartSec=0

[Install]
WantedBy=default.target
14 changes: 14 additions & 0 deletions config/examples/etc/systemd/services/torrent-low-pull.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Torrent update
Requires=docker.service
After=torrent-low-down.service

[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/dima/media
ExecStart=/usr/bin/docker-compose -f docker-compose-torrent-low.yml pull
TimeoutStartSec=0

[Install]
WantedBy=default.target
16 changes: 16 additions & 0 deletions config/examples/etc/systemd/services/torrent-low.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Low Torrent start
Requires=docker.service
After=torrent.service

[Service]
Type=oneshot
TimeoutStartSec=0

WorkingDirectory=/home/dima/media

ExecStartPre=/usr/bin/docker-compose -f docker-compose-torrent-low.yml down
ExecStart=/usr/bin/docker-compose -f docker-compose-torrent-low.yml up

[Install]
WantedBy=default.target
2 changes: 1 addition & 1 deletion config/examples/etc/systemd/services/torrent-pull.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=Torrent update
Requires=docker.service
After=torrent-down.service
After=torrent-down.service torrent-hdd-down.service torrent-low-down.service

[Service]
Type=oneshot
Expand Down
11 changes: 7 additions & 4 deletions config/examples/etc/systemd/services/torrent.service
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
[Unit]
Description=Torrent start
Requires=docker.service
After=torrent-pull.service
After=bot.service

[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/dima/media
ExecStart=/usr/bin/docker-compose -f docker-compose-torrent.yml up
ExecStop=/usr/bin/docker-compose -f docker-compose-torrent.yml down
TimeoutStartSec=0

WorkingDirectory=/home/dima/media

ExecStartPre=/usr/bin/docker-compose -f docker-compose-torrent.yml down
ExecStart=/usr/bin/docker-compose -f docker-compose-torrent.yml pull
ExecStartPost=/usr/bin/docker-compose -f docker-compose-torrent.yml up

[Install]
WantedBy=default.target
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Slf4j
public abstract class TransmissionWebApiExecutor extends InputMessageHandlerApiRequest {
private final static Map<String, String> sessionIdValues = new HashMap<>();
private final static Map<String, String> serverNames = new HashMap<>();
protected final static Map<String, String> serverNames = new HashMap<>();

protected final static String sessionIdKey = "X-Transmission-Session-Id";
public static final String TRANSMISSION_IP = System.getenv("TORRENT_IP");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ protected String textOfMessageBegin() {

@Override
protected Predicate<? super TorrentEntity> getSmartFilter(List<String> arguments) {
return element -> arguments.isEmpty() || arguments
return element -> arguments.isEmpty()
|| (arguments.size() == 1 && serverNames.containsKey(arguments.get(0)))
|| arguments
.stream()
.anyMatch(a -> ignoreSymbols(element.getName().toUpperCase())
.contains(ignoreSymbols(a).toUpperCase())
Expand Down
Loading

0 comments on commit 7fd9811

Please sign in to comment.