|
17 | 17 | [[ ! -L "$i" ]] && ln -s /config/"$(basename "$i")" "$i" |
18 | 18 | done |
19 | 19 |
|
| 20 | +if [[ ! -e /config/data/system.properties ]]; then |
| 21 | + cp /defaults/system.properties /config/data |
| 22 | +fi |
| 23 | + |
| 24 | +if grep -q "xmx" /config/data/system.properties && grep -q "xms" /config/data/system.properties; then |
| 25 | + |
| 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 |
| 30 | + echo "*** Setting Java memory limit to $MEM_LIMIT ***" |
| 31 | + sed -i "s/unifi.xmx=.*/unifi.xmx=$MEM_LIMIT/" /config/data/system.properties |
| 32 | + fi |
| 33 | + |
| 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 |
| 38 | + echo "*** Setting Java memory minimum to $MEM_STARTUP ***" |
| 39 | + sed -i "s/unifi.xms=.*/unifi.xms=$MEM_STARTUP/" /config/data/system.properties |
| 40 | + fi |
| 41 | + |
| 42 | +elif grep -q "xmx" /config/data/system.properties; then |
| 43 | + |
| 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 |
| 48 | + echo "*** Setting Java memory limit to $MEM_LIMIT ***" |
| 49 | + sed -i "s/unifi.xmx=.*/unifi.xmx=$MEM_LIMIT/" /config/data/system.properties |
| 50 | + fi |
| 51 | + |
| 52 | + if [[ -n $MEM_STARTUP ]]; then |
| 53 | + echo "*** Setting Java memory minimum to $MEM_STARTUP ***" |
| 54 | + echo "unifi.xms=$MEM_STARTUP" >> /config/data/system.properties |
| 55 | + fi |
| 56 | + |
| 57 | +elif grep -q "xms" /config/data/system.properties; then |
| 58 | + |
| 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 |
| 63 | + echo "*** Setting Java memory minimum to $MEM_STARTUP ***" |
| 64 | + sed -i "s/unifi.xms=.*/unifi.xms=$MEM_STARTUP/" /config/data/system.properties |
| 65 | + fi |
| 66 | + |
| 67 | + if [[ -n $MEM_LIMIT ]]; then |
| 68 | + echo "*** Setting Java memory limit to $MEM_LIMIT ***" |
| 69 | + echo "unifi.xmx=$MEM_LIMIT" >> /config/data/system.properties |
| 70 | + fi |
| 71 | + |
| 72 | +else |
| 73 | + |
| 74 | + if [[ -n $MEM_LIMIT ]]; then |
| 75 | + echo "*** Setting Java memory limit to $MEM_LIMIT ***" |
| 76 | + echo "unifi.xmx=$MEM_LIMIT" >> /config/data/system.properties |
| 77 | + fi |
| 78 | + |
| 79 | + if [[ -n $MEM_STARTUP ]]; then |
| 80 | + echo "*** Setting Java memory minimum to $MEM_STARTUP ***" |
| 81 | + echo "unifi.xms=$MEM_STARTUP" >> /config/data/system.properties |
| 82 | + fi |
| 83 | + |
| 84 | +fi |
| 85 | + |
20 | 86 | # permissions |
21 | 87 | chown -R abc:abc \ |
22 | 88 | /config \ |
|
0 commit comments