annotate bin/install-k0s-web.sh @ 923:b25fbb9257ec default tip

Breeze GTK theme
author Jeff Hammel <k0scist@gmail.com>
date Thu, 14 Nov 2024 09:30:28 -0800
parents 02b31a76e2c4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
3 # This script installs the k0s.org web server in a virtual environment
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
4 # in the directory specified by the first argument.
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
5
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
6 # Example usage:
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
7 # install-k0s-web.sh "${HOME}"/web2
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
8
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
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
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
13 # Get DEST from "$1"
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
14 # DEST="${HOME}/web3"
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
15 if [ "$#" -ne 1 ]; then
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
16 echo "Usage: $0 <destination>"
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
17 exit 1
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
18 fi
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
19 DEST="$1"
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
20 if [ "${DEST:0:1}" != "/" ]
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
21 then
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
22 echo "Destination must be an absolute path"
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
23 exit 1
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
24 fi
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
25 beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
26 if ! beginswith "${HOME}" "${DEST}"
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
27 then
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
28 echo "Destination must be under your home directory"
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
29 exit 1
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
30 fi
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
31
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
32 set -x
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
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
02b31a76e2c4 get DEST from command line
Jeff Hammel <k0scist@gmail.com>
parents: 920
diff changeset
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}"