This commit is contained in:
Luctia
2022-08-10 22:44:35 +02:00
parent 13d1e70a28
commit 041957bebe
4 changed files with 145 additions and 208 deletions

View File

@@ -2,25 +2,18 @@ class ContainerConfig:
def __init__(self, def __init__(self,
root_dir, root_dir,
timezone, timezone,
config_dir=None,
plex_claim='', plex_claim='',
movie_dir=None,
tv_dir=None,
music_dir=None,
book_dir=None,
comic_dir=None,
torrent_dir=None
): ):
self.root_dir = root_dir self.root_dir = root_dir
self.timezone = timezone self.timezone = timezone
self.config_dir = config_dir if config_dir is not None else root_dir + '/config' self.config_dir = root_dir + '/config'
self.plex_claim = plex_claim self.plex_claim = plex_claim
self.movie_dir = movie_dir if movie_dir is not None else root_dir + '/media/movies' self.movie_dir = root_dir + '/media/movies'
self.tv_dir = tv_dir if tv_dir is not None else root_dir + '/media/tv' self.tv_dir = root_dir + '/media/tv'
self.music_dir = music_dir if music_dir is not None else root_dir + '/media/music' self.music_dir = root_dir + '/media/music'
self.book_dir = book_dir if book_dir is not None else root_dir + '/media/books' self.book_dir = root_dir + '/media/books'
self.comic_dir = comic_dir if comic_dir is not None else root_dir + '/media/comics' self.comic_dir = root_dir + '/media/comics'
self.torrent_dir = torrent_dir if torrent_dir is not None else root_dir + '/torrents' self.torrent_dir = root_dir + '/data/torrents'
def plex(self): def plex(self):
return ( return (
@@ -36,7 +29,7 @@ class ContainerConfig:
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/plex-config:/config\n' ' - ' + self.config_dir + '/plex-config:/config\n'
' - ' + self.root_dir + '/data/media:/media\n' ' - ' + self.root_dir + '/data/media:/media\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
) )
def tautulli(self): def tautulli(self):
@@ -53,8 +46,8 @@ class ContainerConfig:
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/tautulli-config:/config\n' ' - ' + self.config_dir + '/tautulli-config:/config\n'
' ports:\n' ' ports:\n'
' - 8181:8181\n' ' - "8181:8181"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
) )
def jellyfin(self): def jellyfin(self):
@@ -69,28 +62,10 @@ class ContainerConfig:
' - TZ=' + self.timezone + '\n' ' - TZ=' + self.timezone + '\n'
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/jellyfin-config:/config\n' ' - ' + self.config_dir + '/jellyfin-config:/config\n'
' - ${ROOT_DIR}/data/media:/data\n' ' - ' + self.root_dir + '/data/media:/data\n'
' ports:\n' ' ports:\n'
' - 8096:8096\n' ' - "8096:8096"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
)
def radarr(self):
return (
' radarr:\n'
' image: lscr.io/linuxserver/radarr:latest\n'
' container_name: radarr\n'
' environment:\n'
' - PUID=13002\n'
' - PGID=13000\n'
' - UMASK=002\n'
' - TZ=' + self.timezone + '\n'
' volumes:\n'
' - ' + self.config_dir + '/radarr-config:/config\n'
' - ${ROOT_DIR}/data:/data\n'
' ports:\n'
' - 7878:7878\n'
' restart: unless-stopped\n'
) )
def sonarr(self): def sonarr(self):
@@ -105,10 +80,28 @@ class ContainerConfig:
' - TZ=' + self.timezone + '\n' ' - TZ=' + self.timezone + '\n'
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/sonarr-config:/config\n' ' - ' + self.config_dir + '/sonarr-config:/config\n'
' - ${ROOT_DIR}/data:/data\n' ' - ' + self.root_dir + '/data:/data\n'
' ports:\n' ' ports:\n'
' - 8989:8989\n' ' - "8989:8989"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
)
def radarr(self):
return (
' radarr:\n'
' image: lscr.io/linuxserver/radarr:latest\n'
' container_name: radarr\n'
' environment:\n'
' - PUID=13002\n'
' - PGID=13000\n'
' - UMASK=002\n'
' - TZ=' + self.timezone + '\n'
' volumes:\n'
' - ' + self.config_dir + '/radarr-config:/config\n'
' - ' + self.root_dir + '/data:/data\n'
' ports:\n'
' - "7878:7878"\n'
' restart: unless-stopped\n\n'
) )
def lidarr(self): def lidarr(self):
@@ -123,10 +116,10 @@ class ContainerConfig:
' - TZ=' + self.timezone + '\n' ' - TZ=' + self.timezone + '\n'
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/lidarr-config:/config\n' ' - ' + self.config_dir + '/lidarr-config:/config\n'
' - ${ROOT_DIR}/data:/data\n' ' - ' + self.root_dir + '/data:/data\n'
' ports:\n' ' ports:\n'
' - 8686:8686\n' ' - "8686:8686"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
) )
def readarr(self): def readarr(self):
@@ -141,10 +134,10 @@ class ContainerConfig:
' - TZ=' + self.timezone + '\n' ' - TZ=' + self.timezone + '\n'
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/readarr-config:/config\n' ' - ' + self.config_dir + '/readarr-config:/config\n'
' - ${ROOT_DIR}/data:/data\n' ' - ' + self.root_dir + '/data:/data\n'
' ports:\n' ' ports:\n'
' - 8787:8787\n' ' - "8787:8787"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
) )
def mylar3(self): def mylar3(self):
@@ -158,10 +151,10 @@ class ContainerConfig:
' - UMASK=002\n' ' - UMASK=002\n'
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/mylar-config:/config\n' ' - ' + self.config_dir + '/mylar-config:/config\n'
' - ${ROOT_DIR}/data:/data\n' ' - ' + self.root_dir + '/data:/data\n'
' ports:\n' ' ports:\n'
' - 8090:8090\n' ' - "8090:8090"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
) )
def prowlarr(self): def prowlarr(self):
@@ -177,8 +170,8 @@ class ContainerConfig:
' volumes:\n' ' volumes:\n'
' - ' + self.config_dir + '/prowlarr-config:/config\n' ' - ' + self.config_dir + '/prowlarr-config:/config\n'
' ports:\n' ' ports:\n'
' - 9696:9696\n' ' - "9696:9696"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
) )
def qbittorrent(self): def qbittorrent(self):
@@ -196,8 +189,8 @@ class ContainerConfig:
' - ' + self.config_dir + '/qbittorrent-config:/config\n' ' - ' + self.config_dir + '/qbittorrent-config:/config\n'
' - ' + self.torrent_dir + ':/data/torrents\n' ' - ' + self.torrent_dir + ':/data/torrents\n'
' ports:\n' ' ports:\n'
' - 8080:8080\n' ' - "8080:8080"\n'
' - 6881:6881\n' ' - "6881:6881"\n'
' - 6881:6881/udp\n' ' - "6881:6881/udp"\n'
' restart: unless-stopped\n' ' restart: unless-stopped\n\n'
) )

View File

@@ -1,68 +1,6 @@
--- ---
version: "3.1" version: "3.1"
services: services:
plex:
image: lscr.io/linuxserver/plex:latest
container_name: plex
network_mode: host
environment:
- PUID=${UID}
- PGID=13000
- VERSION=docker
- PLEX_CLAIM=${PLEX_CLAIM}
volumes:
- ${ROOT_DIR}/docker/plex-config:/config
- ${ROOT_DIR}/data/media:/data/media
restart: unless-stopped
tautulli:
image: lscr.io/linuxserver/tautulli:latest
container_name: tautulli
depends_on:
- plex
environment:
- PUID=${UID}
- PGID=13000
- TZ=${TIMEZONE}
volumes:
- ${ROOT_DIR}/docker/tautulli-config:/config
ports:
- 8181:8181
restart: unless-stopped
jellyfin:
image: lscr.io/linuxserver/jellyfin:latest
container_name: jellyfin
environment:
- PUID=${UID}
- PGID=13000
- UMASK=002
- TZ=${TIMEZONE}
volumes:
- ${ROOT_DIR}/docker/jellyfin-config:/config
- ${ROOT_DIR}/data/media:/data/media
ports:
- 8096:8096
restart: unless-stopped
#
# SERVARR
#
radarr:
image: lscr.io/linuxserver/radarr:latest
container_name: radarr
environment:
- PUID=13002
- PGID=13000
- UMASK=002
- TZ=${TIMEZONE}
volumes:
- ${ROOT_DIR}/docker/radarr-config:/config
- ${ROOT_DIR}/data:/data
ports:
- 7878:7878
restart: unless-stopped
sonarr: sonarr:
image: lscr.io/linuxserver/sonarr:latest image: lscr.io/linuxserver/sonarr:latest
container_name: sonarr container_name: sonarr
@@ -70,56 +8,27 @@ services:
- PUID=13001 - PUID=13001
- PGID=13000 - PGID=13000
- UMASK=002 - UMASK=002
- TZ=${TIMEZONE} - TZ=Europe/Amsterdam
volumes: volumes:
- ${ROOT_DIR}/docker/sonarr-config:/config - /home/luctia/detering/config/sonarr-config:/config
- ${ROOT_DIR}/data:/data - /home/luctia/detering/data:/data
ports: ports:
- 8989:8989 - "8989:8989"
restart: unless-stopped restart: unless-stopped
lidarr: radarr:
image: lscr.io/linuxserver/lidarr:latest image: lscr.io/linuxserver/radarr:latest
container_name: lidarr container_name: radarr
environment: environment:
- PUID=13003 - PUID=13002
- PGID=13000 - PGID=13000
- UMASK=002 - UMASK=002
- TZ=${TIMEZONE} - TZ=Europe/Amsterdam
volumes: volumes:
- ${ROOT_DIR}/docker/lidarr-config:/config - /home/luctia/detering/config/radarr-config:/config
- ${ROOT_DIR}/data:/data - /home/luctia/detering/data:/data
ports: ports:
- 8686:8686 - "7878:7878"
restart: unless-stopped
readarr:
image: lscr.io/linuxserver/readarr:develop
container_name: readarr
environment:
- PUID=13004
- PGID=13000
- UMASK=002
- TZ=${TIMEZONE}
volumes:
- ${ROOT_DIR}/docker/readarr-config:/config
- ${ROOT_DIR}/data:/data
ports:
- 8787:8787
restart: unless-stopped
mylar3:
image: lscr.io/linuxserver/mylar3:latest
container_name: mylar3
environment:
- PUID=13005
- PGID=13000
- UMASK=002
volumes:
- ${ROOT_DIR}/docker/mylar-config:/config
- ${ROOT_DIR}/data:/data
ports:
- 8090:8090
restart: unless-stopped restart: unless-stopped
prowlarr: prowlarr:
@@ -129,11 +38,26 @@ services:
- PUID=13006 - PUID=13006
- PGID=13000 - PGID=13000
- UMASK=002 - UMASK=002
- TZ=${TIMEZONE} - TZ=Europe/Amsterdam
volumes: volumes:
- ${ROOT_DIR}/docker/prowlarr-config:/config - /home/luctia/detering/config/prowlarr-config:/config
ports: ports:
- 9696:9696 - "9696:9696"
restart: unless-stopped
jellyfin:
image: lscr.io/linuxserver/jellyfin:latest
container_name: jellyfin
environment:
- PUID=${UID}
- PGID=13000
- UMASK=002
- TZ=Europe/Amsterdam
volumes:
- /home/luctia/detering/config/jellyfin-config:/config
- /home/luctia/detering/data/media:/data
ports:
- "8096:8096"
restart: unless-stopped restart: unless-stopped
qbittorrent: qbittorrent:
@@ -143,13 +67,14 @@ services:
- PUID=13007 - PUID=13007
- PGID=13000 - PGID=13000
- UMASK=002 - UMASK=002
- TZ=${TIMEZONE} - TZ=Europe/Amsterdam
- WEBUI_PORT=8080 - WEBUI_PORT=8080
volumes: volumes:
- ${ROOT_DIR}/docker/qbittorrent-config:/config - /home/luctia/detering/config/qbittorrent-config:/config
- ${ROOT_DIR}/data/torrents:/data/torrents - /home/luctia/detering/data/torrents:/data/torrents
ports: ports:
- 8080:8080 - "8080:8080"
- 6881:6881 - "6881:6881"
- 6881:6881/udp - "6881:6881/udp"
restart: unless-stopped restart: unless-stopped

64
main.py
View File

@@ -1,4 +1,5 @@
from container_configs import ContainerConfig from container_configs import ContainerConfig
from users_groups_setup import UserGroupSetup
services_classed = dict() services_classed = dict()
@@ -28,13 +29,14 @@ def take_directory_input():
ans = input() ans = input()
if ans[0] == '/': if ans[0] == '/':
if ans[-1] == '/': if ans[-1] == '/':
return ans[:-2] return ans[:-1]
return ans return ans
print('Please make sure the path is absolute, meaning it starts at the root of your filesystem and starts with "/":', end=' ') print('Please make sure the path is absolute, meaning it starts at the root of your filesystem and starts with "/":', end=' ')
print('Welcome to the EZarr CLI.') print('Welcome to the EZarr CLI.')
print('This CLI will ask you which services you\'d like to use and more.') print('This CLI will ask you which services you\'d like to use and more. If you\'d like more information about a '
'certain service, look in the README.')
print('\n===SERVARR===') print('\n===SERVARR===')
services_classed['servarr'] = [] services_classed['servarr'] = []
@@ -66,7 +68,7 @@ if services_classed['ms'].__contains__('plex'):
print('Use Tautulli? [Y/n]', end=" ") print('Use Tautulli? [Y/n]', end=" ")
take_input('tautulli', 'ms') take_input('tautulli', 'ms')
print('Use Jellyfin? [Y/n]', end=" ") print('Use Jellyfin? [Y/n]', end=" ")
take_input('tautulli', 'ms') take_input('jellyfin', 'ms')
if len(services_classed['ms']) == 0: if len(services_classed['ms']) == 0:
print('Warning: no media servers selected.') print('Warning: no media servers selected.')
@@ -87,41 +89,15 @@ if len(services) == 0:
print('\n===CONFIGURATION===') print('\n===CONFIGURATION===')
print('Please enter your timezone (like "Europe/Amsterdam")', end=' ') print('Please enter your timezone (like "Europe/Amsterdam")', end=' ')
timezone = input() timezone = input()
if len(timezone) == 0:
timezone = 'Europe/Amsterdam'
plex_claim = ''
if services.__contains__('plex'):
print('If you have a PleX claim token, enter it now. Otherwise, just press enter.', end=' ')
plex_claim = input()
root_dir = None print('Where would you like to keep your files?', end=' ')
config_dir = None root_dir = take_directory_input()
plex_claim = None
print('Would you like to place all configuration and media directories in a single root directory? [Y/n]', end=' ')
ans = take_boolean_input()
if ans:
print('Please enter your root directory like "/mediacenter":', end=' ')
root_dir = take_directory_input()
# DONE. CREATE DIRS AND PERMISSIONS
else:
print('Please enter the directory you\'d like to use for configuration files, like /configuration:', end=' ')
config_dir = take_directory_input()
print('Would you like to manually enter directories for all different media types? [y/N]', end=' ')
ans = take_boolean_input(False)
if ans:
# Pain
pass
else:
print('Please enter the directory you\'d like to use as the root of your content directories like "/media":' ,end=' ')
content_root = take_directory_input()
compose = open('docker-compose.yml', 'w') compose = open('docker-compose.yml', 'w')
compose.write( compose.write(
@@ -129,10 +105,18 @@ compose.write(
'version: "3.1"\n' 'version: "3.1"\n'
'services:\n' 'services:\n'
) )
# for service in services:
# container_config = ContainerConfig(config_dir, plex_claim, timezone, root_dir) container_config = ContainerConfig(root_dir, timezone, plex_claim=plex_claim)
# compose.write(getattr(container_config, service)()) permission_setup = UserGroupSetup(root_dir=root_dir)
for service in services:
try:
getattr(permission_setup, service)()
except AttributeError:
pass
compose.write(getattr(container_config, service)())
compose.close() compose.close()
print('Process complete. You can now run "docker compose up -d" to start your containers.') print('Process complete. You can now run "docker compose up -d" to start your containers.')
print('Thank you for using EZarr. If you experience any issues or have feature requests, add them to our issues.') print('Thank you for using EZarr. If you experience any issues or have feature requests, add them to our issues.')
exit(0) exit(0)

35
users_groups_setup.py Normal file
View File

@@ -0,0 +1,35 @@
import os
class UserGroupSetup:
def __init__(self, root_dir='/'):
self.root_dir = root_dir
os.system('sudo groupadd mediacenter -g 13000')
def sonarr(self):
os.system('sudo useradd sonarr -u 13001 && sudo mkdir -pv ' + self.root_dir + 'data/{media,torrents}/tv && sudo mkdir -p ' + self.root_dir + 'docker/sonarr-config')
os.system('sudo usermod -a -G mediacenter sonarr')
def radarr(self):
os.system('sudo useradd radarr -u 13002 && sudo mkdir -pv ' + self.root_dir + 'data/{media,torrents}/movies && sudo mkdir -p ' + self.root_dir + 'docker/radarr-config')
os.system('sudo usermod -a -G mediacenter radarr')
def lidarr(self):
os.system('sudo useradd lidarr -u 13003 && sudo mkdir -pv ' + self.root_dir + 'data/{media,torrents}/music && sudo mkdir -p ' + self.root_dir + 'docker/lidarr-config')
os.system('sudo usermod -a -G mediacenter lidarr')
def readarr(self):
os.system('sudo useradd readarr -u 13004 && sudo mkdir -pv ' + self.root_dir + 'data/{media,torrents}/books && sudo mkdir -p ' + self.root_dir + 'docker/readarr-config')
os.system('sudo usermod -a -G mediacenter readarr')
def mylar3(self):
os.system('sudo useradd mylar -u 13005 && sudo mkdir -pv ' + self.root_dir + 'data/{media,torrents}/comics && sudo mkdir -p ' + self.root_dir + 'docker/mylar-config')
os.system('sudo usermod -a -G mediacenter mylar')
def prowlarr(self):
os.system('sudo useradd prowlarr -u 13006 && sudo mkdir -p ' + self.root_dir + 'docker/prowlarr-config')
os.system('sudo usermod -a -G mediacenter prowlarr')
def qbittorrent(self):
os.system('sudo useradd qbittorrent -u 13007')
os.system('sudo usermod -a -G mediacenter qbittorrent')