Skip to content
This repository was archived by the owner on Jan 7, 2024. It is now read-only.

Commit 9381064

Browse files
committed
Update existing values if found
1 parent fa5afd9 commit 9381064

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

root/etc/cont-init.d/20-config

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,30 @@ if [[ ! -e /config/data/system.properties ]]; then
2121
cp /defaults/system.properties /config/data
2222
fi
2323

24-
if [[ -n $MEM_LIMIT ]]; then
25-
echo "*** Setting Java memory limit to $MEM_LIMIT ***"
26-
echo "unifi.xmx=$MEM_LIMIT" >> /config/data/system.properties
27-
fi
24+
if grep -q "xmx" /config/data/system.properties && grep -q "xms" /config/data/system.properties; then
25+
26+
if [[ -n $MEM_LIMIT ]]; then
27+
echo "*** Setting Java memory limit to $MEM_LIMIT ***"
28+
sed -i "s/unifi.xmx=.*/unifi.xmx=$MEM_LIMIT/" /config/data/system.properties
29+
fi
30+
31+
if [[ -n $MEM_STARTUP ]]; then
32+
echo "*** Setting Java memory minimum to $MEM_STARTUP ***"
33+
sed -i "s/unifi.xms=.*/unifi.xms=$MEM_STARTUP/" /config/data/system.properties
34+
fi
35+
36+
else
37+
38+
if [[ -n $MEM_LIMIT ]]; then
39+
echo "*** Setting Java memory limit to $MEM_LIMIT ***"
40+
echo "unifi.xmx=$MEM_LIMIT" >> /config/data/system.properties
41+
fi
42+
43+
if [[ -n $MEM_STARTUP ]]; then
44+
echo "*** Setting Java memory minimum to $MEM_STARTUP ***"
45+
echo "unifi.xms=$MEM_STARTUP" >> /config/data/system.properties
46+
fi
2847

29-
if [[ -n $MEM_STARTUP ]]; then
30-
echo "*** Setting Java memory minimum to $MEM_STARTUP ***"
31-
echo "unifi.xms=$MEM_STARTUP" >> /config/data/system.properties
3248
fi
3349

3450
# permissions

0 commit comments

Comments
 (0)