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

Commit 62102f3

Browse files
committed
Allow restoring to default
1 parent f0cd761 commit 62102f3

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

readme-vars.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ param_volumes:
2525
# optional container parameters
2626
opt_param_usage_include_env: true
2727
opt_param_env_vars:
28-
- { env_var: "MEM_LIMIT", env_value: "1024M", desc: "Optionally change the Java memory limit (-Xmx) (default is 1024M)." }
29-
- { env_var: "MEM_STARTUP", env_value: "1024M", desc: "Optionally change the Java initial memory (-Xms) (default is 1024M)." }
28+
- { env_var: "MEM_LIMIT", env_value: "1024", desc: "Optionally change the Java memory limit. Set to `default` to reset to default" }
29+
- { env_var: "MEM_STARTUP", env_value: "1024", desc: "Optionally change the Java initial/minimum memory. Set to `default` to reset to default" }
3030

3131
param_usage_include_ports: true
3232
param_ports:

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,30 @@ fi
2323

2424
if grep -q "xmx" /config/data/system.properties && grep -q "xms" /config/data/system.properties; then
2525

26-
if [[ -n $MEM_LIMIT ]]; then
26+
if [[ $MEM_LIMIT == "default" ]]; then
27+
echo "*** Setting Java memory limit to default ***"
28+
sed -i "/unifi.xmx=.*/d" /config/data/system.properties
29+
elif [[ -n $MEM_LIMIT ]]; then
2730
echo "*** Setting Java memory limit to $MEM_LIMIT ***"
2831
sed -i "s/unifi.xmx=.*/unifi.xmx=$MEM_LIMIT/" /config/data/system.properties
2932
fi
3033

31-
if [[ -n $MEM_STARTUP ]]; then
34+
if [[ $MEM_STARTUP == "default" ]]; then
35+
echo "*** Setting Java memory minimum to default ***"
36+
sed -i "/unifi.xms=.*/d" /config/data/system.properties
37+
elif [[ -n $MEM_STARTUP ]]; then
3238
echo "*** Setting Java memory minimum to $MEM_STARTUP ***"
3339
sed -i "s/unifi.xms=.*/unifi.xms=$MEM_STARTUP/" /config/data/system.properties
3440
fi
3541

3642
elif grep -q "xmx" /config/data/system.properties; then
3743

38-
if [[ -n $MEM_LIMIT ]]; then
44+
if [[ $MEM_LIMIT == "default" ]]; then
45+
echo "*** Setting Java memory limit to default ***"
46+
sed -i "/unifi.xmx=.*/d" /config/data/system.properties
47+
elif [[ -n $MEM_LIMIT ]]; then
3948
echo "*** Setting Java memory limit to $MEM_LIMIT ***"
40-
sed -i "s/unifi.xmx=.*/unifi.xmx=$MEM_LIMIT/" /config/data/system.properties
49+
sed -i "s/unifi.xmx=.*/unifi.xmx=$MEM_LIMIT/" /config/data/system.properties
4150
fi
4251

4352
if [[ -n $MEM_STARTUP ]]; then
@@ -47,7 +56,10 @@ elif grep -q "xmx" /config/data/system.properties; then
4756

4857
elif grep -q "xms" /config/data/system.properties; then
4958

50-
if [[ -n $MEM_STARTUP ]]; then
59+
if [[ $MEM_STARTUP == "default" ]]; then
60+
echo "*** Setting Java memory minimum to default ***"
61+
sed -i "/unifi.xms=.*/d" /config/data/system.properties
62+
elif [[ -n $MEM_STARTUP ]]; then
5163
echo "*** Setting Java memory minimum to $MEM_STARTUP ***"
5264
sed -i "s/unifi.xms=.*/unifi.xms=$MEM_STARTUP/" /config/data/system.properties
5365
fi

0 commit comments

Comments
 (0)