Running commands at boot with iso-ignored boot mode

When iso-ignored boot mode is configured, complete the following steps on each appliance that should run commands at boot.

About this task

If you configured the appliance to boot in iso-ignored mode as documented in Appliance boot mode configuration, the bootcmd lines will be ignored. For each appliance node that should run commands at boot, complete the following steps.

Procedure

  1. SSH into the appliance as root.
  2. Create the /usr/local/bin/appliance-boot-commands.sh script to be executed at boot; for example:
    cat << EOF > /usr/local/bin/appliance-boot-commands.sh
    #!/bin/bash
    
    ip route add 172.27.218.0/24 via 192.168.122.1 dev eth0
    ip route add 172.26.203.0/24 via 192.168.122.1 dev eth0
    EOF

    This step takes the same example, and essentially achieves the same result, as the procedure in Adding a static route on a virtual machine.

  3. Make the script executable by running the following command:
    chmod +x /usr/local/bin/appliance-boot-commands.sh
  4. Create the following systemd service file /lib/systemd/system/appliance-boot-commands.service:
    cat << EOF > /lib/systemd/system/appliance-boot-commands.service
    [Unit]
    After=network-online.target
    
    [Service]
    Type=oneshot
    ExecStart=/usr/local/bin/appliance-boot-commands.sh
    RemainAfterExit=false
    StandardOutput=journal
    
    [Install]
    WantedBy=multi-user.target
    EOF
  5. Enable the systemd service by running the following command:
    systemctl enable appliance-boot-commands

    Upon subsequent boots, the /usr/local/bin/appliance-boot-command.sh script will be executed.