From 11fe6bb9f4b8cc9f6b593ff0b1bfcfeb95b53942 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 4 Mar 2025 17:11:14 +0100 Subject: [PATCH] Add the bare metal simple install script as example --- .../examples/bare-metal-simple/README.md | 44 +++++++ .../examples/bare-metal-simple/install.sh | 109 ++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 deployments/examples/bare-metal-simple/README.md create mode 100755 deployments/examples/bare-metal-simple/install.sh diff --git a/deployments/examples/bare-metal-simple/README.md b/deployments/examples/bare-metal-simple/README.md new file mode 100644 index 0000000000..8e58744bc3 --- /dev/null +++ b/deployments/examples/bare-metal-simple/README.md @@ -0,0 +1,44 @@ +# Simple Bare Metal Install + +This install script downloads and installs the OpenCloud binary and +configures it in a sandbox directory in the folder where you called +the install script. It also adds a start script called `runopencloud.sh` +to start OpenCloud later. + +The installation only consists of the bare minimum functionality +without web office and other optional components. Also, it is bound +to localhost and has no valid certificates. ** It is only +useful for simple test- and demo cases and not for production.** + +To use OpenCloud, start it with the start script and head your +browser to https://localhost:9200. The invalid certificate must +be acknowledged in the browser. + +The demo users (eg. alan / demo) are enabled, the admin password +is surprisingly `admin`. + +This script should **NOT** be run as user root. + +# Options + +## Version + +Set the environment variable `OC_VERSION` to the version you want +to download. If not set, there is a reasonable default. + +# Example + +Call + +``` +OC_VERSION="1.0.0" ./install.sh +``` +to install the OpenCloud version 1.0.0 + +There is also a hosted version of this script that makes it even +easier: + +``` +curl -L https://opencloud.eu/oc-install.sh | bash -x +``` + diff --git a/deployments/examples/bare-metal-simple/install.sh b/deployments/examples/bare-metal-simple/install.sh new file mode 100755 index 0000000000..90fe293e2c --- /dev/null +++ b/deployments/examples/bare-metal-simple/install.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +set -euo pipefail + +# +# Quick and dirty quickstart script to fire up a local OpenCloud instance. +# Klaas Freitag +# + +# This script supports the following environment variables: +# OC_VERSION: Version to download, e.g. OC_VERSION="1.2.0" + +# Call this script directly from opencloud: +# curl -L https://opencloud.eu/quickinstall.sh | /bin/bash + +# This function is borrowed from openSUSEs /usr/bin/old, thanks. +function backup_file () { + local DATESTRING=`date +"%Y%m%d"` + + i=${1%%/} + if [ -e "$i" ] ; then + local NEWNAME=$i-$DATESTRING + local NUMBER=0 + while [ -e "$NEWNAME" ] ; do + NEWNAME=$i-$DATESTRING-$NUMBER + let NUMBER=$NUMBER+1 + done + echo moving "$i" to "$NEWNAME" + if [ "${i:0:1}" = "-" ] ; then + i="./$i" + NEWNAME="./$NEWNAME" + fi + mv "$i" "$NEWNAME" + fi +} + +# URL pattern of the download file +# https://github.com/opencloud-eu/opencloud/releases/download/v1.0.0/opencloud-1.0.0-linux-amd64 + +dlversion="${OC_VERSION:-1.0.0}" +dlurl="https://github.com/opencloud-eu/opencloud/releases/download/v${dlversion}/" + +sandbox="opencloud-sandbox-${dlversion}" + +# Create a sandbox +[ -d "./${sandbox}" ] && backup_file ${sandbox} +mkdir ${sandbox} && cd ${sandbox} + +# The operating system +os="linux" + +if [[ $OSTYPE == 'darwin'* ]]; then + os="darwin" +fi + +# The platform +dlarch="amd64" + +if [[ $(uname -s) == "Darwin" && $(uname -m) == "arm64" ]]; then + dlarch="arm64" +fi + +# ...results in the download file +dlfile="opencloud-${dlversion}-${os}-${dlarch}" + +# download +echo "Downloading ${dlurl}/${dlfile}" + +curl -L -o "${dlfile}" --progress-bar "${dlurl}/${dlfile}" +chmod 755 ${dlfile} + +mkdir data config + +export OC_CONFIG_DIR="$(pwd)/config" +export OC_BASE_DATA_PATH="$(pwd)/data" + +# It is bound to localhost for now to deal with non existing routes +# to certain host names for example in WSL +host="localhost" + +./${dlfile} init --insecure yes --ap admin + +echo '#!/bin/bash +SCRIPT_DIR="$(dirname "$(readlink -f "${0}")")" +cd "${SCRIPT_DIR}"' > runopencloud.sh + +echo "export OC_CONFIG_DIR=${OC_CONFIG_DIR} +export OC_BASE_DATA_PATH=${OC_BASE_DATA_PATH} + +export OC_INSECURE=true +export OC_URL=https://${host}:9200 +export IDM_CREATE_DEMO_USERS=true +export PROXY_ENABLE_BASIC_AUTH=true +export OC_LOG_LEVEL=warning + +./"${dlfile}" server +" >> runopencloud.sh + +chmod 755 runopencloud.sh + +echo "Connect to OpenCloud via https://${host}:9200" +echo "" +echo "*** This is a fragile test setup, not suitable for production! ***" +echo " If you stop this script now, you can run your test OpenCloud again" +echo " using the script ${sandbox}/runopencloud.sh" +echo "" + +./runopencloud.sh +