Add self hosted deployment files
This commit is contained in:
commit
e07dba4d53
Binary file not shown.
BIN
calibre/John Schember/Quick Start Guide (1)/cover.jpg
Normal file
BIN
calibre/John Schember/Quick Start Guide (1)/cover.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 40 KiB |
19
calibre/John Schember/Quick Start Guide (1)/metadata.opf
Normal file
19
calibre/John Schember/Quick Start Guide (1)/metadata.opf
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uuid_id" version="2.0">
|
||||||
|
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
|
||||||
|
<dc:identifier opf:scheme="calibre" id="calibre_id">1</dc:identifier>
|
||||||
|
<dc:identifier opf:scheme="uuid" id="uuid_id">e087b93d-b430-4933-9d85-15b6224bcc32</dc:identifier>
|
||||||
|
<dc:title>Quick Start Guide</dc:title>
|
||||||
|
<dc:creator opf:file-as="Schember, John" opf:role="aut">John Schember</dc:creator>
|
||||||
|
<dc:contributor opf:file-as="calibre" opf:role="bkp">calibre (4.22.0) [https://calibre-ebook.com]</dc:contributor>
|
||||||
|
<dc:date>0101-01-01T00:00:00+00:00</dc:date>
|
||||||
|
<dc:description>calibre Quick Start Guide</dc:description>
|
||||||
|
<dc:language>eng</dc:language>
|
||||||
|
<meta content="{"John Schember": ""}" name="calibre:author_link_map"/>
|
||||||
|
<meta content="2020-08-11T00:10:44.292109+00:00" name="calibre:timestamp"/>
|
||||||
|
<meta content="Quick Start Guide" name="calibre:title_sort"/>
|
||||||
|
</metadata>
|
||||||
|
<guide>
|
||||||
|
<reference href="cover.jpg" title="Cover" type="cover"/>
|
||||||
|
</guide>
|
||||||
|
</package>
|
BIN
calibre/metadata.db
Normal file
BIN
calibre/metadata.db
Normal file
Binary file not shown.
210
docker-compose.yml
Normal file
210
docker-compose.yml
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
version: '3'
|
||||||
|
|
||||||
|
networks:
|
||||||
|
unifi_network:
|
||||||
|
mayan_network:
|
||||||
|
gitea_network:
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
scanned_files:
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: cifs
|
||||||
|
o: username=defaults,password=defaults,sec=ntlm,vers=1.0,file_mode=0777,dir_mode=0777
|
||||||
|
device: "\\\\192.168.1.146\\MEMORYCARD\\EPSCAN\\001"
|
||||||
|
|
||||||
|
services:
|
||||||
|
nginx:
|
||||||
|
image: staticfloat/nginx-certbot
|
||||||
|
restart: always
|
||||||
|
network_mode: 'host'
|
||||||
|
environment:
|
||||||
|
CERTBOT_EMAIL: rob@taglang.io
|
||||||
|
volumes:
|
||||||
|
- ./nginx.conf.d:/etc/nginx/user.conf.d:ro
|
||||||
|
- /opt/services/letsencrypt:/etc/letsencrypt
|
||||||
|
|
||||||
|
sync_files:
|
||||||
|
build: sync_files
|
||||||
|
image: sync_files:local
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- scanned_files:/source
|
||||||
|
- /opt/services/mayan/scanned_files:/target
|
||||||
|
|
||||||
|
unifi_db:
|
||||||
|
image: mongo:3.4
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- unifi_network
|
||||||
|
volumes:
|
||||||
|
- /opt/services/unifi/db:/data/db
|
||||||
|
|
||||||
|
unifi_controller:
|
||||||
|
image: jacobalberty/unifi:latest
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- unifi_db
|
||||||
|
networks:
|
||||||
|
- unifi_network
|
||||||
|
volumes:
|
||||||
|
- /opt/services/unifi/data:/unifi/data
|
||||||
|
- /opt/services/unifi/log:/unifi/log
|
||||||
|
- /opt/services/unifi/cert:/unifi/cert
|
||||||
|
- /opt/services/unifi/init:/unifi/init.d
|
||||||
|
environment:
|
||||||
|
DB_URI: mongodb://unifi_db/unifi
|
||||||
|
STATDB_URI: mongodb://unifi_db/unifi_stat
|
||||||
|
DB_NAME: unifi
|
||||||
|
ports:
|
||||||
|
- "3478:3478/udp" # STUN
|
||||||
|
- "6789:6789/tcp" # Speed test
|
||||||
|
- "8080:8080/tcp" # Device/ controller comm.
|
||||||
|
- "8443:8443/tcp" # Controller GUI/API as seen in a web browser
|
||||||
|
- "8880:8880/tcp" # HTTP portal redirection
|
||||||
|
- "8843:8843/tcp" # HTTPS portal redirection
|
||||||
|
- "10001:10001/udp" # AP discovery
|
||||||
|
|
||||||
|
unifi_logs:
|
||||||
|
image: bash
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- unifi_controller
|
||||||
|
command: bash -c 'tail -F /unifi/log/*.log'
|
||||||
|
volumes:
|
||||||
|
- /opt/services/unifi/log:/unifi/log
|
||||||
|
|
||||||
|
gitlab:
|
||||||
|
image: 'gitlab/gitlab-ce:latest'
|
||||||
|
restart: always
|
||||||
|
hostname: 'gitlab.taglang.io'
|
||||||
|
environment:
|
||||||
|
GITLAB_OMNIBUS_CONFIG: |
|
||||||
|
external_url 'https://gitlab.taglang.io'
|
||||||
|
nginx['listen_port'] = 80
|
||||||
|
nginx['listen_https'] = false
|
||||||
|
gitlab_rails['gitlab_shell_ssh_port'] = 2224
|
||||||
|
ports:
|
||||||
|
- '8881:80'
|
||||||
|
- '2224:22'
|
||||||
|
volumes:
|
||||||
|
- /opt/services/gitlab/config:/etc/gitlab
|
||||||
|
- /opt/services/gitlab/logs:/var/log/gitlab
|
||||||
|
- /opt/services/gitlab/data:/var/opt/gitlab
|
||||||
|
|
||||||
|
gitea:
|
||||||
|
image: 'gitea/gitea:latest'
|
||||||
|
environment:
|
||||||
|
- USER_UID=1000
|
||||||
|
- USER_GID=1000
|
||||||
|
restart: always
|
||||||
|
networks:
|
||||||
|
- gitea_network
|
||||||
|
volumes:
|
||||||
|
- /opt/services/gitea:/data
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
ports:
|
||||||
|
- '8885:3000'
|
||||||
|
- '2222:22'
|
||||||
|
|
||||||
|
mayan_app:
|
||||||
|
image: mayanedms/mayanedms:3
|
||||||
|
depends_on:
|
||||||
|
- mayan_postgresql
|
||||||
|
- mayan_redis
|
||||||
|
# Enable to use RabbitMQ
|
||||||
|
#- rabbitmq
|
||||||
|
environment: &mayan_env
|
||||||
|
# Enable to use RabbitMQ
|
||||||
|
# MAYAN_CELERY_BROKER_URL: amqp://mayan:mayanrabbitpass@broker:5672/mayan
|
||||||
|
# Disable Redis Broker to use RabbitMQ as Broker
|
||||||
|
MAYAN_CELERY_BROKER_URL: redis://:mayanredispassword@mayan_redis:6379/0
|
||||||
|
MAYAN_CELERY_RESULT_BACKEND: redis://:mayanredispassword@mayan_redis:6379/1
|
||||||
|
MAYAN_DATABASES: "{'default':{'ENGINE':'django.db.backends.postgresql','NAME':'mayan','PASSWORD':'mayandbpass','USER':'mayan','HOST':'mayan_postgresql'}}"
|
||||||
|
networks:
|
||||||
|
- mayan_network
|
||||||
|
ports:
|
||||||
|
- "8882:8000"
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /opt/services/mayan/media:/var/lib/mayan
|
||||||
|
- /opt/services/mayan/scanned_files:/var/lib/mayan/scanned_files
|
||||||
|
|
||||||
|
mayan_postgresql:
|
||||||
|
image: postgres:9.6-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: mayan
|
||||||
|
POSTGRES_PASSWORD: mayandbpass
|
||||||
|
POSTGRES_USER: mayan
|
||||||
|
networks:
|
||||||
|
- mayan_network
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /opt/services/mayan/postgres:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
mayan_redis:
|
||||||
|
image: redis:5.0-alpine
|
||||||
|
command:
|
||||||
|
- redis-server
|
||||||
|
- --databases
|
||||||
|
- "2"
|
||||||
|
- --maxmemory-policy
|
||||||
|
- allkeys-lru
|
||||||
|
- --save
|
||||||
|
- ""
|
||||||
|
- --requirepass mayanredispassword
|
||||||
|
networks:
|
||||||
|
- mayan_network
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /opt/services/mayan/redis:/data
|
||||||
|
|
||||||
|
spotify_jenna:
|
||||||
|
build: spotify
|
||||||
|
image: spotify:local
|
||||||
|
restart: always
|
||||||
|
hostname: Jenna Spotify Server
|
||||||
|
devices:
|
||||||
|
- /dev/snd
|
||||||
|
environment:
|
||||||
|
SPOTIFY_USERNAME: adrian.jenna.c
|
||||||
|
SPOTIFY_PASSWORD: fM,KM_xK'Jn9vvU>
|
||||||
|
|
||||||
|
spotify_rob:
|
||||||
|
build: spotify
|
||||||
|
image: spotify:local
|
||||||
|
restart: always
|
||||||
|
hostname: Rob Spotify Server
|
||||||
|
devices:
|
||||||
|
- /dev/snd
|
||||||
|
environment:
|
||||||
|
SPOTIFY_USERNAME: lasalvavida
|
||||||
|
SPOTIFY_PASSWORD: amethyst1
|
||||||
|
|
||||||
|
calibre_web:
|
||||||
|
image: linuxserver/calibre-web
|
||||||
|
container_name: calibre-web
|
||||||
|
environment:
|
||||||
|
- PUID=1000
|
||||||
|
- PGID=1000
|
||||||
|
- TZ=America/New_York
|
||||||
|
- DOCKER_MODS=linuxserver/calibre-web:calibre
|
||||||
|
ports:
|
||||||
|
- 8883:8083
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /opt/services/calibre/config:/config
|
||||||
|
- /opt/services/calibre/library:/books
|
||||||
|
|
||||||
|
koken:
|
||||||
|
build: koken
|
||||||
|
image: koken:local
|
||||||
|
restart: always
|
||||||
|
hostname: koken.taglang.io
|
||||||
|
ports:
|
||||||
|
- 8884:80
|
||||||
|
volumes:
|
||||||
|
- ./koken/99-custom_overrides.ini:/etc/php5/fpm/conf.d/99-custom_overrides.ini:ro
|
||||||
|
- /opt/services/koken/www:/usr/share/nginx/www
|
||||||
|
- /opt/services/koken/mysql:/var/lib/mysql
|
2
host-setup.sh
Normal file
2
host-setup.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "options snd-hda-intel index=1" > /etc/modprobe.d/alsa.conf
|
2
koken/99-custom_overrides.ini
Normal file
2
koken/99-custom_overrides.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
upload_max_filesize = 2G
|
||||||
|
post_max_size = 2G
|
3
koken/Dockerfile
Normal file
3
koken/Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM koken/koken-lemp:latest
|
||||||
|
|
||||||
|
COPY ./nginx.conf /etc/nginx/nginx.conf
|
90
koken/nginx.conf
Normal file
90
koken/nginx.conf
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
user www-data;
|
||||||
|
worker_processes auto;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
include /etc/nginx/modules-enabled/*.conf;
|
||||||
|
|
||||||
|
events {
|
||||||
|
use epoll;
|
||||||
|
worker_connections 768;
|
||||||
|
# multi_accept on;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
|
||||||
|
##
|
||||||
|
# Basic Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
keepalive_timeout 2;
|
||||||
|
client_max_body_size 2G;
|
||||||
|
port_in_redirect off;
|
||||||
|
types_hash_max_size 2048;
|
||||||
|
# server_tokens off;
|
||||||
|
|
||||||
|
# server_names_hash_bucket_size 64;
|
||||||
|
# server_name_in_redirect off;
|
||||||
|
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
##
|
||||||
|
# SSL Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Logging Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Gzip Settings
|
||||||
|
##
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_disable "msie6";
|
||||||
|
|
||||||
|
# gzip_vary on;
|
||||||
|
# gzip_proxied any;
|
||||||
|
# gzip_comp_level 6;
|
||||||
|
# gzip_buffers 16 8k;
|
||||||
|
# gzip_http_version 1.1;
|
||||||
|
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
|
##
|
||||||
|
# Virtual Host Configs
|
||||||
|
##
|
||||||
|
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
include /etc/nginx/sites-enabled/*;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#mail {
|
||||||
|
# # See sample authentication script at:
|
||||||
|
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
|
||||||
|
#
|
||||||
|
# # auth_http localhost/auth.php;
|
||||||
|
# # pop3_capabilities "TOP" "USER";
|
||||||
|
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
|
||||||
|
#
|
||||||
|
# server {
|
||||||
|
# listen localhost:110;
|
||||||
|
# protocol pop3;
|
||||||
|
# proxy on;
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# server {
|
||||||
|
# listen localhost:143;
|
||||||
|
# protocol imap;
|
||||||
|
# proxy on;
|
||||||
|
# }
|
||||||
|
#}
|
||||||
|
daemon off;
|
1
nginx.conf.d/.htpasswd
Normal file
1
nginx.conf.d/.htpasswd
Normal file
@ -0,0 +1 @@
|
|||||||
|
rob:$apr1$9xyPmEcI$/icPEYJeSik0H1H4J3Im4.
|
84
nginx.conf.d/taglang.io.conf
Normal file
84
nginx.conf.d/taglang.io.conf
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name unifi.taglang.io;
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8880;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
ssl_certificate /etc/letsencrypt/live/unifi.taglang.io/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/unifi.taglang.io/privkey.pem;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name gitlab.taglang.io;
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8881;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
ssl_certificate /etc/letsencrypt/live/gitlab.taglang.io/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/gitlab.taglang.io/privkey.pem;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name mayan.taglang.io;
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8882;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
ssl_certificate /etc/letsencrypt/live/mayan.taglang.io/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/mayan.taglang.io/privkey.pem;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name calibre.taglang.io;
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8883;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
ssl_certificate /etc/letsencrypt/live/calibre.taglang.io/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/calibre.taglang.io/privkey.pem;
|
||||||
|
client_max_body_size 2G;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name koken.taglang.io;
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8884;
|
||||||
|
proxy_redirect off;
|
||||||
|
auth_basic "Restricted";
|
||||||
|
auth_basic_user_file /etc/nginx/user.conf.d/.htpasswd;
|
||||||
|
}
|
||||||
|
location /admin {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8884;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
|
}
|
||||||
|
location ~* \.php$ {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8884;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header X-Forwarded-Proto https;
|
||||||
|
}
|
||||||
|
ssl_certificate /etc/letsencrypt/live/koken.taglang.io/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/koken.taglang.io/privkey.pem;
|
||||||
|
client_max_body_size 2G;
|
||||||
|
}
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name git.taglang.io;
|
||||||
|
location / {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_pass http://localhost:8885;
|
||||||
|
proxy_redirect off;
|
||||||
|
}
|
||||||
|
ssl_certificate /etc/letsencrypt/live/git.taglang.io/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/git.taglang.io/privkey.pem;
|
||||||
|
client_max_body_size 2G;
|
||||||
|
}
|
||||||
|
|
29
spotify/Dockerfile
Normal file
29
spotify/Dockerfile
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
FROM ubuntu
|
||||||
|
|
||||||
|
# Install base dependencies
|
||||||
|
RUN apt-get update && apt-get install -y curl gnupg locales pulseaudio
|
||||||
|
|
||||||
|
# Set the locale/TZ
|
||||||
|
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
|
||||||
|
locale-gen
|
||||||
|
ENV LANG en_US.UTF-8
|
||||||
|
ENV LANGUAGE en_US:en
|
||||||
|
ENV LC_ALL en_US.UTF-8
|
||||||
|
ENV TZ America/New_York
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
RUN apt-get install tzdata
|
||||||
|
|
||||||
|
# Set up the virtual display
|
||||||
|
RUN apt-get install -y xvfb
|
||||||
|
ENV DISPLAY :1
|
||||||
|
|
||||||
|
# Install spotify
|
||||||
|
RUN curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | apt-key add -
|
||||||
|
RUN echo "deb http://repository.spotify.com stable non-free" | tee /etc/apt/sources.list.d/spotify.list
|
||||||
|
RUN apt-get update && apt-get install -y spotify-client
|
||||||
|
|
||||||
|
# Start
|
||||||
|
ADD start.sh /
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
|
CMD ["/start.sh"]
|
4
spotify/start.sh
Normal file
4
spotify/start.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
rm /tmp/.X1-lock
|
||||||
|
Xvfb :1 -screen 0 1024x768x16 & sleep 1
|
||||||
|
spotify --username="${SPOTIFY_USERNAME}" --password="${SPOTIFY_PASSWORD}" --show-console
|
10
sync_files/Dockerfile
Normal file
10
sync_files/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
FROM ubuntu
|
||||||
|
|
||||||
|
# Install base dependencies
|
||||||
|
RUN apt-get update && apt-get install -y python3
|
||||||
|
|
||||||
|
# Start
|
||||||
|
ADD sync_files.py /
|
||||||
|
RUN chmod +x /sync_files.py
|
||||||
|
|
||||||
|
CMD ["python3", "-u", "/sync_files.py"]
|
5
sync_files/start.sh
Normal file
5
sync_files/start.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
rsync --remove-source-files -avz /source/* /target
|
||||||
|
while inotifywait -r -e modify,create,delete,move /source; do
|
||||||
|
rsync --remove-source-files -avz /source/* /target
|
||||||
|
done
|
44
sync_files/sync_files.py
Normal file
44
sync_files/sync_files.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
from shutil import copyfile
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
def is_done_being_written(file_path):
|
||||||
|
file_size_before = os.path.getsize(file_path)
|
||||||
|
print('Size before: ', file_size_before)
|
||||||
|
time.sleep(1) # 1s
|
||||||
|
file_size_after = os.path.getsize(file_path)
|
||||||
|
print('Size after: ', file_size_after)
|
||||||
|
return file_size_before == file_size_after
|
||||||
|
|
||||||
|
def copy(source_file_path):
|
||||||
|
destination_dir = '/target'
|
||||||
|
destination_file_path = os.path.join(destination_dir, str(uuid.uuid4()) + '.pdf')
|
||||||
|
print(source_file_path, ' -> ', destination_file_path)
|
||||||
|
print('Checking if the file is done being written...')
|
||||||
|
while not is_done_being_written(source_file_path):
|
||||||
|
continue
|
||||||
|
print('File is stable, copying...')
|
||||||
|
copyfile(source_file_path, destination_file_path)
|
||||||
|
print('Deleting original...')
|
||||||
|
os.remove(source_file_path)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
source_dir = '/source'
|
||||||
|
for file_name in os.listdir(source_dir):
|
||||||
|
file_path = os.path.join(source_dir, file_name)
|
||||||
|
try:
|
||||||
|
copy(file_path)
|
||||||
|
except Exception as err:
|
||||||
|
print('Failed to copy ', file_path)
|
||||||
|
print(err)
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
print('Done!')
|
||||||
|
print('Sleeping for 10m...')
|
||||||
|
time.sleep(60 * 10) #10m
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user