-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit
executable file
·84 lines (73 loc) · 2.63 KB
/
init
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
#!/usr/bin/env bash
# Raspi OS (Debian) and Manjaro (Arch) differ in $0 for sourced scripts
# BASH_SOURCE is always the script, sourced or executed
# BASH_ARGV0 is the script or "-bash" (when sourced)
MySelf=$(realpath "$BASH_SOURCE")
MyHome=$(dirname "$MySelf")
QuestRel="7.1.3"
Envir=${1:-"Devel"} # else "Prod"
if [[ $(basename -- "$BASH_ARGV0") = $(basename -- "${MySelf}") ]]
then
echo "ERROR: this script must be sourced: '. ${MySelf}/init'"
exit 10
fi
if [ -n "$ZSH_VERSION" ]
then
echo "ERROR: this script supports _bash_ only, sorry"
return 11
fi
if [[ ! -d "${MyHome}/venv" ]]
then
echo "First time init of aquaPi development env."
read -p "CR to continue / Ctrl-C to cancel" dummy
cd "${MyHome}" || return 12
git submodule init
git submodule update
# Debian derivatives don't come with py3 venv by default
grep -i debian /usr/lib/os-release && sudo apt-get install python3-venv
# NOTE: You can append --system-site-packages to inherit all
# packages installed globally, e.g. your vim's jedi. The
# release environment should not, to ensure requirements are complete.
if [ ${Envir^^} == "DEVEL" ]
then
python3 -m venv venv --system-site-packages
else
python3 -m venv venv
fi
fi
echo "Activate aquaPi development env."
cd "${MyHome}" || return 12
. ./venv/bin/activate
echo "===== get all python packages"
pip3 install -r requirements.txt
echo "====="
if [ $(getconf LONG_BIT) == 64 ]
then
if [ -z "$(ls -d "${MyHome}/questdb-${QuestRel}/" 2>/dev/null)" ]
then
if ( grep -i arm /proc/cpuinfo >/dev/null )
then
echo "===== install Quest DB & JRE 11"
tar -xvf questdb-${QuestRel}-no-jre-bin.tar.gz
mv questdb-${QuestRel}-no-jre-bin questdb-${QuestRel}
apt install default-jre
else
echo "===== install Quest DB incl. JRE for AMD64"
tar -xvf questdb-${QuestRel}-rt-linux-amd64.tar.gz
mv questdb-${QuestRel}-rt-linux-amd64 questdb-${QuestRel}
fi
fi
pip3 install 'psycopg[binary]>=3.1.9'
echo "===== ... and start QuestDB"
"${MyHome}/questdb-${QuestRel}/bin/questdb.sh" start
echo "You can interact with Quest DB in your browser at localhost:9000"
echo "====="
fi
echo "There are two scripts to run the development server:"
echo " './run' should be used to start the software in a SSH"
echo " shell, termination of the shell will not hang up (HUP)"
echo " the process, and output is tee-ed to run.log"
echo " './dbg' starts without output redirect to allow debugger"
echo " interaction. If used via SSH the process will die"
echo " when you close the shell."
echo "Use your browser to see the UI at 'http://$(hostname -i):5000'"