mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
create a script that executes at every startup
This commit is contained in:
parent
24269d2b4b
commit
62a8ef6d0b
4 changed files with 44 additions and 0 deletions
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
- include_tasks: udev.yml
|
- include_tasks: udev.yml
|
||||||
|
|
||||||
|
- include_tasks: iiab-startup.yml
|
||||||
|
|
||||||
- name: Recording STAGE 2 HAS COMPLETED ==========================
|
- name: Recording STAGE 2 HAS COMPLETED ==========================
|
||||||
lineinfile: dest=/etc/iiab/iiab.env
|
lineinfile: dest=/etc/iiab/iiab.env
|
||||||
regexp='^STAGE=*'
|
regexp='^STAGE=*'
|
||||||
|
|
25
roles/2-common/tasks/startup.yml
Normal file
25
roles/2-common/tasks/startup.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
- name: Does systemd startup service exist
|
||||||
|
stat: path="{{ systemd_location }}/iiab-startup.service"
|
||||||
|
register: startup_unit
|
||||||
|
|
||||||
|
- name: Copy startup service to /etc/systemd/system
|
||||||
|
template: src=iiab-startup.service
|
||||||
|
dest=/etc/systemd/system/
|
||||||
|
when: startup_unit.stat.exists is defined and not startup_unit.stat.exists
|
||||||
|
|
||||||
|
- name: Copy startup script
|
||||||
|
template: src=iiab-startup.sh
|
||||||
|
dest=/usr/libexec/
|
||||||
|
when: startup_unit.stat.exists is defined and not startup_unit.stat.exists
|
||||||
|
|
||||||
|
- name: Ask systemd to recognize the changes
|
||||||
|
shell: systemctl daemon-reload
|
||||||
|
when: startup_unit.stat.exists is defined and not startup_unit.stat.exists
|
||||||
|
|
||||||
|
- name: Restart so systemd recognizes the changes
|
||||||
|
shell: systemctl restart iiab-startup.service
|
||||||
|
when: startup_unit.stat.exists is defined and not startup_unit.stat.exists
|
||||||
|
|
||||||
|
- name: Enable the reload service
|
||||||
|
shell: systemctl enable iiab-startup.service
|
||||||
|
when: startup_unit.stat.exists is defined and not startup_unit.stat.exists
|
10
roles/2-common/templates/iiab-startup.service
Normal file
10
roles/2-common/templates/iiab-startup.service
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Execute startup script
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/libecec/iiab-startup.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
7
roles/2-common/templates/iiab-startup.sh
Normal file
7
roles/2-common/templates/iiab-startup.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# put initialization that needs to happen at every startup for IIAB here
|
||||||
|
|
||||||
|
if [ ! -f /etc/iiab/uuid ]; then
|
||||||
|
uuidgen > /etc/iiab/uuid
|
||||||
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue