1*531fbc25SLei YU#!/bin/bash
2*531fbc25SLei YUset -eo pipefail
3*531fbc25SLei YU
4*531fbc25SLei YU# Check the /sys/class/watchdog/watchdog1/access_cs0 and tell if it's running on the primary or the secondary flash.
5*531fbc25SLei YU
6*531fbc25SLei YUACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
7*531fbc25SLei YUSLOT_FILE="/run/media/slot"
8*531fbc25SLei YU
9*531fbc25SLei YU# Create directory if not exist
10*531fbc25SLei YUmkdir -p "$(dirname "${SLOT_FILE}")"
11*531fbc25SLei YU
12*531fbc25SLei YU# Write slot info
13*531fbc25SLei YUif [ -f ${ACCESS_CS0} ]; then
14*531fbc25SLei YU    echo "1" > ${SLOT_FILE}
15*531fbc25SLei YUelse
16*531fbc25SLei YU    echo "0" > ${SLOT_FILE}
17*531fbc25SLei YUfi
18