Add automatic cron for client expiration check
This commit is contained in:
+14
-1
@@ -12,6 +12,7 @@ RUN apt-get update && apt-get install -y \
|
|||||||
sshpass \
|
sshpass \
|
||||||
openssh-client \
|
openssh-client \
|
||||||
qrencode \
|
qrencode \
|
||||||
|
cron \
|
||||||
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd \
|
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd \
|
||||||
&& a2enmod rewrite \
|
&& a2enmod rewrite \
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
@@ -35,7 +36,19 @@ COPY apache.conf /etc/apache2/sites-available/000-default.conf
|
|||||||
RUN chown -R www-data:www-data /var/www/html \
|
RUN chown -R www-data:www-data /var/www/html \
|
||||||
&& chmod -R 755 /var/www/html/public
|
&& chmod -R 755 /var/www/html/public
|
||||||
|
|
||||||
|
# Setup cron for client expiration check (runs every hour)
|
||||||
|
RUN echo "0 * * * * www-data cd /var/www/html && /usr/local/bin/php bin/check_expired_clients.php >> /var/log/cron.log 2>&1" > /etc/cron.d/amnezia-cron \
|
||||||
|
&& chmod 0644 /etc/cron.d/amnezia-cron \
|
||||||
|
&& crontab /etc/cron.d/amnezia-cron \
|
||||||
|
&& touch /var/log/cron.log
|
||||||
|
|
||||||
|
# Create startup script
|
||||||
|
RUN echo '#!/bin/bash\n\
|
||||||
|
service cron start\n\
|
||||||
|
apache2-foreground' > /start.sh \
|
||||||
|
&& chmod +x /start.sh
|
||||||
|
|
||||||
# Expose port 80
|
# Expose port 80
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
CMD ["apache2-foreground"]
|
CMD ["/start.sh"]
|
||||||
|
|||||||
@@ -106,10 +106,16 @@ curl -X POST http://localhost:8082/api/servers/1/restore \
|
|||||||
|
|
||||||
### Automatic Client Expiration Check
|
### Automatic Client Expiration Check
|
||||||
|
|
||||||
Run via cron to auto-disable expired clients:
|
**Автоматически запускается в Docker контейнере** каждый час для отключения просроченных клиентов.
|
||||||
|
|
||||||
|
Проверить логи крона:
|
||||||
```bash
|
```bash
|
||||||
# Add to crontab (runs every hour)
|
docker compose exec web tail -f /var/log/cron.log
|
||||||
0 * * * * docker compose exec web php /var/www/html/bin/check_expired_clients.php
|
```
|
||||||
|
|
||||||
|
Запустить вручную:
|
||||||
|
```bash
|
||||||
|
docker compose exec web php /var/www/html/bin/check_expired_clients.php
|
||||||
```
|
```
|
||||||
|
|
||||||
### API Authentication
|
### API Authentication
|
||||||
|
|||||||
Reference in New Issue
Block a user