-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New helper to load all configured kernel modules and set their parameters. If the script fails to set a parameter, it exists with special code 99
- Loading branch information
1 parent
104e54b
commit e8a171c
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
|
||
# Load all kernel modules from /etc/modules.d/ns-nathelpers | ||
# Example: | ||
# nf_conntrack_sip sip_external_media=1 sip_direct_media=1 | ||
|
||
exit_code=0 | ||
|
||
# Load all module | ||
for line in "$(grep -v '^#' /etc/modules.d/ns-nathelpers)"; do | ||
module=$(echo $line | awk '{print $1}') | ||
modprobe $module | ||
for param in $(echo $line | awk '{for(i=2;i<=NF;++i)print $i}'); do | ||
# Set parameter using /sys since modprobe doesn't support parameters | ||
key=$(echo $param | cut -d= -f1) | ||
value=$(echo $param | cut -d= -f2) | ||
echo $value > /sys/module/$module/parameters/$key | ||
if [ $? -ne 0 ]; then | ||
exit_code=99 | ||
fi | ||
done | ||
done | ||
|
||
# Special exit code 99 means that at least one parameter failed to be set | ||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# Copyright (C) 2024 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
|
||
# Load all kernel modules from /etc/modules.d/ns-nathelpers | ||
# Example: | ||
# nf_conntrack_sip sip_external_media=1 sip_direct_media=1 | ||
|
||
exit_code=0 | ||
|
||
# Load all module | ||
for line in "$(grep -v '^#' /etc/modules.d/ns-nathelpers)"; do | ||
module=$(echo $line | awk '{print $1}') | ||
modprobe $module | ||
exit_code=$? | ||
for param in $(echo $line | awk '{for(i=2;i<=NF;++i)print $i}'); do | ||
# Set parameter using /sys since modprobe doesn't support parameters | ||
key=$(echo $param | cut -d= -f1) | ||
value=$(echo $param | cut -d= -f2) | ||
echo $value > /sys/module/$module/parameters/$key | ||
if [ $? -ne 0 ]; then | ||
exit_code=99 | ||
fi | ||
done | ||
done | ||
|
||
# Special exit code 99 means that at least one parameter failed to be set | ||
exit $exit_code |