Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add systemd timer to auto update proxy-multi.conf #342

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ If the build has failed, you should run `make clean` before building it again.
```bash
curl -s https://core.telegram.org/getProxySecret -o proxy-secret
```
2. Obtain current telegram configuration. It can change (occasionally), so we encourage you to update it once per day.
2. Obtain current telegram configuration. It can change (occasionally), so we encourage you to update it once per day (see [below](#Timers) ).
```bash
curl -s https://core.telegram.org/getProxyConfig -o proxy-multi.conf
```
Expand Down Expand Up @@ -104,6 +104,53 @@ systemctl status MTProxy.service
systemctl enable MTProxy.service
```

### Timers

This provides automatic proxy-multi.conf file update everyday

1. Create and edit systemd service file (especially path of proxy-multi.conf file):
```bash
nano /etc/systemd/system/MTProxy-multiUpdater.service
```

```bash
[Unit]
Description=Update MTPRoxy proxy-multi.conf file

[Service]
Type=oneshot
ExecStart=/usr/bin/curl -s https://core.telegram.org/getProxyConfig -o /opt/MTProxy/proxy-multi.conf
```
2. Add the timer (this example runs above service everyday at 4AM)
```bash
nano /etc/systemd/system/MTProxy-multiUpdater.timer
```

```bash
[Unit]
Description=MTProxy-multiUpdater timer

[Timer]
OnCalendar=*-*-* 4:00:00
Persistent=true

[Install]
WantedBy=timers.target
```
3. Reload daemons:
```bash
systemctl daemon-reload
```
4. Enable and start timer
```bash
systemctl enable MTProxy-multiUpdater.timer
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After enabling maybe it is a good idea just start the timer right away

systemctl start MTProxy-multiUpdater.timer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 9b018dc

systemctl start MTProxy-multiUpdater.timer
```
5. Check timer is properly set up
```bash
systemctl list-timers
```

## Docker image
Telegram is also providing [official Docker image](https://hub.docker.com/r/telegrammessenger/proxy/).
Note: the image is outdated.