Skip to content

Commit

Permalink
init: move modprobing modules from S94bmcd to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
rbakbashev authored and svenrademakers committed Dec 14, 2023
1 parent d26db40 commit 4ec8f83
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
56 changes: 56 additions & 0 deletions tp2bmc/board/tp2bmc/overlay/etc/init.d/S92modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

MODULES="modules"

load_unload() {
[ ! -f /etc/${MODULES} ] && echo ' OK' && exit 0

while read module args; do

case "$module" in
""|"#"*) continue ;;
esac

if [ "$1" = "load" ]; then
modprobe -q ${module} ${args} >/dev/null && \
printf ' %s success,' "$module" ||
printf ' %s failed,' "$module"
else
rmmod ${module} >/dev/null
fi

done < /etc/${MODULES}
}

start() {
printf 'Starting %s:' "$MODULES"

load_unload load

echo ' OK'
}

stop() {
printf 'Stopping %s: ' "$MODULES"

load_unload unload

echo 'OK'
}

restart() {
stop
sleep 1
start
}

case "$1" in
start|stop|restart)
"$1";;
reload)
# Restart, since there is no true "reload" feature.
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
1 change: 1 addition & 0 deletions tp2bmc/board/tp2bmc/overlay/etc/modules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rockusb
2 changes: 0 additions & 2 deletions tp2bmc/package/bmcd/S94bmcd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ KEYFILE="/etc/ssl/certs/bmcd_key.pem"
start() {
printf 'Starting %s...\n' "$DAEMON"

modprobe rockusb

[ ! -f "$CERTFILE" ] || [ ! -f "$KEYFILE" ] && /etc/bmcd/generate_self_signedx509.sh

start-stop-daemon --start --quiet --background --make-pidfile --pidfile "$PIDFILE" --no-close \
Expand Down

0 comments on commit 4ec8f83

Please sign in to comment.