Skip to content

Commit

Permalink
Moved check for existing overlay file to INSTALL...
Browse files Browse the repository at this point in the history
Corrected grep argument for UNINSTALL
Added pull-up for GPIO 16 (ShutdownMonitor)
  • Loading branch information
herrfrei committed Aug 13, 2023
1 parent 03ef608 commit 2d3675f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ fi
if [ $scriptAction == 'INSTALL' ] ; then
updateActiveFile "$gpioListFile"
updateActiveFile "$rulesFile"
updateActiveFile "$overlayFile"
# install overlay only if it doesn't exist
[ -f "$overlayFile" ] || updateActiveFile "$overlayFile"

if [ $(grep -c "CAN+RS485 overlay" "$configFile") == 0 ]; then
logMessage "activating CAN+RS485 DT overlay"
echo "#### begin CAN+RS485 overlay" >> "$configFile"
echo "dtparam=spi=on" >> "$configFile"
echo "dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,,spimaxfrequency=1000000" >> "$configFile"
echo "dtoverlay=sc16is752-spi1,int_pin=24" >> "$configFile"
echo "gpio=16=ip,pu" >> "$configFile"
echo "#### end CAN+RS485 overlay" >> "$configFile"
filesUpdated=true
fi
Expand All @@ -107,13 +109,12 @@ fi
# if an install step failed package needs to be removed
if [ $scriptAction == 'UNINSTALL' ] ; then
restoreActiveFile "$gpioListFile"
restoreActiveFile "$rulesFile"
# install overlay only if it doesn't exist
[ -f "$overlayFile" ] || restoreActiveFile "$overlayFile"
restoreActiveFile "$rulesFile"
restoreActiveFile "$overlayFile"

# remove mods from configFile - do not use restore in case other mods were made manually
if [ -f "$configFile" ]; then
if [ $(grep -c "#### change all digital inputs to pull ups" "$configFile") != 0 ]; then
if [ $(grep -c "#### begin CAN+RS485 overlay" "$configFile") != 0 ]; then
sed -i -e '/#### begin CAN+RS485 overlay/,/#### end CAN+RS485 overlay/d' "$configFile"
filesUpdated=true
fi
Expand Down

0 comments on commit 2d3675f

Please sign in to comment.