source: OpenWorkouts-current/bin/install @ 7f335a4

currentfeature/docs
Last change on this file since 7f335a4 was 7f335a4, checked in by Borja Lopez <borja@…>, 5 years ago

Improved the install script:

  • Added some messages so the user knows what is going on
  • Added log file redirection of stdout and stderr (nicer output without all the pip and js_deps info)
  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/bin/sh
2#
3# Script to install OpenWorkouts for development
4#
5
6# Full path to where we run the script from
7current=`pwd`
8# Full path to the main python binary (will be set by check_python3())
9python_bin=''
10# Full path to the env
11env_path=${current}/env
12# full path to the install logs
13install_log=${current}/var/log/install.log
14
15set_scripts_permissions() {
16    echo "Setting up script permissions"
17    # ensure the shell scripts we will need have proper permissions
18    chmod u+x ${current}/bin/js_deps
19    chmod u+x ${current}/bin/start
20}
21
22check_python3() {
23    # if python3 is not installed, exit with an error
24    if command -v python3 > /dev/null; then
25        # ok
26        python_bin=`command -v python3`
27        echo "Found valid python installation: ${python_bin}"
28        return
29    else
30        # no python3 binary, look for python
31        if command -v python > /dev/null; then
32            # python found, check if it is 3.x
33            if `command -v python` -c "import sys; exit(0) if sys.version.startswith('3.') else exit(1)"; then
34                python_bin=`command -v python`
35                echo "Found valid python installation: ${python_bin}"
36                return
37            else
38                # no python binary, error
39                echo "Error: could not find a suitable python version installed, please install python 3.x"
40                exit 1
41            fi
42        else
43            # no python binary, error
44            echo "Error: could not find a suitable python version installed, please install python 3.x"
45            exit 1
46        fi
47    fi
48}
49
50create_venv() {
51    # create a new virtual environment
52    echo "Creating new python virtual environment [${env_path}]"
53    ${python_bin} -m venv ${env_path}
54}
55
56upgrade_pip_setuptools() {
57    . ${env_path}/bin/activate
58    echo "Upgrading python packaging tools"
59    yes | pip install --upgrade setuptools pip >> ${install_log}.stdout 2>> ${install_log}.stderr
60    deactivate
61}
62
63install_openworkouts() {
64    . ${env_path}/bin/activate
65    echo "Installing OpenWorkouts dependencies"
66    yes | pip install --upgrade -e ${current}[testing] >> ${install_log}.stdout 2>> ${install_log}.stderr
67    deactivate
68}
69
70install_js_deps() {
71    echo "Installing javascript components"
72    ${current}/bin/js_deps >> ${install_log}.stdout 2>> ${install_log}.stderr
73}
74
75setup_start_stop() {
76    echo "OpenWorkouts successfully installed in ${env_path}"
77    echo ""
78    echo "You can now start the OpenWorkouts service calling:"
79    echo ""
80    echo "  cd ${current} && ./bin/start"
81    echo ""
82    echo "(the installation script left a log under ${install_log})"
83    echo ""
84    # echo "You can stop any running OpenWorkouts instances calling:"
85    # echo ""
86    # echo "  ${current}/bin/stop"
87    # echo ""
88}
89
90set_scripts_permissions
91check_python3
92create_venv
93upgrade_pip_setuptools
94install_openworkouts
95install_js_deps
96setup_start_stop
Note: See TracBrowser for help on using the repository browser.