diff --git a/README.md b/README.md index efa25ab..6036869 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,9 @@ cd routerfleet Use the following command to start your RouterFleet server. This command will also build the Docker image if it's the first time you're running it, or if there have been changes to the Dockerfile: ```bash -SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password docker compose up --build -d +SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password TIMEZONE=America/Sao_Paulo docker compose up --build -d ``` +[Timezone List](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) During the deployment, a self-signed certificate will be automatically generated for use with HTTPS. If you prefer to use your own certificates, proceed to the next step. @@ -104,7 +105,7 @@ To maintain security, performance, and access to new features in RouterFleet, it With the latest updates in place, re-deploy RouterFleet using Docker Compose. This step rebuilds the Docker image to incorporate any changes: ```bash - SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password docker compose up --build -d + SERVER_ADDRESS=yourserver.example.com POSTGRES_PASSWORD=your_password TIMEZONE=America/Sao_Paulo docker compose up --build -d ``` 6.**Verify Operation:** diff --git a/backup/views.py b/backup/views.py index fd7f2ca..e9df321 100644 --- a/backup/views.py +++ b/backup/views.py @@ -3,6 +3,7 @@ from django.http import JsonResponse, HttpResponse, FileResponse from django.shortcuts import render, get_object_or_404, redirect, Http404 from django.contrib import messages +from routerfleet_tools.models import WebadminSettings from routerlib.backup_functions import perform_backup from .models import BackupProfile from .forms import BackupProfileForm @@ -98,10 +99,12 @@ def view_backup_details(request): if backup_item.backup_text_hash and backup_item.backup_text_hash not in hash_list: hash_list.append(backup_item.backup_text_hash) backup_list.append(backup_item) + webadmin_settings, _ = WebadminSettings.objects.get_or_create(name='webadmin_settings') context = { 'backup': backup, 'backup_list': backup_list, - 'page_title': 'Backup Details' + 'page_title': 'Backup Details', + 'webadmin_settings': webadmin_settings } return render(request, 'backup/backup_details.html', context) diff --git a/docker-compose.yml b/docker-compose.yml index 2c36d3f..3ceae2f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,6 +19,7 @@ services: - SERVER_ADDRESS=${SERVER_ADDRESS} - DEBUG_MODE=${DEBUG_MODE} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - TIMEZONE=${TIMEZONE} volumes: - media_root:/var/lib/routerfleet/ diff --git a/entrypoint.sh b/entrypoint.sh index d134a0e..c288e35 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -34,6 +34,10 @@ DATABASES = { } EOL +if [ -n "$TIMEZONE" ]; then + echo "TIME_ZONE = '$TIMEZONE'" >> /app/routerfleet/production_settings.py +fi + sed -i "/^ path('admin\/', admin.site.urls),/s/^ / # /" /app/routerfleet/urls.py exec "$@" \ No newline at end of file diff --git a/routerfleet/settings.py b/routerfleet/settings.py index 2175229..08646dd 100644 --- a/routerfleet/settings.py +++ b/routerfleet/settings.py @@ -140,6 +140,6 @@ STATICFILES_DIRS = [ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' MEDIA_ROOT = '/var/lib/routerfleet/' -ROUTERFLEET_VERSION = 7002 +ROUTERFLEET_VERSION = 7003 from routerfleet.production_settings import * diff --git a/routerfleet_tools/migrations/0002_webadminsettings_cron_last_run.py b/routerfleet_tools/migrations/0002_webadminsettings_cron_last_run.py new file mode 100644 index 0000000..e634324 --- /dev/null +++ b/routerfleet_tools/migrations/0002_webadminsettings_cron_last_run.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.3 on 2024-04-06 00:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('routerfleet_tools', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='webadminsettings', + name='cron_last_run', + field=models.DateTimeField(blank=True, null=True), + ), + ] diff --git a/routerfleet_tools/models.py b/routerfleet_tools/models.py index eef0360..8068820 100644 --- a/routerfleet_tools/models.py +++ b/routerfleet_tools/models.py @@ -1,12 +1,14 @@ from django.db import models import uuid + class WebadminSettings(models.Model): name = models.CharField(default='webadmin_settings', max_length=20, unique=True) update_available = models.BooleanField(default=False) current_version = models.PositiveIntegerField(default=0) latest_version = models.PositiveIntegerField(default=0) last_checked = models.DateTimeField(blank=True, null=True) + cron_last_run = models.DateTimeField(blank=True, null=True) updated = models.DateTimeField(auto_now=True) created = models.DateTimeField(auto_now_add=True) diff --git a/routerfleet_tools/views.py b/routerfleet_tools/views.py index b2f9d9e..5fb4d11 100644 --- a/routerfleet_tools/views.py +++ b/routerfleet_tools/views.py @@ -8,6 +8,8 @@ import requests def cron_check_updates(request): webadmin_settings, webadmin_settings_created = WebadminSettings.objects.get_or_create(name='webadmin_settings') + webadmin_settings.cron_last_run = timezone.now() + webadmin_settings.save() if webadmin_settings.last_checked is None or timezone.now() - webadmin_settings.last_checked > timezone.timedelta( hours=1): diff --git a/templates/backup/backup_details.html b/templates/backup/backup_details.html index c745a8a..217c64d 100644 --- a/templates/backup/backup_details.html +++ b/templates/backup/backup_details.html @@ -37,6 +37,64 @@ {{ backup.id }} + + + {% if not backup.success and not backup.error %} +
  • + Backup Status + + {% if backup.success %} + + {% elif backup.error %} + + {% elif backup.backup_pending_retrieval %} + + {% else %} + + {% endif %} + +
  • + +
  • + Host Monitoring + + {% if backup.router.monitoring %} + {% if backup.router.routerstatus.status_online %} + + {% else %} + Host offline. Waiting for it to come online + {% endif %} + {% else %} + Not enabled + {% endif %} + +
  • +
  • + Retry Count + + {{ backup.retry_count }} + +
  • + +
  • + Next Retry + + {{ backup.next_retry|default_if_none:"" }} + +
  • + +
  • + Cron last run + + {{ webadmin_settings.cron_last_run }} + +
  • + + + {% endif %} +
  • Schedule Type @@ -54,7 +112,7 @@
  • Finish Time - {{ backup.finish_time }} + {{ backup.finish_time|default_if_none:"" }}
  • @@ -94,6 +152,8 @@
  • + + @@ -158,9 +218,7 @@
    -
    {{ backup.backup_text }}
    - - +
    {{ backup.backup_text|default_if_none:"" }}