#!/bin/bash

WRITABLE_DIR="/run/mnt/ubuntu-data/system-data/_writable_defaults"

# install the files the same way the specific device does this - note we don't
# create the directories since that requires extra permissions we don't have 
# here, system-files only allows us access to the specific files

# add a udev rule if executed from factory-reset
if snapctl system-mode | grep "factory-reset"; then
    cat << EOF > "$WRITABLE_DIR"/etc/udev/rules.d/from-factory-reset.conf
# this udev rule should only appear after factory-reset mode
EOF
    exit 0
fi

# add modprobe.d config
cat << EOF > "$WRITABLE_DIR"/etc/modprobe.d/from-install.conf
# this modprobe conf should only appear after install mode
EOF

# add modules-load.d config
cat << EOF > "$WRITABLE_DIR"/etc/modules-load.d/from-install.conf
# this module load conf should only appear after install mode
EOF
