Compare commits

..

No commits in common. "710f2611282c06b80f1263dfa3d7c53dbfebb164" and "d2d303d06bc226c6877fdb315bdb175b782ff8b5" have entirely different histories.

2 changed files with 4 additions and 72 deletions

View file

@ -3,5 +3,5 @@
Install a frontend for a Watt42 system, experimental:
```sh
wget -q -O - https://source.c3.uber5.com/watt42-public/install/raw/branch/main/install.sh | TARGET=view bash
wget -q -O - https://source.c3.uber5.com/watt42-public/install/raw/branch/main/install.sh | bash
```

View file

@ -1,72 +1,4 @@
#!/usr/local/env bash
echo "installing Watt42 components for development..."
# Define a function to read from the terminal
read_from_terminal() {
# Check if a tty is available
if [[ -t 0 ]]; then
# Use 'read -p' if standard input is an interactive terminal
read -p "$1" user_input
else
printf "\n" > /dev/tty
# If not interactive (e.g. piped), read from /dev/tty
# The '< /dev/tty' redirects input for 'read' to the terminal device
read -p "$1" user_input < /dev/tty
fi
echo "$user_input"
}
required_commands=( git poetry )
# ensure we have required commands available
for cmd in "${required_commands[@]}"; do
if ! command -v "$cmd" &> /dev/null; then
echo "Error: $cmd is not installed." >&2
exit 1
fi
done
# ensure TARGET is either 'view' or 'client'
if [ -z "$TARGET" ] || { [ "$TARGET" != "view" ] && [ "$TARGET" != "client" ]; }; then
echo "Error: TARGET environment variable must be set to either 'view' or 'client'." >&2
exit 1
fi
# determine exec directory
SCRIPT_DIR="$( pwd )"
# create temp dir and cleanup on exit (TODO: we don't need a temp dir at the moment)
TEMP_DIR="$( mktemp -d )"
trap 'rm -rf "$TEMP_DIR"' EXIT
cd ${TEMP_DIR} || exit 1
# prompt for directory name to clone template into
DIR_NAME=$(read_from_terminal "Enter your project name: ")
read_from_terminal "Cloning template into ${SCRIPT_DIR}/${DIR_NAME}, press Enter to continue..."
git clone https://source.c3.uber5.com/watt42-public/watt42-panelview-template.git "${SCRIPT_DIR}/${DIR_NAME}"
# remove the origin from git
(cd "${SCRIPT_DIR}/${DIR_NAME}" || exit 1; git remote remove origin)
echo "Your ${TARGET} project has been created in ${SCRIPT_DIR}/${DIR_NAME}"
read_from_terminal "Installing dependencies with poetry, press Enter to continue..."
(cd "${SCRIPT_DIR}/${DIR_NAME}" || exit 1; poetry install)
TOKEN=$(read_from_terminal "What is your API TOKEN? (request one at https://www.watt42.com/contact?request-token=1): ")
# write token to .env file
echo "WATT42_API_TOKEN=${TOKEN}" > "${SCRIPT_DIR}/${DIR_NAME}/.env"
SYSTEM_ID=$(read_from_terminal "What is your SYSTEM ID? (you can find it in your watt42.com dashboard): ")
# append system id to .env file
echo "WATT42_SYSTEM_ID=${SYSTEM_ID}" >> "${SCRIPT_DIR}/${DIR_NAME}/.env"
echo "Setup complete! We will now start the ${TARGET} application. To run it later, navigate to ${SCRIPT_DIR}/${DIR_NAME} and run './run.sh'"
# start the application
(cd "${SCRIPT_DIR}/${DIR_NAME}" || exit 1; ./run.sh)
#!/bin/sh
echo "should install stuff..."
exit 0