Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ramdisk settings #1650

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/config/ramdisk_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# openwb - begin
# openwb-version:1
# Do not edit this section! We need begin/end and version for proper updates!
tmpfs /var/www/html/openWB/ramdisk tmpfs nodev,nosuid,size=48M 0 0
# openwb - end
4 changes: 2 additions & 2 deletions openwb-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ else
fi

echo -n "check for ramdisk... "
if grep -Fxq "tmpfs ${OPENWBBASEDIR}/ramdisk tmpfs nodev,nosuid,size=32M 0 0" /etc/fstab; then
if grep -Fq "tmpfs ${OPENWBBASEDIR}/ramdisk" /etc/fstab; then
echo "ok"
else
mkdir -p "${OPENWBBASEDIR}/ramdisk"
echo "tmpfs ${OPENWBBASEDIR}/ramdisk tmpfs nodev,nosuid,size=32M 0 0" >> /etc/fstab
sudo tee -a "/etc/fstab" <"${OPENWBBASEDIR}/data/config/ramdisk_config.txt" >/dev/null
mount -a
echo "created"
fi
Expand Down
24 changes: 24 additions & 0 deletions runs/atreboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,30 @@ chmod 666 "$LOGFILE"
echo "new configuration active after next boot"
fi

ramdisk_config_source="${OPENWBBASEDIR}/data/config/ramdisk_config.txt"
ramdisk_config_target="/etc/fstab"
echo "checking ramdisk settings in $ramdisk_config_target..."
if versionMatch "$ramdisk_config_source" "$ramdisk_config_target"; then
echo "already up to date"
else
echo "openwb section not found or outdated"
# delete old settings with version tag
pattern_begin=$(grep -m 1 '#' "$ramdisk_config_source")
pattern_end=$(grep '#' "$ramdisk_config_source" | tail -n 1)
sudo sed -i "/$pattern_begin/,/$pattern_end/d" "$ramdisk_config_target"
# check for old settings without version tag
if grep -o "tmpfs ${OPENWBBASEDIR}/ramdisk" "$ramdisk_config_target"; then
echo "old setting without version tag found, removing"
sudo sed -i "\#tmpfs ${OPENWBBASEDIR}/ramdisk#D" "$ramdisk_config_target"
fi
# add new settings
echo "adding ramdisk settings to $ramdisk_config_target..."
sudo tee -a "$ramdisk_config_target" <"$ramdisk_config_source" >/dev/null
echo "done"
echo "rebooting system"
sudo reboot now &
fi

# check group membership
echo "Group membership..."
# ToDo: remove sudo group membership if possible
Expand Down