From 6f079d196756962c04ebb5652a0a07b1d4c8c2d5 Mon Sep 17 00:00:00 2001 From: Tha14 Date: Thu, 29 Dec 2022 15:23:46 +0200 Subject: [PATCH] feat: add wondershaper and update README.md --- README.md | 3 ++- uam-swarm/docker-compose.yml | 12 +++++++++--- uam-swarm/entrypoint.sh | 3 ++- uam/docker-compose.yml | 6 +++++- uam/entrypoint.sh | 3 ++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fe186dc..3baf1fd 100644 --- a/README.md +++ b/README.md @@ -25,12 +25,13 @@ 1. This container will download the latest version of uam every time it is started and will install apt packages so keep that in mind. 2. The http service for uam is enabled and listening on http://127.0.0.1:17099 for the single instance. For the UAM swarm you need to define the listening port for each instance. 3. Make sure you port forward manually as upnp will most likely not work. +4. You can adjust the maximum upload and download bandwidth of uam by changing the `NETLIMUP` and `NETLIMDOWN` env variables. ## ToDo: - [x] Add CI tests to make sure the scripts work. - [x] Make PBKEY a required variable to avoid running uam without it. - [ ] Remove unnecessary packages. - [ ] Try to speed up mime database update. -- [ ] Include wondershaper or sch_cake in `apt install` and environment configuration parameters for it. +- [x] Include wondershaper or sch_cake in `apt install` and environment configuration parameters for it. - [ ] See if it's possible to automatically increment port numbers for the swarm script. - [ ] Try to package up-to-date databases to prevent warm-up problems. diff --git a/uam-swarm/docker-compose.yml b/uam-swarm/docker-compose.yml index fbcb158..3dabc41 100644 --- a/uam-swarm/docker-compose.yml +++ b/uam-swarm/docker-compose.yml @@ -15,13 +15,15 @@ services: volumes: - "./entrypoint.sh:/opt/entrypoint.sh" - "/opt/uam_data/uam_1:/root/.uam" - command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY} $${PPORT}" + command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY} $${PPORT} $${NETLIMUP} $${NETLIMDOWN}" ports: - "127.0.0.1:17100:17099" - "4160:4160" environment: - PBKEY=${PBKEY?err} - PPORT=4160 + - NETLIMUP=10000 + - NETLIMDOWN=18000 uam_2: image: debian:bullseye-slim @@ -37,13 +39,15 @@ services: volumes: - "./entrypoint.sh:/opt/entrypoint.sh" - "/opt/uam_data/uam_2:/root/.uam" - command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY} $${PPORT}" + command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY} $${PPORT} $${NETLIMUP} $${NETLIMDOWN}" ports: - "127.0.0.1:17101:17099" - "4161:4161" environment: - PBKEY=${PBKEY?err} - PPORT=4161 + - NETLIMUP=10000 + - NETLIMDOWN=18000 uam_3: image: debian:bullseye-slim @@ -59,10 +63,12 @@ services: volumes: - "./entrypoint.sh:/opt/entrypoint.sh" - "/opt/uam_data/uam_3:/root/.uam" - command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY} $${PPORT}" + command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY} $${PPORT} $${NETLIMUP} $${NETLIMDOWN}" ports: - "127.0.0.1:17102:17099" - "4162:4162" environment: - PBKEY=${PBKEY?err} - PPORT=4162 + - NETLIMUP=10000 + - NETLIMDOWN=18000 diff --git a/uam-swarm/entrypoint.sh b/uam-swarm/entrypoint.sh index 343db73..41c1441 100755 --- a/uam-swarm/entrypoint.sh +++ b/uam-swarm/entrypoint.sh @@ -1,7 +1,8 @@ #!/bin/sh cd /tmp -apt update && apt -yq install wget libglib2.0-0 ca-certificates dnsmasq +apt update && apt -yq install wget libglib2.0-0 ca-certificates dnsmasq wondershaper update-ca-certificates +wondershaper eth0 $3 $4 & wget https://update.u.is/downloads/uam/linux/uam-latest_amd64.deb dpkg -i uam-latest_amd64.deb cd /opt/uam/ diff --git a/uam/docker-compose.yml b/uam/docker-compose.yml index 4c1f115..6e33270 100644 --- a/uam/docker-compose.yml +++ b/uam/docker-compose.yml @@ -12,12 +12,16 @@ services: memlock: -1 oom_score_adj: -700 mem_swappiness: 10 + cap_add: + - NET_ADMIN volumes: - "./entrypoint.sh:/opt/entrypoint.sh" - "/opt/uam_data:/root/.uam" - command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY}" + command: /bin/sh -c "chmod +x /opt/entrypoint.sh && /opt/entrypoint.sh $${PBKEY} $${NETLIMUP} $${NETLIMDOWN}" ports: - "127.0.0.1:17099:17099" - "4156:4156" environment: - PBKEY=${PBKEY?err} + - NETLIMUP=10000 + - NETLIMDOWN=18000 diff --git a/uam/entrypoint.sh b/uam/entrypoint.sh index 75d97cd..d9197db 100755 --- a/uam/entrypoint.sh +++ b/uam/entrypoint.sh @@ -1,7 +1,8 @@ #!/bin/sh cd /tmp -apt update && apt -yq install wget libglib2.0-0 ca-certificates dnsmasq +apt update && apt -yq install wget libglib2.0-0 ca-certificates dnsmasq wondershaper update-ca-certificates +wondershaper eth0 $2 $3 & wget https://update.u.is/downloads/uam/linux/uam-latest_amd64.deb dpkg -i uam-latest_amd64.deb cd /opt/uam/