mirror of
https://github.com/pigmonkey/spark.git
synced 2026-01-23 02:24:09 +00:00
add systemd timer to update pacman mirrors daily
This increases the likelihood of speedy and up-to-date mirrors, particularly during travel.
This commit is contained in:
parent
ceb1526498
commit
c4be5e5e7b
10 changed files with 88 additions and 14 deletions
|
|
@ -71,7 +71,6 @@ base_packages:
|
|||
- coreutils
|
||||
- moreutils
|
||||
- dateutils
|
||||
- reflector
|
||||
- bc
|
||||
- ranger
|
||||
- strace
|
||||
|
|
@ -283,4 +282,7 @@ aur_fonts:
|
|||
syncthing:
|
||||
run_on: trusted
|
||||
|
||||
mirrorlist:
|
||||
run_on: trusted
|
||||
|
||||
kernel_parameters: "quiet consoleblank=60 i915.enable_psr=2"
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@
|
|||
- { role: himawaripy, tags: ['himawaripy'], when: "himawaripy is defined" }
|
||||
- { role: kiwix, tags: ['kiwix'] }
|
||||
- { role: syncthing, tags: ['syncthing'], when: "syncthing is defined" }
|
||||
- { role: mirrorlist, tags: ['mirrorlist'], when: "mirrorlist is defined" }
|
||||
vars_prompt:
|
||||
- name: user_password
|
||||
prompt: "Enter desired user password"
|
||||
|
|
|
|||
|
|
@ -6,25 +6,12 @@
|
|||
tags:
|
||||
- packages
|
||||
|
||||
- name: Push reflector update script
|
||||
copy:
|
||||
src: reflector-update.sh
|
||||
dest: /usr/local/bin/reflector-update
|
||||
mode: 0755
|
||||
tags:
|
||||
- packages
|
||||
|
||||
- name: Create pacman hook directory
|
||||
file: path=/etc/pacman.d/hooks
|
||||
state=directory
|
||||
tags:
|
||||
- packages
|
||||
|
||||
- name: Push pacman mirror list update hook
|
||||
copy: src=mirrorlist.hook dest=/etc/pacman.d/hooks/mirrorlist.hook
|
||||
tags:
|
||||
- packages
|
||||
|
||||
- name: Use all cores when compressing packages
|
||||
lineinfile:
|
||||
dest: /etc/makepkg.conf
|
||||
|
|
|
|||
7
roles/mirrorlist/files/reflector-update.service
Normal file
7
roles/mirrorlist/files/reflector-update.service
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[Unit]
|
||||
Description=Reflector Update Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/reflector-update
|
||||
11
roles/mirrorlist/files/reflector-update.timer
Normal file
11
roles/mirrorlist/files/reflector-update.timer
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Reflector Update Timer
|
||||
|
||||
[Timer]
|
||||
Unit=reflector-update.service
|
||||
OnCalendar=daily
|
||||
Persistent=True
|
||||
RandomizedDelaySec=1h
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
4
roles/mirrorlist/handlers/main.yml
Normal file
4
roles/mirrorlist/handlers/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- name: restart reflector update
|
||||
service: name=mirrorlist.timer state=restarted
|
||||
when: mirrorlist.run_on == "all"
|
||||
4
roles/mirrorlist/meta/main.yml
Normal file
4
roles/mirrorlist/meta/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
dependencies:
|
||||
- { role: networkmanager }
|
||||
- { role: systemd }
|
||||
58
roles/mirrorlist/tasks/main.yml
Normal file
58
roles/mirrorlist/tasks/main.yml
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
- name: Install reflector
|
||||
pacman:
|
||||
name: reflector
|
||||
state: present
|
||||
|
||||
- name: Push reflector update script
|
||||
copy:
|
||||
src: reflector-update.sh
|
||||
dest: /usr/local/bin/reflector-update
|
||||
mode: 0755
|
||||
|
||||
- name: Push pacman mirror list update hook
|
||||
copy:
|
||||
src: mirrorlist.hook
|
||||
dest: /etc/pacman.d/hooks/mirrorlist.hook
|
||||
|
||||
- name: Push reflector update service file
|
||||
copy:
|
||||
src: reflector-update.service
|
||||
dest: /etc/systemd/system/
|
||||
notify:
|
||||
- reload systemd config
|
||||
|
||||
- name: Push reflector update timer file
|
||||
copy:
|
||||
src: reflector-update.timer
|
||||
dest: /etc/systemd/system/
|
||||
notify:
|
||||
- reload systemd config
|
||||
- restart reflector update
|
||||
|
||||
- name: Enable and start reflector timer
|
||||
service:
|
||||
name: reflector-update.timer
|
||||
enabled: yes
|
||||
state: started
|
||||
when: mirrorlist.run_on == "all"
|
||||
|
||||
- name: Remove reflector from trusted unit list
|
||||
lineinfile:
|
||||
dest: /usr/local/etc/trusted_units
|
||||
state: absent
|
||||
line: reflector-update.timer
|
||||
when: mirrorlist.run_on == "all"
|
||||
|
||||
- name: Disable reflector timer
|
||||
service:
|
||||
name: reflector-update.timer
|
||||
enabled: no
|
||||
when: mirrorlist.run_on == "trusted"
|
||||
|
||||
- name: Add reflector to trusted unit list
|
||||
lineinfile:
|
||||
dest: /usr/local/etc/trusted_units
|
||||
state: present
|
||||
line: reflector-update.timer
|
||||
when: mirrorlist.run_on == "trusted"
|
||||
Loading…
Add table
Add a link
Reference in a new issue