-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path95-jammy-cloud-init-fixup
More file actions
executable file
·32 lines (25 loc) · 1.03 KB
/
95-jammy-cloud-init-fixup
File metadata and controls
executable file
·32 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Exit immediately if a command exits with a non-zero status (-e),
# treat unset variables as an error and exit immediately (-u),
# and ensure that a pipeline fails if any part fails (-o pipefail).
set -euo pipefail
# Display a message indicating the purpose of the script
echo "Creating systemd override for cloud-init-local.service to ensure it starts after /var is mounted"
# Define the path to the systemd override directory
OVERRIDE_DIR="/etc/systemd/system/cloud-init-local.service.d"
# Create the override directory if it doesn't already exist
mkdir -p "${OVERRIDE_DIR}"
# Define the path to the override file
OVERRIDE_FILE="${OVERRIDE_DIR}/override.conf"
# Write the override configuration
cat <<EOF >"${OVERRIDE_FILE}"
[Unit]
Requires=var.mount
After=var.mount
RequiresMountsFor=/var/lib/cloud
EOF
# Ensure correct permissions
chmod 755 "${OVERRIDE_DIR}"
chmod 644 "${OVERRIDE_FILE}"
# Display a message indicating that the override has been created
echo "Systemd override for cloud-init-local.service created successfully"