Skip to content

Commit

Permalink
install: boards: Use sed over truncate to add cgroups
Browse files Browse the repository at this point in the history
Truncate can remove characters of files that does not have a line break
Sed can add the text on the first line without problems

Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Dec 8, 2022
1 parent 12e21b7 commit ffa3bca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions install/boards/bcm_27xx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ sudo sed -e 's/console=serial[0-9],[0-9]*\ //' -i $CMDLINE_FILE
# Set cgroup, necessary for docker access to memory information
echo "- Enable cgroup with memory and cpu"
grep -q cgroup $CMDLINE_FILE || (
truncate --size -1 $CMDLINE_FILE
echo " cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory" >> $CMDLINE_FILE
# Append cgroups on the first line
sed -i '1 s/$/ cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory/' $CMDLINE_FILE
)

# Update raspberry pi firmware
Expand Down
4 changes: 2 additions & 2 deletions install/boards/bcm_28xx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ sudo sed -e 's/console=serial[0-9],[0-9]*\ //' -i $CMDLINE_FILE
# Set cgroup, necessary for docker access to memory information
echo "- Enable cgroup with memory and cpu"
grep -q cgroup $CMDLINE_FILE || (
truncate --size -1 $CMDLINE_FILE
echo " cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory" >> $CMDLINE_FILE
# Append cgroups on the first line
sed -i '1 s/$/ cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory/' $CMDLINE_FILE
)

0 comments on commit ffa3bca

Please sign in to comment.