Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RichardBronosky/cf1bda1825ba7d431c6fa07a344d5a53 to your computer and use it in GitHub Desktop.
Save RichardBronosky/cf1bda1825ba7d431c6fa07a344d5a53 to your computer and use it in GitHub Desktop.
Use standard Linux run-parts utility to run *.sh in /boot/per-boot.d/ and /boot/per-once.d/
[Unit]
Description=Run user provided scripts on boot
ConditionPathExists=/usr/lib/raspi-ini/run-parts.sh
Before=dhcpcd.service # Need to put more thought into when
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/raspi-ini/run-parts.sh
[Install]
WantedBy=multi-user.target
#!/bin/bash
# Prevent *.sh from returning itself if there are no matches
shopt -s nullglob
# Run every per-once script
run-parts --regex '.*\.sh$' /boot/per-once
# Rename every per-once script
for f in /boot/per-once/*.sh; do
mv $f $(dirname $f)/$(basename $f .sh).$(date +%F@%H.%M.%S)
done
# Run every per-boot script
run-parts --regex '.*\.sh$' /boot/per-boot
@claytongulick
Copy link

Might want to tweak the description to remove the per-once.d and per-boot.d, since it doesn't use the '.d' on those directories. Thanks for the useful script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment