/ docker / proxy-entry.sh
proxy-entry.sh
 1  #!/bin/bash
 2  
 3  echo "Thank you for using Lineage2TS project, see more at https://gitlab.com/MrTREX/lineage2ts"
 4  
 5  psoptions=${PS_NODE_OPTIONS:-""}
 6  proxypid=0
 7  
 8  # SIGUSR1-handler
 9  # SIGUSR2-handler
10  user_handler() {
11    if [ $proxypid -ne 0 ]; then
12      kill -SIGTERM "$proxypid"
13      wait "$proxypid"
14    fi
15  
16    exit 130; # 128 + 2 -- SIGUSR1
17  }
18  
19  # SIGTERM-handler
20  # SIGINT-handler
21  sigterm_handler() {
22    if [ $proxypid -ne 0 ]; then
23      kill -SIGTERM "$proxypid"
24      wait "$proxypid"
25    fi
26  
27    exit 143; # 128 + 15 -- SIGTERM
28  }
29  
30  trap 'kill ${!}; user_handler' SIGUSR1
31  trap 'kill ${!}; user_handler' SIGUSR2
32  trap 'kill ${!}; sigterm_handler' SIGTERM
33  trap 'kill ${!}; sigterm_handler' SIGINT
34  
35  cd /opt/lineage2ts || exit
36  
37  if [ -f node_modules.7z ]; then
38      echo "Found compressed node dependencies. Decompressing..."
39      7z x node_modules.7z -y > nul
40      rm -f node_modules.7z
41      echo "Finished decompressing node dependencies"
42  fi
43  
44  # proxy server
45  if [ -n "$psoptions" ]; then
46      exec node "$psoptions" /opt/lineage2ts/proxy/dist/source/Start.js &
47  else
48      exec node /opt/lineage2ts/proxy/dist/source/Start.js &
49  fi
50  
51  proxypid="$!"
52  
53  # wait forever
54  while true
55  do
56    tail -f /dev/null & wait ${!}
57  done