forked from skalanux/docker-gnuhealth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gnuhealthrc
83 lines (60 loc) · 2.63 KB
/
gnuhealthrc
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
# GNU Health BASH environment
# 2013-2018 Luis Falcon <[email protected]>
# File Editor
export EDITOR=vi
GNUHEALTH_DIR="${HOME}/gnuhealth"
if ! type $EDITOR >/dev/null ; then
echo "$EDITOR not found"
fi
# Add Environment Variables for Docker passed variables.
set -e
: ${DB_USER:=${POSTGRES_ENV_POSTGRES_USER:='postgres'}}
: ${DB_PASSWORD:=${POSTGRES_ENV_POSTGRES_PASSWORD}}
: ${DB_HOSTNAME:=${POSTGRES_PORT_5432_TCP_ADDR:='postgres'}}
: ${DB_PORT:=${POSTGRES_PORT_5432_TCP_PORT:='5432'}}
: ${TRYTOND_DATABASE__URI:="postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOSTNAME}:${DB_PORT}/"}
: ${PYTHONOPTIMIZE:=1}
export TRYTOND_DATABASE__URI PYTHONOPTIMIZE
# Get the most current Tryton server version
# It should only be one trytond, but just in case..
TRYTOND=`ls -1d ${GNUHEALTH_DIR}/tryton/server/trytond-* | egrep -o "trytond-[0-9\.]+.[0-9\.]+.[0-9\.]+" | sort -V | tail -1`
export TRYTON_VERSION=`echo $TRYTOND | cut -d'-' -f2`
export TRYTOND
# Add PYTHONPATH environment variable
export PYTHONPATH=${GNUHEALTH_DIR}/tryton/server/${TRYTOND}:${GNUHEALTH_DIR}/tryton/server/config
# Include local directory (gunicorn and other python executables)
export PATH=$PATH:$HOME/.local/bin
# Add Tryton server configuration file
export TRYTOND_CONFIG=${GNUHEALTH_DIR}/tryton/server/config/trytond.conf
sed -E -i "s|^uri = postgresql://localhost:5432|uri = "${TRYTOND_DATABASE__URI}"|" $TRYTOND_CONFIG
if grep -Fxq "[ldap_authentication]" $TRYTOND_CONFIG
then
echo "Doing nothing..."
else
# Build [ldap_authentication]
printf "\n[ldap_authentication]\nuri = %s:389/cn=Users,dc=corp,dc=gnuhealth,dc=testing????bindname=cn=Administrator,dc=corp,dc=gnuhealth,dc=testing\nbind_pass = %s\nuid = sAMAccountName\n" "${TRYTOND_LDAP_AUTHENTICATION__URI}" "${LDAP_PASSWORD}" >> $HOME/gnuhealth/tryton/server/config/trytond.conf
fi
if grep -Fxq "[session]" $TRYTOND_CONFIG
then
echo "Doing nothing..."
else
# Build [session]
printf "\n[session]\nauthentications = password,ldap" >> $HOME/gnuhealth/tryton/server/config/trytond.conf
fi
# Aliases
alias cdlogs='cd ${GNUHEALTH_DIR}/logs'
alias cdexe='cd ${GNUHEALTH_DIR}/tryton/server/${TRYTOND}/bin'
alias cdutil='cd ${GNUHEALTH_DIR}/tryton/server/util'
alias cdconf='cd ${GNUHEALTH_DIR}/tryton/server/config'
alias cdmods='cd ${GNUHEALTH_DIR}/tryton/server/modules'
alias editconf='${EDITOR} ${TRYTOND_CONFIG}'
# Protect from accidental deletions
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
#GNU HEALTH version
export GNUHEALTH_VERSION=`cat ${GNUHEALTH_DIR}/version`
# Commented to be compatible with FreeBSD
# alias ls='ls --color=auto'
#Prompt
PS1="\[\e[32;2m\]\u@\h:\[\e[30;0m\]\w $ \[\e[0m\]"