Skip to content

Commit

Permalink
Add more then 2 storages
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Galushko committed Mar 23, 2024
1 parent 94261ed commit 68afdda
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 18 deletions.
1 change: 1 addition & 0 deletions 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
- ./workdir/mediadata_hdd/low_quality:/movies/4
restart: unless-stopped
network_mode: host
23 changes: 23 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,23 @@
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
networks:
torrent_network_low:
networks:
torrent_network_low:
driver: bridge
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
9 changes: 9 additions & 0 deletions config/examples/etc/systemd/services/create_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ 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 torrent-low-down.service
systemctl stop torrent-low-pull.service
systemctl stop mount-hdd.service
systemctl stop mount-smb.service

Expand All @@ -35,6 +38,9 @@ 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 torrent-low-pull.service
systemctl disable mount-hdd.service
systemctl disable mount-smb.service

Expand All @@ -56,5 +62,8 @@ 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 torrent-low-down.service
systemctl enable torrent-low-pull.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
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=mount-hdd.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
15 changes: 15 additions & 0 deletions config/examples/etc/systemd/services/torrent-low.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Torrent start
Requires=docker.service
After=torrent-low-pull.service

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

[Install]
WantedBy=default.target
37 changes: 21 additions & 16 deletions torrent/src/main/resources/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
#!/bin/bash

mkdir -p /home/app/transmission_config
if [ -e /home/app/transmission_config/.settings.lock ]; then
echo "The transmission service was already configured by this service"
else
cp /home/app/settings.json /home/app/transmission_config/settings.json
echo "The transmission service configured by this service"
echo "The transmission service configured by this service" > /home/app/transmission_config/.settings.lock
fi
TORRENT_IP_ARRAY=$(echo $TORRENT_IP | jq -r '.[]')

mkdir -p /home/app/transmission_config_hdd
if [ -e /home/app/transmission_config_hdd/.settings.lock ]; then
echo "The transmission hdd service was already configured by this service"
else
cp /home/app/settings.json /home/app/transmission_config_hdd/settings.json
echo "The transmission hdd service configured by this service"
echo "The transmission hdd service configured by this service" > /home/app/transmission_config_hdd/.settings.lock
fi
for ITEM in $TORRENT_IP_ARRAY
do
NAME=$(echo $ITEM | jq -r '.name // empty')

if [ -n "$NAME" ]; then
CONFIG_PATH="/home/app/transmission_config_$NAME"
else
CONFIG_PATH="/home/app/transmission_config"
fi

mkdir -p $CONFIG_PATH

if [ -e $CONFIG_PATH/.settings.lock ]; then
echo "The transmission service was already configured by this service"
else
cp /home/app/settings.json $CONFIG_PATH/settings.json
echo "The transmission service configured by this service"
echo "The transmission service configured by this service" > $CONFIG_PATH/.settings.lock
fi
done

java -Dlog4j.configuration=file:/home/app/log4j-${LOGS_LEVEL}.properties -jar /home/app/app.jar

0 comments on commit 68afdda

Please sign in to comment.