some changes
parent
ce1c9fb6b6
commit
56ac5ffa80
Binary file not shown.
Binary file not shown.
|
|
@ -9,8 +9,8 @@ services:
|
|||
- 993:993
|
||||
volumes:
|
||||
- vmail:/srv/mail
|
||||
- /opt/dovecot/config:/etc/dovecot
|
||||
- /opt/dovecot/passwd:/etc/dovecot/passwd
|
||||
- ./dovecot/config:/etc/dovecot
|
||||
- ./dovecot/passwd:/etc/dovecot/passwd
|
||||
|
||||
roundcube:
|
||||
image: roundcube/roundcubemail
|
||||
|
|
@ -19,22 +19,21 @@ services:
|
|||
ports:
|
||||
- 80:80
|
||||
environment:
|
||||
- ROUNDCUBEMAIL_DEFAULT_HOST=180.1.1.164
|
||||
- ROUNDCUBEMAIL_DEFAULT_HOST=dovecot
|
||||
- ROUNDCUBEMAIL_DEFAULT_PORT=143
|
||||
depends_on:
|
||||
- dovecot
|
||||
|
||||
imapsync:
|
||||
build:
|
||||
dockerfile: imapsync-dockerfile
|
||||
dockerfile: ./dockerfile/imapsync-dockerfile
|
||||
container_name: imapsync
|
||||
restart: always
|
||||
expose:
|
||||
- 993
|
||||
- 143
|
||||
volumes:
|
||||
- /app/db:/root/IMAP-Sync/db
|
||||
logging:
|
||||
driver: journald
|
||||
options:
|
||||
tag: imapsync
|
||||
- ./db:/app/db
|
||||
networks:
|
||||
- default
|
||||
depends_on:
|
||||
|
|
@ -42,11 +41,13 @@ services:
|
|||
|
||||
streamlit:
|
||||
build:
|
||||
dockerfile: streamlit-dockerfile
|
||||
dockerfile: ./dockerfile/streamlit-dockerfile
|
||||
container_name: streamlit
|
||||
restart: always
|
||||
ports:
|
||||
- 81:80
|
||||
volumes:
|
||||
- /app/db:/root/IMAP-Sync/db
|
||||
- ./db:/app/db
|
||||
logging:
|
||||
driver: journald
|
||||
options:
|
||||
|
|
|
|||
|
|
@ -3,19 +3,20 @@ FROM debian:latest
|
|||
RUN apt update
|
||||
RUN apt upgrade -y
|
||||
RUN apt install -y git make gcc
|
||||
RUN apt install -y apt-file cpanminus libc6-dev libssl-dev python3 python3-pip
|
||||
RUN apt install -y apt-file cpanminus libc6-dev libssl-dev python3 python3-pip python3-dotenv
|
||||
RUN apt install -y libperl-dev zlib1g-dev libnet-ssleay-perl
|
||||
RUN cpanm App::cpanminus Authen::NTLM CGI Compress::Zlib Crypt::OpenSSL::RSA Data::Dumper Data::Uniqid Dist::CheckConflicts Encode Encode::IMAPUTF7 File::Copy::Recursive File::Tail IO::Socket::INET IO::Socket::INET6 IO::Socket::SSL IO::Tee JSON JSON::WebToken LWP::UserAgent Mail::IMAPClient Module::ScanDeps PAR::Packer Pod::Usage Readonly Regexp::Common Sys::MemInfo Term::ReadKey Test::MockObject Test::More Test::Pod Unicode::String; exit 0
|
||||
RUN apt install -y libproc-processtable-perl python3-requests iputils-ping
|
||||
WORKDIR /usr/local/src
|
||||
RUN echo PWD
|
||||
RUN git clone https://github.com/imapsync/imapsync.git
|
||||
RUN ./imapsync
|
||||
WORKDIR ./imapsync
|
||||
RUN make install
|
||||
|
||||
RUN mkdir /app
|
||||
WORKDIR /app/
|
||||
COPY ../python_scripte/imapsync.py .
|
||||
CMD ["/bin/bash"]
|
||||
COPY ../python_scripte/.env .
|
||||
ENTRYPOINT [ "python3", "/app/imapsync.py" ]
|
||||
|
||||
#RUN impasync-script
|
||||
|
|
@ -11,13 +11,13 @@ RUN apt-get update && apt-get install -y \
|
|||
git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY ../python_scripte/streamlit-app.py /app/
|
||||
COPY ../python_scripte/requirements.txt /app/
|
||||
|
||||
RUN pip3 install -r /app/requirements.txt
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
COPY ../python_scripte/streamlit-app.py /app/
|
||||
COPY ../python_scripte/requirements.txt /app/
|
||||
|
||||
HEALTHCHECK CMD curl --fail http://localhost:80/_stcore/health
|
||||
|
||||
ENTRYPOINT ["streamlit", "run", "/app/streamlit-app.py", "--server.port=80", "--server.address=0.0.0.0"]
|
||||
|
|
@ -7,11 +7,12 @@ import smtplib
|
|||
import os
|
||||
from email.message import EmailMessage
|
||||
from dotenv import load_dotenv
|
||||
import time # Import time module for sleep functionality
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# Define server details
|
||||
host = "front"
|
||||
host = "180.1.1.164"
|
||||
port = 993
|
||||
|
||||
# Function to send an email notification
|
||||
|
|
@ -37,55 +38,60 @@ def send_email(subject, body, to_email):
|
|||
except Exception as e:
|
||||
print(f"Failed to send email: {e}")
|
||||
|
||||
# Check if mail server is active
|
||||
try:
|
||||
# Start the infinite loop
|
||||
while True:
|
||||
try:
|
||||
# Check if mail server is active
|
||||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.settimeout(1)
|
||||
result = sock.connect_ex((host, port))
|
||||
if result != 0:
|
||||
print(f"Fehler beim Verbinden zu {host} auf Port {port}") # --- E-Mail senden
|
||||
except Exception as e:
|
||||
send_email("Server Connection Error", f"Fehler beim Verbinden zu {host} auf Port {port}", os.getenv('TO_EMAIL'))
|
||||
except Exception as e:
|
||||
print(f"Fehler beim Verbinden zu {host} auf Port {port}: {e}") # --- E-Mail senden
|
||||
finally:
|
||||
send_email("Server Connection Error", f"Fehler beim Verbinden zu {host} auf Port {port}: {e}", os.getenv('TO_EMAIL'))
|
||||
finally:
|
||||
sock.close()
|
||||
|
||||
# Prepare SQLite database connection
|
||||
db_path = "imapsync_results.db"
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
# Prepare SQLite database connection
|
||||
db_path = "/app/db/imapsync_results.db"
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Create tables if not exists
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS sync_results (
|
||||
# Create tables if not exists
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS sync_results (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
email TEXT,
|
||||
messages_transferred INTEGER,
|
||||
date TEXT
|
||||
)
|
||||
''')
|
||||
)
|
||||
''')
|
||||
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
cursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
email TEXT UNIQUE,
|
||||
password TEXT,
|
||||
domain TEXT
|
||||
)
|
||||
''')
|
||||
)
|
||||
''')
|
||||
|
||||
# Fetch user data from the SQLite database
|
||||
cursor.execute("SELECT email, password, domain FROM users")
|
||||
users = cursor.fetchall()
|
||||
# Fetch user data from the SQLite database
|
||||
cursor.execute("SELECT email, password, domain FROM users")
|
||||
users = cursor.fetchall()
|
||||
|
||||
if not users:
|
||||
if not users:
|
||||
print("No users found in the database.")
|
||||
sys.exit(1)
|
||||
|
||||
# Process each user
|
||||
for user in users:
|
||||
# Process each user
|
||||
for user in users:
|
||||
username, password, domain = user
|
||||
local_part = username.split('@')[0]
|
||||
|
||||
print(f"User: {username} running.")
|
||||
# Command for imapsync
|
||||
command = [
|
||||
"imapsync",
|
||||
|
|
@ -93,11 +99,12 @@ for user in users:
|
|||
"--user1", username,
|
||||
"--password1", password,
|
||||
"--host2", "180.1.1.164",
|
||||
"--user2", "archiv@archiv.trendsetzer.eu",
|
||||
"--password2", "pass",
|
||||
"--user2", "archiv@trendsetzer.eu",
|
||||
"--password2", "Ln0m2YQZd23H54L5tCiyjIBWLEn8mk36v7KauqS8QFGzu",
|
||||
"--subfolder2", f"{local_part}",
|
||||
"--regextrans2", "s/^(.*)$/\\1/",
|
||||
"--nolog"
|
||||
"--log",
|
||||
"--notls2"
|
||||
]
|
||||
|
||||
# Run the command and capture the output
|
||||
|
|
@ -131,5 +138,12 @@ for user in users:
|
|||
except Exception as e:
|
||||
print(f"Error running imapsync for {username}: {e}")
|
||||
|
||||
# Close database connection
|
||||
conn.close()
|
||||
# Close database connection
|
||||
conn.close()
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred during the loop execution: {e}")
|
||||
|
||||
# Sleep for 5 minutes before the next iteration
|
||||
print("Sleep 5 minutes")
|
||||
time.sleep(300)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ def main():
|
|||
view_users = st.sidebar.button("View Users", key="view_users_button")
|
||||
delete_user = st.sidebar.button("Delete User", key="delete_user_button")
|
||||
st.sidebar.markdown(
|
||||
'<a href="http://180.1.1.164:8000" target="_blank"><button style="background-color: LightGray; color: black; border: none; padding: 8px 16px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer;">View Mails</button></a>',
|
||||
'<a href="http://180.1.1.164" target="_blank"><button style="background-color: LightGray; color: black; border: none; padding: 8px 16px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer;">View Mails</button></a>',
|
||||
unsafe_allow_html=True
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue