Verified Commit 7d770057 authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

Replace init entrypoint with delete_after_delay process

parent fc12cd67
FROM perl:5-buster
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get -y install build-essential libssl-dev libio-socket-ssl-perl
RUN cpan Carton
RUN mkdir -p /opt/delete_after_delay
COPY ./delete_after_delay.pl ./delete_after_delay ./cpanfile.snapshot ./cpanfile /opt/delete_after_delay/
COPY ./delete_after_delay.pl ./cpanfile.snapshot ./cpanfile /opt/delete_after_delay/
WORKDIR /opt/delete_after_delay
RUN carton install
COPY ./docker/init /
ENV READ_FILE_API_KEY_RETRIES 10
ENV READ_FILE_API_KEY_DELAY_BETWEEN_RETRIES_SECONDS 30
ENV QUERY_API_RETRIES 10
ENV QUERY_API_DELAY_BETWEEN_RETRIES_SECONDS 30
ENV DELAY_BETWEEN_CHECK 604800
ENTRYPOINT ["/init"]
CMD ["carton", "exec", "/opt/delete_after_delay/delete_after_delay.pl", "--", "--verbose", "--daemon", "--instance", "instanceD"]
# INSTALLATION
**Warning!**
* You will still need to install the plugin `ep_delete_after_delay` on your etherpad instance if you want to be sure that pads that expired between two check loops can't be accessed.
## Dependencies
### Carton
Carton is a Perl dependencies manager, it will get what you need, so don't bother for Perl modules dependencies (but you can read the file `cpanfile` if you want).
```shell
sudo cpan Carton
```
Some modules that Carton will install need to be compiled. So you will need some tools:
```shell
sudo apt-get install build-essential libssl-dev
```
## Installation
After installing Carton:
```shell
cd /opt
git clone https://framagit.org/framasoft/pad_delete_after_delay.git delete_after_delay
cd delete_after_delay
carton install
sudo cp delete_after_delay.yml.template /etc/delete_after_delay.yml
sudo chmod 640 /etc/delete_after_delay.yml
sudo vi /etc/delete_after_delay.yml
```
The `dir` setting is really important: when a pad is expired, `delete_after_delay` stores a HTML copy of the pad in `$dir/deleted_pads`.
The plugin `ep_delete_after_delay` does the same thing, in the etherpad installation directory.
You can choose to set `dir` to the etherpad installation directory but then you will need to be sure that the `deleted_pads` is writable by the etherpad user AND the user you run `delete_after_delay` with (you can change it in `delete_after_delay@.service` with the `User` setting if you run it as a systemd service).
Warning! Verify that the expiration delays in `/etc/delete_after_delay.yml` and in your etherpad instance's `settings.json` are the same!
Check that `loop` setting is set to `false` in your etherpad instance's `settings.json`.
### delete\_after\_delay
You can see the options of `delete_after_delay` with:
```shell
/opt/delete_after_delay/delete_after_delay -h
```
If you want to start `delete_after_delay` as a systemd service:
```shell
sudo cp delete_after_delay@.service /etc/systemd/system/delete_after_delay@.service
# Change User in /etc/systemd/system/delete_after_delay@.service in needed
sudo systemctl daemon-reload
# To start delete_after_delay on instance foo:
sudo systemctl start delete_after_delay@foo.service
# To start at boot:
sudo systemctl enable delete_after_delay@foo.service
```
Edit `/etc/systemd/system/delete_after_delay@.service` to change the delay between check loops if you want.
[![](https://framagit.org/assets/favicon-075eba76312e8421991a0c1f89a89ee81678bcde72319dd3e8047e2a47cd3a42.ico)](https://framagit.org)
![English:](https://upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Flag_of_the_United_Kingdom.svg/20px-Flag_of_the_United_Kingdom.svg.png) **Framasoft uses GitLab** for the development of its free softwares. Our Github repositories are only mirrors.
If you want to work with us, **fork us on [framagit.org](https://framagit.org)**. (no registration needed, you can sign in with your Github account)
![Français :](https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Flag_of_France.svg/20px-Flag_of_France.svg.png) **Framasoft utilise GitLab** pour le développement de ses logiciels libres. Nos dépôts Github ne sont que des miroirs.
Si vous souhaitez travailler avec nous, **forkez-nous sur [framagit.org](https://framagit.org)**. (l'inscription n'est pas nécessaire, vous pouvez vous connecter avec votre compte Github)
* * *
Fork du dépôt : https://framagit.org/framasoft/Etherpad/pad_delete_after_delay
Adapté pour Docker.
# PAD\_DELETE\_AFTER\_DELAY
......@@ -19,9 +13,9 @@ So we developped an external script to delete the expired pads without loading t
`delete_after_delay` asks an etherpad instance for the list of its pads, then check (and delete if expired) all of them.
# Installation
# Usage
Have a look at the [INSTALL.md file](INSTALL.md)
Build the image, see [README](./docker/README.md).
# License
......
#!/bin/bash
cd /opt/delete_after_delay/
/usr/local/bin/carton exec ./delete_after_delay.pl -- $@
foo:
key: etherpad instance API key
dir: /var/www/foo.etherpad/
url: https://foo.etherpad.org
del: 31536000
[Unit]
Description=%p-%i
[Service]
Type=simple
# Change User if you want
#User=www-data
WorkingDirectory=/opt/delete_after_delay/
ExecStart=/opt/delete_after_delay/delete_after_delay -i %i -s 86400 -d
[Install]
WantedBy=multi-user.target
# picasoft-docker.1.0.1
Replace init entrypoint with delete_after_delay process
# picasoft-docker.1.0
Initial Docker image with init script waiting for instance to be up and API key to be available
# Dockerfile for `delete_pad_after_delay`
This directory only contains an init script. It will grab the `$DIR`, `$URL` and `$DEL` environment variables and pass them to `delete_pad_after_delay`. The API key will be read from a file specified with the `$APIKEY_PATH` variable (it must be mounted or written somehow). You could check picasoft's docker-compose.yml as an example. Only one instance is supported, it is (internally) named `instanceD`.
Use `DELAY_BETWEEN_CHECK` to configure the delay between check/deletion loop.
......@@ -16,4 +16,5 @@ echo " key: $(cat $APIKEY_PATH)" >> $CF
echo " dir: $DIR" >> $CF
echo " url: $URL" >> $CF
echo " del: $DEL" >> $CF
/opt/delete_after_delay/delete_after_delay --verbose --daemon --instance instanceD
exec $@ --sleep $DELAY_BETWEEN_CHECK
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment