From 6a9de6e3c4848ed2933ab6ffeb04019a7e2a772d Mon Sep 17 00:00:00 2001 From: "D. Ror." Date: Tue, 15 Oct 2024 14:11:18 -0400 Subject: [PATCH] [installer] Use --dependency-update; Fix debugging; Remove junk dirs (#3402) --- deploy/scripts/install-combine.sh | 21 +++-- deploy/scripts/kube_env.py | 13 +-- deploy/scripts/package_images.py | 132 +++++++++++++++++----------- deploy/scripts/setup_cluster.py | 11 ++- deploy/scripts/setup_combine.py | 19 ++-- deploy/scripts/uninstall-combine | 52 +++++------ deploy/scripts/utils.py | 2 +- installer/README.md | 98 +++++++++------------ installer/make-combine-installer.sh | 21 +++-- 9 files changed, 202 insertions(+), 167 deletions(-) diff --git a/deploy/scripts/install-combine.sh b/deploy/scripts/install-combine.sh index 3a46c8c441..0432f2b427 100755 --- a/deploy/scripts/install-combine.sh +++ b/deploy/scripts/install-combine.sh @@ -7,8 +7,9 @@ set -eo pipefail # It should only be executed directly by developers. For general users, it is packaged in # a stand-alone installer (see ./installer/README.md or ./installer/README.pdf). # -# The options for this script and for the packaged installer are the same. Note that 2 -# additional debugging options are available that aren't documented in the readme file: +# The options for this script and for the packaged installer are the same. Note that some +# additional dev options are available that aren't documented in the readme file: +# - debug - show more verbose output for debugging. # - single-step - run the next "step" in the installation process and stop. # - start-at - start at the step named and run to completion. # @@ -57,7 +58,7 @@ create-python-venv () { python3 -m venv venv source venv/bin/activate echo "Install pip and pip-tools" - python -m pip install --upgrade pip pip-tools + python -m pip $((( DEBUG == 0)) && echo "-q") install --upgrade pip pip-tools echo "Install dependencies" python -m piptools sync requirements.txt } @@ -78,9 +79,9 @@ install-kubernetes () { cd ${DEPLOY_DIR}/ansible if [ -d "${DEPLOY_DIR}/airgap-images" ] ; then - ansible-playbook playbook_desktop_setup.yml -K -e k8s_user=`whoami` -e install_airgap_images=true + ansible-playbook playbook_desktop_setup.yml -K -e k8s_user=`whoami` -e install_airgap_images=true $(((DEBUG == 1)) && echo "-vv") else - ansible-playbook playbook_desktop_setup.yml -K -e k8s_user=`whoami` + ansible-playbook playbook_desktop_setup.yml -K -e k8s_user=`whoami` $(((DEBUG == 1)) && echo "-vv") fi } @@ -97,7 +98,7 @@ set-k3s-env () { export KUBECONFIG=${K3S_CONFIG_FILE} ##### # Start k3s if it is not running - if ! systemctl is-active --quiet k3s ; then + if ! systemctl is-active $(((DEBUG == 0)) && echo "--quiet") k3s ; then sudo systemctl start k3s fi } @@ -137,7 +138,7 @@ install-the-combine () { cd ${DEPLOY_DIR}/scripts set-combine-env set-k3s-env - ./setup_combine.py --tag ${COMBINE_VERSION} --repo public.ecr.aws/thecombine --target desktop ${SETUP_OPTS} --debug + ./setup_combine.py --tag ${COMBINE_VERSION} --repo public.ecr.aws/thecombine --target desktop ${SETUP_OPTS} $(((DEBUG == 1)) && echo "--debug") deactivate } @@ -175,7 +176,7 @@ next-state () { # Verify that the required network devices have been setup for Kubernetes cluster wait-for-k8s-interfaces () { - echo "Waiting for k8s interfaces" + echo "Waiting for k8s interfaces: $@" for interface in $@ ; do while ! ip link show $interface > /dev/null 2>&1 ; do sleep 1 @@ -192,6 +193,7 @@ CONFIG_DIR=${HOME}/.config/combine mkdir -p ${CONFIG_DIR} SINGLE_STEP=0 IS_SERVER=0 +DEBUG=0 # See if we need to continue from a previous install STATE_FILE=${CONFIG_DIR}/install-state @@ -211,6 +213,9 @@ while (( "$#" )) ; do rm ${CONFIG_DIR}/env fi ;; + debug) + DEBUG=1 + ;; restart) next-state "Pre-reqs" ;; diff --git a/deploy/scripts/kube_env.py b/deploy/scripts/kube_env.py index 0ca05e999c..d1a9480eb3 100755 --- a/deploy/scripts/kube_env.py +++ b/deploy/scripts/kube_env.py @@ -108,17 +108,18 @@ def add_helm_opts(parser: argparse.ArgumentParser) -> None: ) -def add_kube_opts(parser: argparse.ArgumentParser) -> None: +def add_kube_opts(parser: argparse.ArgumentParser, *, add_debug: bool = True) -> None: """Add commandline arguments for Kubernetes tools.""" parser.add_argument( "--context", help="Context in kubectl configuration file to be used.", ) - parser.add_argument( - "--debug", - action="store_true", - help="Enable debugging output for helm commands.", - ) + if add_debug: + parser.add_argument( + "--debug", + action="store_true", + help="Enable debugging output for helm commands.", + ) parser.add_argument( "--kubeconfig", help="Specify the kubectl configuration file to be used.", diff --git a/deploy/scripts/package_images.py b/deploy/scripts/package_images.py index 0fa690db54..2a0fa5eb50 100755 --- a/deploy/scripts/package_images.py +++ b/deploy/scripts/package_images.py @@ -8,6 +8,7 @@ image names are extracted from the templates and then pulled from the repo and stored in ../images as compressed tarballs; zstd compression is used. """ + import argparse import logging import os @@ -19,7 +20,7 @@ from utils import init_logging, run_cmd import yaml -# Define configuration and output directories' +# Define configuration and output directories scripts_dir = Path(__file__).resolve().parent ansible_dir = scripts_dir.parent / "ansible" helm_dir = scripts_dir.parent / "helm" @@ -58,46 +59,57 @@ def parse_args() -> argparse.Namespace: return parser.parse_args() -def package_k3s(dest_dir: Path) -> None: +def package_k3s(dest_dir: Path, *, debug: bool = False) -> None: logging.info("Packaging k3s images.") - run_cmd( - [ - "ansible-playbook", - "playbook_k3s_airgapped_files.yml", - "--extra-vars", - f"package_dir={dest_dir}", - ], - cwd=str(ansible_dir), - ) - - -def package_images(image_list: List[str], tar_file: Path) -> None: + ansible_cmd = [ + "ansible-playbook", + "playbook_k3s_airgapped_files.yml", + "--extra-vars", + f"package_dir={dest_dir}", + ] + if debug: + ansible_cmd.append("-vv") + run_cmd(ansible_cmd, cwd=str(ansible_dir), print_cmd=debug, print_output=debug) + + +def package_images(image_list: List[str], tar_file: Path, *, debug: bool = False) -> None: container_cli_cmd = [os.getenv("CONTAINER_CLI", "docker")] if container_cli_cmd[0] == "nerdctl": container_cli_cmd.extend(["--namespace", "k8s.io"]) + # Pull each image for image in image_list: pull_cmd = container_cli_cmd + ["pull", image] - logging.debug(f"Running {pull_cmd}") - run_cmd(pull_cmd) + run_cmd(pull_cmd, print_cmd=debug, print_output=debug) + # Save pulled images into a .tar archive - run_cmd(container_cli_cmd + ["save"] + image_list + ["-o", str(tar_file)]) + save_cmd = container_cli_cmd + ["save"] + image_list + ["-o", str(tar_file)] + run_cmd(save_cmd, print_cmd=debug, print_output=debug) + # Compress the tarball - run_cmd(["zstd", "--rm", "--force", "--quiet", str(tar_file)]) + tar_cmd = ["zstd", "--rm", "--force", str(tar_file)] + if not debug: + tar_cmd.append("--quiet") + run_cmd(tar_cmd, print_cmd=debug, print_output=debug) def package_middleware( - config_file: str, *, cluster_type: str, image_dir: Path, chart_dir: Path + config_file: str, *, cluster_type: str, image_dir: Path, chart_dir: Path, debug: bool = False ) -> None: logging.info("Packaging middleware images.") - # read in cluster configuration + + # Read in cluster configuration with open(config_file) as file: config: Dict[str, Any] = yaml.safe_load(file) - # get current repos + + # Get current repos curr_repo_list: List[str] = [] middleware_images: List[str] = [] + helm_list_cmd = ["helm", "repo", "list", "-o", "yaml"] + if debug: + helm_list_cmd.append("--debug") helm_cmd_results = run_cmd( - ["helm", "repo", "list", "-o", "yaml"], print_cmd=False, check_results=False + helm_list_cmd, check_results=False, print_cmd=debug, print_output=debug ) if helm_cmd_results.returncode == 0: curr_helm_repos = yaml.safe_load(helm_cmd_results.stdout) @@ -105,60 +117,76 @@ def package_middleware( curr_repo_list.append(repo["name"]) for chart_descr in config["clusters"][cluster_type]: - # add the chart's repo if we don't already have it + logging.debug(f"Chart: ${chart_descr}") + + # Add the chart's repo if we don't already have it repo = config[chart_descr]["repo"] if repo["name"] not in curr_helm_repos: - run_cmd(["helm", "repo", "add", repo["name"], repo["url"]]) + helm_add_cmd = ["helm", "repo", "add", repo["name"], repo["url"]] + if debug: + helm_add_cmd.append("--debug") + run_cmd(helm_add_cmd, print_cmd=debug, print_output=debug) curr_repo_list.append(repo["name"]) - # pull the middleware chart + # Pull the middleware chart chart = config[chart_descr]["chart"] dest_dir = chart_dir / chart["name"] dest_dir.mkdir(mode=0o755, parents=True, exist_ok=True) - helm_cmd = ["helm", "pull", chart["reference"], "--destination", str(dest_dir)] + helm_pull_cmd = ["helm", "pull", chart["reference"], "--destination", str(dest_dir)] + if debug: + helm_pull_cmd.append("--debug") if "version" in chart: - helm_cmd.extend(["--version", chart["version"]]) - run_cmd(helm_cmd) - # render chart templates and extract images + helm_pull_cmd.extend(["--version", chart["version"]]) + run_cmd(helm_pull_cmd, print_cmd=debug, print_output=debug) + + # Render chart templates and extract images for chart_file in dest_dir.glob("*.tgz"): - results = run_cmd(["helm", "template", chart_file]) + results = run_cmd(["helm", "template", chart_file], print_cmd=debug) for line in results.stdout.splitlines(): match = re.match(r'[-\s]+image:\s+"*([^"\n]*)"*', line) - if match: + if match and not match.group(1) in middleware_images: logging.debug(f" - Found image {match.group(1)}") middleware_images.append(match.group(1)) + logging.debug(f"Middleware images: {middleware_images}") - package_images(middleware_images, image_dir / "middleware-airgap-images-amd64.tar") + package_images( + middleware_images, image_dir / "middleware-airgap-images-amd64.tar", debug=debug + ) -def package_thecombine(tag: str, image_dir: Path) -> None: +def package_thecombine(tag: str, image_dir: Path, *, debug: bool = False) -> None: logging.info(f"Packaging The Combine version {tag}.") logging.debug("Create helm charts from templates") combine_charts.generate(tag) + logging.debug(" - Get template for The Combine.") - results = run_cmd( - [ - "helm", - "template", - "thecombine", - str(helm_dir / "thecombine"), - "--set", - "global.imageRegistry=public.ecr.aws/thecombine", - "--set", - f"global.imageTag={tag}", - ] - ) + helm_template_cmd = [ + "helm", + "template", + "thecombine", + str(helm_dir / "thecombine"), + "--dependency-update", + "--set", + "global.imageRegistry=public.ecr.aws/thecombine", + "--set", + f"global.imageTag={tag}", + ] + if debug: + helm_template_cmd.append("--debug") + results = run_cmd(helm_template_cmd, print_cmd=debug) + combine_images: List[str] = [] for line in results.stdout.splitlines(): match = re.match(r'^[-\s]+image:\s+"*([^"\n]*)"*', line) if match: image = match.group(1) - logging.debug(f" - Found image {image}") if image not in combine_images: + logging.debug(f" - Found image {image}") combine_images.append(image) logging.debug(f"Combine images: {combine_images}") + # Logout of AWS to allow pulling the images - package_images(combine_images, image_dir / "combine-airgap-images-amd64.tar") + package_images(combine_images, image_dir / "combine-airgap-images-amd64.tar", debug=debug) def main() -> None: @@ -179,11 +207,15 @@ def main() -> None: os.environ["AWS_DEFAULT_REGION"] = "" # Update helm repos - package_k3s(image_dir) + package_k3s(image_dir, debug=args.debug) package_middleware( - args.config, cluster_type="standard", image_dir=image_dir, chart_dir=chart_dir + args.config, + cluster_type="standard", + image_dir=image_dir, + chart_dir=chart_dir, + debug=args.debug, ) - package_thecombine(args.tag, image_dir) + package_thecombine(args.tag, image_dir, debug=args.debug) if __name__ == "__main__": diff --git a/deploy/scripts/setup_cluster.py b/deploy/scripts/setup_cluster.py index e588d011cc..0342a7f633 100755 --- a/deploy/scripts/setup_cluster.py +++ b/deploy/scripts/setup_cluster.py @@ -26,7 +26,7 @@ def parse_args() -> argparse.Namespace: description="Build containerd container images for project.", formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) - add_kube_opts(parser) + add_kube_opts(parser, add_debug=False) add_helm_opts(parser) parser.add_argument( "--chart-dir", help="Directory for the chart files when doing an airgap installation." @@ -37,12 +37,19 @@ def parse_args() -> argparse.Namespace: help="Configuration file for the cluster type(s).", default=str(scripts_dir / "setup_files" / "cluster_config.yaml"), ) - parser.add_argument( + logging_group = parser.add_mutually_exclusive_group() + logging_group.add_argument( "--quiet", "-q", action="store_true", help="Print less output information.", ) + logging_group.add_argument( + "--debug", + "-d", + action="store_true", + help="Print extra debugging information.", + ) parser.add_argument( "--type", "-t", diff --git a/deploy/scripts/setup_combine.py b/deploy/scripts/setup_combine.py index 052103d824..e871486d50 100755 --- a/deploy/scripts/setup_combine.py +++ b/deploy/scripts/setup_combine.py @@ -52,7 +52,7 @@ def parse_args() -> argparse.Namespace: formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) # Arguments used by the Kubernetes tools - add_kube_opts(parser) + add_kube_opts(parser, add_debug=False) # Arguments used by Helm add_helm_opts(parser) # Arguments specific to setting up The Combine @@ -187,8 +187,7 @@ def main() -> None: if chart in installed_charts: if args.clean: # Delete existing chart if --clean specified - delete_cmd = helm_cmd + ["--namespace", chart_namespace, "delete", chart] - logging.debug(delete_cmd) + delete_cmd = helm_cmd + [f"--namespace={chart_namespace}", "delete", chart] run_cmd(delete_cmd, print_cmd=not args.quiet, print_output=True) else: helm_action = HelmAction.UPGRADE @@ -204,8 +203,8 @@ def main() -> None: # Create the base helm install command chart_dir = helm_dir / chart helm_install_cmd = helm_cmd + [ - "--namespace", - chart_namespace, + "--dependency-update", + f"--namespace={chart_namespace}", helm_action.value, chart, str(chart_dir), @@ -251,15 +250,7 @@ def main() -> None: for variable in target_vars: helm_install_cmd.extend(["--set", variable]) - # Update chart dependencies - # Note that this operation is performed on the local helm charts - # so the kubeconfig and context arguments are not passed to the - # helm command. - helm_deps_cmd = ["helm", "dependency", "update", str(chart_dir)] - logging.debug(helm_deps_cmd) - run_cmd(helm_deps_cmd, print_cmd=not args.quiet, print_output=True) - - logging.debug(helm_install_cmd) + # Install the chart run_cmd(helm_install_cmd, print_cmd=not args.quiet, print_output=True) diff --git a/deploy/scripts/uninstall-combine b/deploy/scripts/uninstall-combine index 0f6c5ffebf..973ae69c58 100755 --- a/deploy/scripts/uninstall-combine +++ b/deploy/scripts/uninstall-combine @@ -2,6 +2,7 @@ set -euo pipefail delete-files () { + # Deletes the specified files for file in "$@" ; do if [[ -f "$file" ]] ; then echo "Removing $file" @@ -10,45 +11,44 @@ delete-files () { done } -kill-service () { - # Stops and disables the specified service - if systemctl is-active $1 ; then - echo "Stopping service $1" - sudo systemctl stop $1 2>&1 >/dev/null - fi - if systemctl is-enabled $1 ; then - echo "Disabline service $1" - sudo systemctl disable $1 - fi +kill-services () { + # Stops and disables the specified services + for service in "$@" ; do + if systemctl is-active $service ; then + echo "Stopping service $service" + sudo systemctl stop $service 2>&1 >/dev/null + fi + if systemctl is-enabled $service ; then + echo "Disabling service $service" + sudo systemctl disable $service + fi + done } -# Stop & disable combine services -echo "Stopping combine services" -kill-service k3s -kill-service create_ap - -# Delete $HOME/thecombine; $HOME/.config/combine -delete-files ${HOME}/thecombine ${HOME}/.config/combine +# Stop and remove The Combine +echo "Stopping The Combine services" +kill-services k3s create_ap +echo "Deleting The Combine files" +delete-files ${HOME}/thecombine ${HOME}/.config/combine /usr/local/bin/combinectl -# Remove support tool - -kill-service display-eth.service -kill-service display-eth.timer +# Stop and remove support tools +echo "Stopping display-eth services" +kill-services display-eth.service display-eth.timer +echo "Deleting display-eth files" delete-files /lib/systemd/system/display-eth.service /lib/systemd/system/display-eth.timer -# Remove combine management tool -delete-files /usr/local/bin/combinectl - - # Uninstall k3s if [[ -x /usr/local/bin/k3s-uninstall.sh ]] ; then + echo "Uninstalling k3s" /usr/local/bin/k3s-uninstall.sh fi # Remove network configurations if nmcli c show dummy-vip >/dev/null 2>&1 ; then + echo "Removing dummy-vip" sudo nmcli c delete dummy-vip fi -# delete create_ap files +# Delete create_ap files +echo "Deleting create_ap files" delete-files /etc/create_ap /usr/lib/systemd/system/create_ap.service diff --git a/deploy/scripts/utils.py b/deploy/scripts/utils.py index 0af9cff521..d451b3aa26 100644 --- a/deploy/scripts/utils.py +++ b/deploy/scripts/utils.py @@ -22,7 +22,7 @@ def run_cmd( ) -> subprocess.CompletedProcess[str]: """Run a command with subprocess and catch any CalledProcessErrors.""" if print_cmd: - print(f"Running: {' '.join(cmd)}") + print(f"Running: {' '.join([str(arg) for arg in cmd])}") try: process_results = subprocess.run( cmd, diff --git a/installer/README.md b/installer/README.md index d88dc5e07b..6817b8efcd 100644 --- a/installer/README.md +++ b/installer/README.md @@ -4,10 +4,10 @@ This README describes how to install _The Combine_ Rapid Word Collection tool on ## Contents -1. [System Requirements](#system-requirements) -2. [Install _The Combine_](#install-the-combine) -3. [Running _The Combine_](#running-the-combine) -4. [Advanced Installation Options](#advanced-installation-options) + - [System Requirements](#system-requirements) + - [Install _The Combine_](#install-the-combine) + - [Running _The Combine_](#running-the-combine) + - [Advanced Installation Options](#advanced-installation-options) ## System Requirements @@ -35,29 +35,15 @@ The installation script has been tested on _Ubuntu 22.04_ and _Wasta Linux 22.04 _Note for Wasta Linux users_ - _Wasta Linux_ includes Skype in its list of available software. Skype no longer supports installing it on Linux from - an `apt` software repository. As a result, when the installation script, or a user, updates the list of available - software, the process fails. To address this issue, you can either: - - 1. Remove the file directly: + _Wasta Linux_ includes Skype in its list of available software. Skype no longer supports installation + via `apt`. (It's available as a Snap package.) As a result, when the installation script, or a user, updates the list of available + software, the process fails. To address this issue, run: ```console sudo rm /etc/apt/sources.list.d/skype-stable.list - sudo apt update + sudo apt update && sudo apt upgrade -y ``` - or - - 2. Deselect _Skype_ in the Software Updater settings - - 1. Open the _Software Settings_ application - 2. Click the _Other Software_ tab - 3. Uncheck the entry for Skype (`https://repo.skype.com/deb stable`) - 4. Click the "Close" button - 5. Click the "Reload" button in the dialog window that is displayed - - Skype is available on _Wasta Linux_ or _Ubuntu_ as a Snap package. - 4. Download the installation script from [https://s3.amazonaws.com/software.thecombine.app/combine-installer.run](https://s3.amazonaws.com/software.thecombine.app/combine-installer.run) 5. Open a terminal window (Ctrl-Alt-T) and make the script executable: @@ -90,6 +76,13 @@ The installation script has been tested on _Ubuntu 22.04_ and _Wasta Linux 22.04 [The Combine](https://software.sil.org/thecombine/#contact) - When run with no options, ./combine-installer.run will install the current version of _The Combine_. - If the previous installation did not run to completion, it will resume where the previous installation left off. + - If you get the error `Job for k3s.service failed because the control process exited with error code.`, + make sure no other instance of k3s is running. For example, if Docker Desktop is active on the current user, run: + + ```console + systemctl --user stop docker-desktop + systemctl --user disable docker-desktop + ``` _The Combine_ will not be running when installation is complete. @@ -118,10 +111,7 @@ If you would like to change the WiFi passphrase, see the options described in [c #### Connecting to the App -Open a web browser and navigate to [local.thecombine.app](https://local.thecombine.app). - -If your browser tries to do a web search, add the `https://` to the beginning, that is, -[https://local.thecombine.app](https://local.thecombine.app) +Open a web browser and navigate to [https://local.thecombine.app](https://local.thecombine.app). ### Shutting Down _The Combine_ @@ -134,17 +124,17 @@ combinectl stop ### combinectl Tool Once installation is complete, you can use the `combinectl` command to manage the installation. The `combinectl` command -is entered in a terminal window as `combinectl COMMAND [parameters]` The possible commands are: - -| Command | Parameters | Description | -| ------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| help | N/A | Print a usage message. | -| start | N/A | Start the combine services. | -| stop | N/A | Stop the combine services. | -| status | N/A | List the status for the combine services. | -| cert | N/A | Print the expiration date for the web certificate. | -| update | release-number | Update the version of The Combine to the "release-number" specified. You can see the number of the latest release at [The Combine on GitHub](https://github.com/sillsdev/TheCombine/releases). Note that not all releases can be updated this way. If The Combine does not run properly, download and run the updated install package. | -| wifi | [wifi-passphrase] | If no wifi-passphrase is provieded, the current wifi passphrase is printed. If a new passphase is provided, the wifi passphrase is updated to the new phrase. If your passphrase has spaces or special characters, it is best to enclose your pass phrase in quotation marks (""). | +is entered in a terminal window as `combinectl COMMAND [parameters]`, where the possible commands are: + +| Command | Parameters | Description | +| ------- | -------------- | ------------------------------------------------------------------- | +| help | N/A | Print a usage message. | +| start | N/A | Start the combine services. | +| stop | N/A | Stop the combine services. | +| status | N/A | List the status for the combine services. | +| cert | N/A | Print the expiration date for the web certificate. | +| update | release-number | Update the version of The Combine to the `release-number` specified. You can see the latest release number at [The Combine on GitHub](https://github.com/sillsdev/TheCombine/releases). (This only works if the release begins with a "v".) | +| wifi | [passphrase] | If no passphrase is provided, print the current passphrase. If a passphrase is provided, update the wifi passphrase. A passphrase with spaces or special characters should be enclosed in quotation marks (""). | If the command is omitted or unrecognized, the help message is printed. @@ -159,30 +149,28 @@ certificate will be valid for a time between 60 and 90 days. You can use the com current certificate will expire, for example: ```console -$combinectl cert +$ combinectl cert Web certificate expires at Jul 8 08:54:11 2024 GMT ``` ## Advanced Installation Options -To run `combine-installer.run` with options, the option list must be started with `--`. - -`combine-installer.run` supports the following options: +To run `combine-installer.run` with options, the option list must be started with `--` . The following options are supported: -| option | description | -| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| clean | Remove the previously saved environment (AWS Access Key, admin user info) before performing the installation. | -| restart | Run the installation from the beginning; do not resume a previous installation. | -| server | Install _The Combine_ in a server environment so that _The Combine_ is always running by default. | -| timeout TIMEOUT | Use a different timeout when installing. The default timeout is 5 minutes. With slow internet connections, it is helpful to extend the timeout. See for timeout formats. | -| uninstall | Remove software installed by this script. | -| update | Update _The Combine_ to the version number provided. This skips installing the support software that was installed previously. | -| version-number | Specify a version to install instead of the current version. A version number will have the form `vn.n.n` where `n` represents an integer value, for example, `v1.20.0`. | +| option | description | +| --------------- | ---------------------------------------------------------------------------- | +| clean | Remove the previously saved environment (AWS Access Key, admin user info) before performing the installation. | +| restart | Run the installation from the beginning; do not resume a previous installation. | +| server | Install _The Combine_ in a server environment so that _The Combine_ is always running by default. | +| timeout TIMEOUT | Use a different timeout when installing. (Default: 5 minutes.) With slow internet, it is helpful to extend the timeout. See for timeout formats. | +| uninstall | Remove software installed by this script. | +| update | Update _The Combine_ to the version number provided. This skips installing support software that was installed previously. | +| version-number | Specify a version to install instead of the current version. A version number will have the form `vn.n.n` where `n` represents an integer value, for example, `v1.20.0`. | ### Examples -| Command | Effect | -| ------------------------------------------ | ------------------------------------------------------------ | -| `./combine-installer.run -- v2.0.1` | Install version `v2.0.1` of _The Combine_. | -| `./combine-installer.run -- update v2.2.0` | Update an existing Combine installation to version `v2.2.0` | -| `./combine-installer.run -- restart` | Restart the current installation process from the beginning. | +| Command | Effect | +| ------------------------------------------------------------------------------------ | -------------------------------------------| +| `./combine-installer.run -- v2.0.1` | Install version `v2.0.1` of _The Combine_. | +| `./combine-installer.run -- update v2.2.0` | Update installation to version `v2.2.0` | +| `./combine-installer.run -- restart` | Restart process from the beginning. | diff --git a/installer/make-combine-installer.sh b/installer/make-combine-installer.sh index 908f4ecd4d..71eaa578ce 100755 --- a/installer/make-combine-installer.sh +++ b/installer/make-combine-installer.sh @@ -13,11 +13,15 @@ error () { # cd to the directory where the script is installed SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +DEBUG=0 NET_INSTALL=0 # Parse arguments to customize installation while (( "$#" )) ; do OPT=$1 case $OPT in + --debug) + DEBUG=1 + ;; --net-install) NET_INSTALL=1 ;; @@ -28,7 +32,7 @@ while (( "$#" )) ; do error "Invalid version number, $OPT" fi ;; - *) + *) warning "Unrecognized option: $OPT" ;; esac @@ -48,23 +52,30 @@ if [[ $NET_INSTALL == 0 ]] ; then fi source venv/bin/activate # Update the environment if necessary - python -m pip install --upgrade pip pip-tools + python -m pip $((( DEBUG == 0)) && echo "-q") install --upgrade pip pip-tools python -m piptools sync requirements.txt # Package The Combine for "offline" installation TEMP_DIR=/tmp/images-$$ pushd scripts - ./package_images.py ${COMBINE_VERSION} ${TEMP_DIR} + ./package_images.py ${COMBINE_VERSION} ${TEMP_DIR} $((( DEBUG == 1 )) && echo "--debug") INSTALLER_NAME="combine-installer.run" popd - rm -rf venv else # Package The Combine for network installation INSTALLER_NAME="combine-net-installer.run" fi +# Remove unwanted folders +for DIR in venv scripts/__pycache__ ; do + if [ -d $DIR ] ; then + (( DEBUG == 1 )) && echo "Removing ../deploy/$DIR/" + rm -rf $DIR + fi +done + cd ${SCRIPT_DIR} -makeself --tar-quietly ../deploy ${INSTALLER_NAME} "Combine Installer" scripts/install-combine.sh ${COMBINE_VERSION} +makeself $((( DEBUG == 0)) && echo "--tar-quietly" ) ../deploy ${INSTALLER_NAME} "Combine Installer" scripts/install-combine.sh ${COMBINE_VERSION} if [[ $NET_INSTALL == 0 ]] ; then makeself --append ${TEMP_DIR} ${INSTALLER_NAME} rm -rf ${TEMP_DIR}