-
Notifications
You must be signed in to change notification settings - Fork 6
Mirror linux mint #15
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
base: main
Are you sure you want to change the base?
Changes from all commits
76b38dd
b4df43f
4fde1c9
03e78ba
9797b49
18769fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [Unit] | ||
| Description=Keeping the linux mint mirror images up to date | ||
| After=network-online.target | ||
| Wants=network-online.target | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| ExecStart=/usr/local/bin/linux-mint-sync-images.sh | ||
| TimeoutStartSec=7200 | ||
| User=mirrors | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [Unit] | ||
| Description=Activate service for syncing changes in the linux mint mirror | ||
|
|
||
| [Timer] | ||
| OnCalendar=*:0/15 | ||
| AccuracySec=5m | ||
| Persistent=true | ||
|
|
||
| [Install] | ||
| WantedBy=timers.target |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,126 @@ | ||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||
|
|
||||||||||||||||||
| # This script checks the status of the upstream Linux Mint server and the local mirror. | ||||||||||||||||||
| # It compares the last modification time of a reference file | ||||||||||||||||||
| # and checks the following conditions: | ||||||||||||||||||
| # | ||||||||||||||||||
| # - If the upstream mirror has new updates, the local mirror fetches them | ||||||||||||||||||
| # - If the upstream mirror was updated less than 24 hours ago, the local mirror is considered up-to-date and no action is taken. | ||||||||||||||||||
| # - If the upstream mirror was updated more than 24 hours ago it synchronizes again | ||||||||||||||||||
| # | ||||||||||||||||||
| # This script is intended to be run repeatedly by a cron job or a systemd timer. | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| MIRROR_DIRECTORY=/srv/linux-mint | ||||||||||||||||||
| LOCAL_MIRROR="lidsol.fi-b.unam.mx" | ||||||||||||||||||
|
||||||||||||||||||
| LOCAL_MIRROR="lidsol.fi-b.unam.mx" |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script creates directories and writes files in /srv/linux-mint while running as the mirrors user. Ensure the Ansible playbook creates the /srv/linux-mint directory with appropriate ownership and permissions for the mirrors user, otherwise the script will fail with permission errors.
| # Ensure the main mirror directory exists and is owned by the mirrors user | |
| if [ ! -d "${MIRROR_DIRECTORY}" ]; then | |
| mkdir -p "${MIRROR_DIRECTORY}" | |
| fi | |
| chown mirrors:mirrors "${MIRROR_DIRECTORY}" | |
| chmod 755 "${MIRROR_DIRECTORY}" |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after #. Should be # In case we don't receive any date for connection problems.
| #In case we don't receive any date for connection problems | |
| # In case we don't receive any date for connection problems |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The returned date string is missing the " UTC" suffix that is expected by the rest of the script. The get_local_time function returns dates in "YYYY-MM-DD HH:MM:SS UTC" format, but this function returns only "YYYY-MM-DD HH:MM:SS". Add " UTC" to the echo statement for consistency.
| echo "$latest" | |
| echo "$latest UTC" |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless use of cat. Replace cat ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} | head -n 1 with head -n 1 ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} to avoid unnecessary process creation.
| cat ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} | head -n 1 | |
| head -n 1 ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment states the local mirror is considered out of date if it's "more than 24 hours old" but the condition checks for more than 24 hours (86400 seconds). The comment matches the code, but there's an inconsistency with the repository sync script which uses 12 hours. Consider standardizing the thresholds or documenting why they differ.
| # Note: This script uses a 24-hour (86400 seconds) threshold for image sync. | |
| # The repository sync script uses a 12-hour (43200 seconds) threshold. | |
| # This difference is intentional to allow less frequent image updates. |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition checks if less than 12 hours (43200 seconds) have passed, but the comment at the top of the file states "less than 24 hours". Either update this threshold to 86400 seconds to match the documentation, or update the file header comment to reflect the actual 12-hour threshold.
| if [ $(($current_time_epoch - $local_mirror_time_epoch)) -lt 43200 ]; then | |
| if [ $(($current_time_epoch - $local_mirror_time_epoch)) -lt 86400 ]; then |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing whitespace at the end of line.
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,10 @@ | ||||||||
| [Unit] | ||||||||
| Description=Keeping the linux mint mirror repository up to date | ||||||||
| After=network-online.target | ||||||||
| Wants=network-online.target | ||||||||
|
|
||||||||
| [Service] | ||||||||
| Type=oneshot | ||||||||
| ExecStart=/usr/local/bin/linux-mint-sync-repo.sh | ||||||||
| TimeoutStartSec=1800 | ||||||||
| User=mirrors | ||||||||
|
Comment on lines
+9
to
+10
|
||||||||
| TimeoutStartSec=1800 | |
| User=mirrors | |
| TimeoutStartSec=1800 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [Unit] | ||
| Description=Activate service for syncing changes in the linux mint mirror | ||
|
|
||
| [Timer] | ||
| OnCalendar=*:0/15 | ||
| AccuracySec=5m | ||
| Persistent=true | ||
|
|
||
| [Install] | ||
| WantedBy=timers.target |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,108 @@ | ||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # This script checks the status of the upstream Linux Mint server and the local mirror. | ||||||||||||||||||||||||
| # It compares the last modification time of a reference file | ||||||||||||||||||||||||
| # and checks the following conditions: | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # - If the upstream mirror has new updates, the local mirror fetches them | ||||||||||||||||||||||||
| # - If the upstream mirror was updated less than 24 hours ago, the local mirror is considered up-to-date and no action is taken. | ||||||||||||||||||||||||
| # - If the upstream mirror was updated more than 24 hours ago it synchronizes again | ||||||||||||||||||||||||
| # | ||||||||||||||||||||||||
| # This script is intended to be run repeatedly by a cron job or a systemd timer. | ||||||||||||||||||||||||
|
Comment on lines
+3
to
+12
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| MIRROR_DIRECTORY=/srv/linux-mint | ||||||||||||||||||||||||
| LOCAL_MIRROR="lidsol.fi-b.unam.mx" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| LOCAL_MIRROR="lidsol.fi-b.unam.mx" |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script creates directories and writes files in /srv/linux-mint while running as the mirrors user. Ensure the Ansible playbook creates the /srv/linux-mint directory with appropriate ownership and permissions for the mirrors user, otherwise the script will fail with permission errors.
| LATEST_UPDATE_FILE=latest_sync_repository.meta | |
| LATEST_UPDATE_FILE=latest_sync_repository.meta | |
| # Ensure MIRROR_DIRECTORY exists and is writable | |
| if [ ! -d "${MIRROR_DIRECTORY}" ]; then | |
| mkdir -p "${MIRROR_DIRECTORY}" || { echo "Error: Could not create ${MIRROR_DIRECTORY}. Permission denied."; exit 1; } | |
| fi | |
| if [ ! -w "${MIRROR_DIRECTORY}" ]; then | |
| echo "Error: ${MIRROR_DIRECTORY} is not writable by user $(whoami). Please ensure correct ownership and permissions." | |
| exit 1 | |
| fi |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless use of cat. Replace cat ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} | head -n 1 with head -n 1 ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} to avoid unnecessary process creation.
| cat ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} | head -n 1 | |
| head -n 1 ${MIRROR_DIRECTORY}/${LATEST_UPDATE_FILE} |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "more than 24 hours" but the condition checks for more than 12 hours (43200 seconds). Either update the comment to say "more than 12 hours" or adjust the threshold to 86400 seconds for 24 hours.
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "less than 12 hours" but the condition checks for less than 6 hours (21600 seconds). Either update the comment to say "less than 6 hours" or adjust the threshold to 43200 seconds for 12 hours.
| if [ $(($current_time_epoch - $local_mirror_time_epoch)) -lt 21600 ]; then | |
| if [ $(($current_time_epoch - $local_mirror_time_epoch)) -lt 43200 ]; then |
Copilot
AI
Nov 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove trailing whitespace at the end of line.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [mirror-server] | ||
| lidsol.fi-b.unam.mx |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| - name: Setup mirrors server for LIDSoL | ||
| hosts: mirror-server | ||
| become: true | ||
|
|
||
| tasks: | ||
| - name: Linux Mint mirrors | ||
| ansible.builtin.import_tasks: tasks/linux-mint.yaml | ||
|
|
||
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||
| # Ansible task file for setting up Linux Mint mirrors | ||||||
| # This playbook copies necessary service and script files to the target system | ||||||
| # and ensures that the corresponding systemd services and timers are enabled and started. | ||||||
| --- | ||||||
| - name: Copy required systemd service and timer files for linux mint images mirror | ||||||
| ansible.builtin.copy: | ||||||
| src: files/linux-mint/images/confd/{{ item }} | ||||||
| dest: /etc/systemd/system/{{ item }} | ||||||
| owner: root | ||||||
| group: root | ||||||
| mode: '0644' | ||||||
| loop: | ||||||
| - "mintUpdateImages.service" | ||||||
| - "mintUpdateImages.timer" | ||||||
|
|
||||||
| - name: Copy linux mint sync script for images mirror | ||||||
| ansible.builtin.copy: | ||||||
| src: files/linux-mint/images/scripts/linux-mint-sync-images.sh | ||||||
|
||||||
| dest: /usr/local/bin/linux-mint-sync-images.sh | ||||||
| owner: root | ||||||
| group: root | ||||||
| mode: '0755' | ||||||
|
|
||||||
| - name: Copy required systemd service and timer files for linux mint repository mirror | ||||||
| ansible.builtin.copy: | ||||||
| src: files/linux-mint/repository/confd/{{ item }} | ||||||
| dest: /etc/systemd/system/{{ item }} | ||||||
| owner: root | ||||||
| group: root | ||||||
| mode: '0644' | ||||||
| loop: | ||||||
| - "mintUpdateRepository.service" | ||||||
| - "mintUpdateRepository.timer" | ||||||
|
|
||||||
| - name: Copy linux mint sync script for repository mirror | ||||||
| ansible.builtin.copy: | ||||||
| src: files/linux-mint/repository/scripts/linux-mint-sync-repo.sh | ||||||
|
||||||
| src: files/linux-mint/repository/scripts/linux-mint-sync-repo.sh | |
| src: files/linux-mint/repository/scripts/linux-mint-sync-repo.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service specifies
User=mirrors, but there's no task in the Ansible playbook to create this user. Ensure the user exists on the target system, or add a task to create it before deploying these services.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I write the task in main instead?, because the user most exist for every mirror