#!/usr/bin/env bash set -o errexit set -o nounset set -o pipefail if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace fi source "${BASH_SOURCE%/*}/common.sh" ROOT_FOLDER="${PWD}" # Cleanup and ensure environment ensure_linux ensure_pwd ensure_root clean_logs ### -------------------------------- ### Pre-configuration ### -------------------------------- "${ROOT_FOLDER}/scripts/configure.sh" STATE_FOLDER="${ROOT_FOLDER}/state" if [[ ! -f "${STATE_FOLDER}/seed" ]]; then echo "Generating seed..." if ! tr "${STATE_FOLDER}/seed"; then echo "Created seed file..." fi fi ### -------------------------------- ### General variables ### -------------------------------- apps_repository="https://github.com/meienberger/runtipi-appstore" INTERNAL_IP= if [[ -f "${STATE_FOLDER}/settings.json" ]]; then # If listenIp is set in settings.json, use it if [[ "$(get_json_field "${STATE_FOLDER}/settings.json" listenIp)" != "null" ]]; then INTERNAL_IP=$(get_json_field "${STATE_FOLDER}/settings.json" listenIp) fi fi if [[ -z "${INTERNAL_IP:-}" ]]; then network_interface="$(ip route | grep default | awk '{print $5}' | uniq)" network_interface_count=$(echo "$network_interface" | wc -l) if [[ "$network_interface_count" -eq 0 ]]; then echo "No network interface found!" exit 1 elif [[ "$network_interface_count" -gt 1 ]]; then echo "Found multiple network interfaces. Please select one of the following interfaces:" echo "$network_interface" while true; do read -rp "> " USER_NETWORK_INTERFACE if echo "$network_interface" | grep -x "$USER_NETWORK_INTERFACE"; then network_interface="$USER_NETWORK_INTERFACE" break else echo "Please select one of the interfaces above. (CTRL+C to abort)" fi done fi INTERNAL_IP="$(ip addr show "${network_interface}" | grep "inet " | awk '{print $2}' | cut -d/ -f1)" internal_ip_count=$(echo "$INTERNAL_IP" | wc -l) if [[ "$internal_ip_count" -eq 0 ]]; then echo "No IP address found for network interface ${network_interface}! Set the IP address manually with --listen-ip or with the listenIp field in settings.json." exit 1 elif [[ "$internal_ip_count" -gt 1 ]]; then echo "Found multiple IP addresses for network interface ${network_interface}. Please select one of the following IP addresses:" echo "$INTERNAL_IP" while true; do read -rp "> " USER_INTERNAL_IP if echo "$INTERNAL_IP" | grep -x "$USER_INTERNAL_IP"; then INTERNAL_IP="$USER_INTERNAL_IP" break else echo "Please select one of the IP addresses above. (CTRL+C to abort)" fi done fi fi env_variables_json=$(cat <._ \X-=/^ ( / `-._//^` `Y-.____(__} | {__) ()` EOF echo "" echo "Visit http://${INTERNAL_IP}/ to view the dashboard" echo ""