Skip to content

Commit 5fc238e

Browse files
authored
Merge pull request #2 from jetrails/boot-hooks-update
Some formatting and other small adjustments.
2 parents 4f50b67 + c9961d4 commit 5fc238e

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

docs/guides/custom-boot-hooks/index.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ We assume you have root access to modify files in `/mnt/jrc-comms/hooks/boot.d/`
1010

1111
## Create Custom Boot Hook
1212

13-
### 1. Create Your Script
13+
##### 1. Create Your Script
14+
1415
Create a new shell script with a filename starting with `99-` (to ensure it runs last). For example:
1516

1617
```bash
@@ -20,15 +21,17 @@ Create a new shell script with a filename starting with `99-` (to ensure it runs
2021
echo "Running custom boot task..."
2122
```
2223

23-
### 2. Set Permissions and Ownership
24+
##### 2. Set Permissions and Ownership
25+
2426
Make the script executable and ensure it’s owned by `root`:
2527

2628
```bash
2729
sudo chown root:root /mnt/jrc-comms/hooks/boot.d/99-custom-task
2830
sudo chmod +x /mnt/jrc-comms/hooks/boot.d/99-custom-task
2931
```
3032

31-
### 3. Verify Execution Order
33+
##### 3. Verify Execution Order
34+
3235
The application runs scripts in ascending order based on their numeric prefixes. Scripts added to `/mnt/jrc-comms/hooks/boot.d` will be injected into `/opt/jrc/hooks/boot.d` based on script prefix automatically. For example:
3336

3437
- `05-mount-recovery-mount` runs first (found in `/opt/jrc/hooks/boot.d`)
@@ -41,6 +44,8 @@ The application runs scripts in ascending order based on their numeric prefixes.
4144
- Scripts with the same prefix may execute in lexicographical order, but avoid ambiguity by using unique prefixes
4245
- Scripts added to `/mnt/jrc-comms/hooks/boot.d` will persist AMI upgrades, stack clones, etc.
4346

47+
By following this structure, you can extend the boot process with custom logic while maintaining predictable execution order.
48+
4449
---
4550

4651
## Example Walkthrough
@@ -57,33 +62,32 @@ echo "Boot completed at: $(date)" >> $LOGFILE
5762
---
5863

5964
## Troubleshooting Tips
60-
1. **Test your script manually** before relying on the boot process:
65+
66+
##### 1. **Test your script manually** before relying on the boot process:
6167

6268
```bash
6369
sudo /mnt/jrc-comms/hooks/boot.d/99-custom-task
6470
```
6571

66-
2. **Check logs** for errors (e.g., `/var/log/syslog` or `journalctl`)
72+
##### 2. **Check logs** for errors (e.g., `/var/log/syslog` or `journalctl`)
6773

68-
3. **Validate script syntax** using:
74+
##### 3. **Validate script syntax** using:
6975

7076
```bash
7177
bash -n /mnt/jrc-comms/hooks/boot.d/99-custom-task
7278
```
7379

74-
By following this structure, you can extend the boot process with custom logic while maintaining predictable execution order.
75-
7680
---
7781

78-
### Alternative to fstab Mounting Using Boot Hook Script
82+
## Alternative to fstab Mounting Using Boot Hook Script
7983

8084
AutoPilot's boot hook system provides a more reliable alternative to `/etc/fstab` for bind mounts within dynamic environments, particularly when dealing with paths that might not be available during early boot stages.
8185

8286
The following is an example of how you would implement a boot hook script to create hard links. Typically this would be accomplished within `/etc/fstab`.
8387

84-
## Boot Hook Script Implementation
88+
### Boot Hook Script Implementation
8589

86-
### 1. Create /mnt/jrc-comms/hooks/boot.d/99-links Script
90+
##### 1. Create `/mnt/jrc-comms/hooks/boot.d/99-links` Script
8791

8892
Creates bind mounts after filesystems are available
8993

@@ -96,21 +100,22 @@ mount --bind /var/www/domain.com/shared/var/salesexport /home/user/salesexport
96100
mount --bind /var/www/domain.com/shared/media/importexport /home/user/importexport
97101
```
98102

99-
### 2. Set Permissions
103+
##### 2. Set Permissions
100104

101105
```bash
102106
sudo chmod +x /mnt/jrc-comms/hooks/boot.d/99-links
103107
sudo chown root:root /mnt/jrc-comms/hooks/boot.d/99-links
104108
```
105109

106-
## Verification
107-
1. **Validate script syntax**:
110+
### Verification
111+
112+
##### 1. **Validate script syntax**:
108113

109114
```bash
110115
bash -n /mnt/jrc-comms/hooks/boot.d/99-custom-task
111116
```
112117

113-
2. **Check active mounts**:
118+
##### 2. **Check active mounts**:
114119

115120
```bash
116121
mount | grep bind

0 commit comments

Comments
 (0)