File: kopano-grapi

package info (click to toggle)
kopanocore 8.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,400 kB
  • sloc: cpp: 175,422; python: 24,623; perl: 7,319; php: 6,056; sh: 2,172; makefile: 1,294; xml: 45; ansic: 1
file content (84 lines) | stat: -rwxr-xr-x 1,613 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/sh
#
# Kopano Groupware REST API (grapi) launcher
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright 2018 Kopano and its licensors
#

set -e

# Base defines.

EXE=/usr/libexec/kopano/kopano-mfr.py
PROCESS_NAME=grapi
PYTHON=python3
EXTRA_PYTHONPATH=
DEFAULT_SOCKET_PATH=/var/run/kopano-grapi
DEFAULT_NUM_WORKERS=8
DEFAULT_PID_FILE=${DEFAULT_SOCKET_PATH}/grapi.pid
DEFAULT_STORAGE_SERVER_SOCKET=file:///var/run/kopano/server.sock

# Handle parameters for configuration.

if [ -z "${1}" ]; then
	set -- "$@" --help
fi
case "${1}" in
	serve)
		# Inject values from environment into command line. This is mainly used
		# when this script is run from systemd or docker.

		shift

		if [ -z "$socket_path" ]; then
			socket_path="${DEFAULT_SOCKET_PATH}"
		fi

		if [ -z "$num_workers" ]; then
			num_workers=${DEFAULT_NUM_WORKERS}
		fi

		if [ -z "$pid_file" ]; then
			pid_file="${DEFAULT_PID_FILE}"
		fi

		if [ -z "$server_socket" ]; then
			server_socket="${DEFAULT_STORAGE_SERVER_SOCKET}"
		fi

		if [ "$insecure" = "yes" ]; then
			set -- "$@" --insecure
		fi

		set -- "$@" --socket-path="$socket_path" --workers="$num_workers" --pid-file="$pid_file" --process-name="${PROCESS_NAME}"

		# Environment.

		export KOPANO_SOCKET="$server_socket"

		# Try to create stuff.

		mkdir -p "$socket_path" || true
		mkdir -p $(dirname "$pid_file") || true

		;;

	*)
		;;
esac

# Setup python with extra path.

if [ -n "${EXTRA_PYTHONPATH}" -a -d "${EXTRA_PYTHONPATH}" ]; then
	export PYTHONPATH="${EXTRA_PYTHONPATH}:${PYTHONPATH}"
fi


# Set executable.

set -- "${PYTHON}" "${EXE}" "$@"

# Run.

exec "$@"