Mercurial > hg > config
annotate bin/install-k0s-web.sh @ 921:02b31a76e2c4
get DEST from command line
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 02 Jun 2024 16:35:01 -0700 |
parents | 531a7200649f |
children |
rev | line source |
---|---|
918
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env bash |
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
2 |
921 | 3 # This script installs the k0s.org web server in a virtual environment |
4 # in the directory specified by the first argument. | |
5 | |
6 # Example usage: | |
7 # install-k0s-web.sh "${HOME}"/web2 | |
8 | |
9 set -euo pipefail | |
918
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
10 |
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
11 PYTHON_VERSION="3.7" |
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
12 |
921 | 13 # Get DEST from "$1" |
14 # DEST="${HOME}/web3" | |
15 if [ "$#" -ne 1 ]; then | |
16 echo "Usage: $0 <destination>" | |
17 exit 1 | |
18 fi | |
19 DEST="$1" | |
20 if [ "${DEST:0:1}" != "/" ] | |
21 then | |
22 echo "Destination must be an absolute path" | |
23 exit 1 | |
24 fi | |
25 beginswith() { case $2 in "$1"*) true;; *) false;; esac; } | |
26 if ! beginswith "${HOME}" "${DEST}" | |
27 then | |
28 echo "Destination must be under your home directory" | |
29 exit 1 | |
30 fi | |
31 | |
32 set -x | |
33 | |
918
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
34 rm -rf "${DEST}" |
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
35 |
919
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
36 # Make a directory for k0s.org web |
918
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
37 mkdir -p "${DEST}" |
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
38 cd "${DEST}" |
919
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
39 |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
40 # Install the proper version of Python with pyenv |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
41 # See https://github.com/pyenv/pyenv/wiki#suggested-build-environment |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
42 pyenv install --skip-existing "${PYTHON_VERSION}" |
918
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
43 pyenv local "${PYTHON_VERSION}" |
9d89288e3b4c
add script for k0s.org web install
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
44 python --version |
919
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
45 |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
46 # Create a virtual environment |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
47 python -m venv . |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
48 |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
49 # Activate the virtual environment |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
50 . bin/activate |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
51 |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
52 # Install the required packages |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
53 bin/pip install --upgrade pip |
cc3b78bc4c21
install k0s.org requirements
Jeff Hammel <k0scist@gmail.com>
parents:
918
diff
changeset
|
54 bin/pip install -r "${HOME}"/web/requirements.txt |
920
531a7200649f
echo command to run new k0s web
Jeff Hammel <k0scist@gmail.com>
parents:
919
diff
changeset
|
55 |
531a7200649f
echo command to run new k0s web
Jeff Hammel <k0scist@gmail.com>
parents:
919
diff
changeset
|
56 # echo command to run the server |
921 | 57 set +x |
920
531a7200649f
echo command to run new k0s web
Jeff Hammel <k0scist@gmail.com>
parents:
919
diff
changeset
|
58 command="sudo ${DEST}/bin/paster serve /home/jhammel/web/paster-wsgintegrate.ini" |
531a7200649f
echo command to run new k0s web
Jeff Hammel <k0scist@gmail.com>
parents:
919
diff
changeset
|
59 echo "Run with:" |
531a7200649f
echo command to run new k0s web
Jeff Hammel <k0scist@gmail.com>
parents:
919
diff
changeset
|
60 echo "${command}" |