From 3bfdd9bbb3f762eb8a8b8651fa8365a0d9740f4d Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger <47644445+meienberger@users.noreply.github.com> Date: Tue, 17 May 2022 22:57:43 +0000 Subject: [PATCH 1/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7b2e3ff4..988350d8 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,4 @@ Tipi is licensed under the GNU General Public License v3.0. TL;DR — You may co ## 🗣 Community - [Matrix](https://matrix.to/#/#runtipi:matrix.org)
- [Twitter](https://twitter.com/runtipi) +- [Telegram](https://t.me/+72-y10MnLBw2ZGI0) From 2969817269df6ebeaf85985b12ab0034a3e3c971 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger <47644445+meienberger@users.noreply.github.com> Date: Wed, 18 May 2022 12:34:44 +0000 Subject: [PATCH 2/5] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 988350d8..2bcf522f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![License](https://img.shields.io/github/license/meienberger/runtipi)](https://github.com/meienberger/runtipi/blob/master/LICENSE) [![Version](https://img.shields.io/github/v/release/meienberger/runtipi?color=%235351FB&label=version)](https://github.com/meienberger/runtipi/releases) ![Issues](https://img.shields.io/github/issues/meienberger/runtipi) +[![Docker Pulls](https://badgen.net/docker/pulls/meienberger/tipi-dashboard?icon=docker&label=pulls)](https://hub.docker.com/r/meienberger/tipi-dashboard/) +[![Docker Image Size](https://badgen.net/docker/size/meienberger/tipi-dashboard?icon=docker&label=image%20size)](https://hub.docker.com/r/meienberger/tipi-dashboard/) ![RunsOn](https://img.shields.io/badge/Debian-Supported-green?logo=debian) ![RunsOn](https://img.shields.io/badge/Ubuntu-Supported-green?logo=ubuntu) ![Build](https://github.com/meienberger/runtipi/workflows/Tipi%20CI/badge.svg) @@ -11,7 +13,6 @@ Tipi is a personal homeserver orchestrator. It is running docker containers under the hood and provides a simple web interface to manage them. Every service comes with an opinionated configuration in order to remove the need for manual configuration and network setup. ## Apps available -- [Anonaddy](https://github.com/anonaddy/anonaddy) - Anonymous email forwarding - [Filebrowser](https://github.com/filebrowser/filebrowser) - Web File Browser - [Freshrss](https://github.com/FreshRSS/FreshRSS) - A free, self-hostable RSS aggregator - [Invidious](https://github.com/iv-org/invidious) - An alternative front-end to YouTube From 287999cacaffc8088b75cee68035a73224e0693d Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Wed, 18 May 2022 20:13:58 +0200 Subject: [PATCH 3/5] Allow custom port --- docker-compose.rc.yml | 4 +-- docker-compose.yml | 5 ++- scripts/app.sh | 12 +++---- scripts/configure.sh | 12 +++---- scripts/start.sh | 75 +++++++++++++++++++++++++++--------------- scripts/stop.sh | 23 +++++++------ scripts/system-info.sh | 6 ++-- templates/env-sample | 2 ++ 8 files changed, 81 insertions(+), 58 deletions(-) diff --git a/docker-compose.rc.yml b/docker-compose.rc.yml index 7cfb3a52..ed93e464 100644 --- a/docker-compose.rc.yml +++ b/docker-compose.rc.yml @@ -6,8 +6,8 @@ services: image: traefik:v2.6 restart: always ports: - - 80:80 - - 8080:8080 + - ${NGINX_PORT}:80 + - ${PROXY_PORT}:8080 command: --api.insecure=true --providers.docker volumes: - /var/run/docker.sock:/var/run/docker.sock:ro diff --git a/docker-compose.yml b/docker-compose.yml index 99622c80..42e98e43 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,8 @@ services: image: traefik:v2.6 restart: always ports: - - 80:80 - - 8080:8080 + - ${NGINX_PORT}:80 + - ${PROXY_PORT}:8080 command: --api.insecure=true --providers.docker volumes: - /var/run/docker.sock:/var/run/docker.sock:ro @@ -15,7 +15,6 @@ services: networks: - tipi_main_network - api: image: meienberger/tipi-api:${TIPI_VERSION} container_name: api diff --git a/scripts/app.sh b/scripts/app.sh index 055d70e9..dbb01911 100755 --- a/scripts/app.sh +++ b/scripts/app.sh @@ -12,7 +12,7 @@ ROOT_FOLDER="$($rdlk -f $(dirname "${BASH_SOURCE[0]}")/..)" STATE_FOLDER="${ROOT_FOLDER}/state" show_help() { - cat << EOF + cat < /dev/null + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null fi # Add deb repo for docker (Ubuntu) if [[ "${LSB}" == "Ubuntu" ]]; then - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null fi sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io # Install docker compose if not here -if ! command -v docker-compose > /dev/null; then +if ! command -v docker-compose >/dev/null; then sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose fi # create docker group -if ! getent group docker > /dev/null; then +if ! getent group docker >/dev/null; then sudo groupadd docker fi sudo usermod -aG docker "${USERNAME}" @@ -65,4 +65,4 @@ sudo usermod -aG docker "${USERNAME}" # find "$ROOT_FOLDER" -path "$ROOT_FOLDER/app-data" -prune -o -exec chown 1000:1000 {} + || true # Create configured status -touch "${ROOT_FOLDER}/state/configured" \ No newline at end of file +touch "${ROOT_FOLDER}/state/configured" diff --git a/scripts/start.sh b/scripts/start.sh index fb04a602..7bd88bb7 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e # Exit immediately if a command exits with a non-zero status. +set -e # Exit immediately if a command exits with a non-zero status. # use greadlink instead of readlink on osx if [[ "$(uname)" == "Darwin" ]]; then @@ -8,18 +8,42 @@ else readlink=readlink fi -while [ -n "$1" ]; do # while loop starts +NGINX_PORT=80 +PROXY_PORT=8080 - case "$1" in - --rc) rc="true" ;; - --ci) ci="true" ;; - --) - shift # The double dash makes them parameters - break - ;; - *) echo "Option $1 not recognized" && exit 1 ;; - esac - shift +while [ -n "$1" ]; do # while loop starts + case "$1" in + --rc) rc="true" ;; + --ci) ci="true" ;; + --port) + port="$2" + + if [[ "${port}" =~ ^[0-9]+$ ]]; then + NGINX_PORT="${port}" + else + echo "--port must be a number" + exit 1 + fi + shift + ;; + --proxy-port) + proxy_port="$2" + + if [[ "${proxy_port}" =~ ^[0-9]+$ ]]; then + PROXY_PORT="${proxy_port}" + else + echo "--proxy-port must be a number" + exit 1 + fi + shift + ;; + --) + shift # The double dash makes them parameters + break + ;; + *) echo "Option $1 not recognized" && exit 1 ;; + esac + shift done # Check we are on linux @@ -40,10 +64,10 @@ if [[ "$ARCHITECTURE" == "aarch64" ]]; then fi if [[ $UID != 0 ]]; then - echo "Tipi must be started as root" - echo "Please re-run this script as" - echo " sudo ./scripts/start" - exit 1 + echo "Tipi must be started as root" + echo "Please re-run this script as" + echo " sudo ./scripts/start" + exit 1 fi # Configure Tipi if it isn't already configured @@ -53,20 +77,20 @@ fi # Get field from json file function get_json_field() { - local json_file="$1" - local field="$2" + local json_file="$1" + local field="$2" - echo $(jq -r ".${field}" "${json_file}") + echo $(jq -r ".${field}" "${json_file}") } # Deterministically derives 128 bits of cryptographically secure entropy function derive_entropy() { SEED_FILE="${STATE_FOLDER}/seed" identifier="${1}" - tipi_seed=$(cat "${SEED_FILE}") || true + tipi_seed=$(cat "${SEED_FILE}") || true if [[ -z "$tipi_seed" ]] || [[ -z "$identifier" ]]; then - >&2 echo "Missing derivation parameter, this is unsafe, exiting." + echo >&2 "Missing derivation parameter, this is unsafe, exiting." exit 1 fi @@ -107,7 +131,7 @@ fi # Create seed file with cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 if [[ ! -f "${STATE_FOLDER}/seed" ]]; then echo "Generating seed..." - cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 > "${STATE_FOLDER}/seed" + cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 >"${STATE_FOLDER}/seed" fi export DOCKER_CLIENT_TIMEOUT=240 @@ -136,7 +160,8 @@ for template in "${ENV_FILE}"; do sed -i "s//${SED_ROOT_FOLDER}/g" "${template}" sed -i "s//$(cat "${ROOT_FOLDER}/VERSION")/g" "${template}" sed -i "s//${ARCHITECTURE}/g" "${template}" - + sed -i "//${NGINX_PORT}" "${template}" + sed -i "//${PROXY_PORT}" "${template}" done mv -f "$ENV_FILE" "$ROOT_FOLDER/.env" @@ -170,7 +195,7 @@ fi echo "Tipi is now running" echo "" -cat << "EOF" +cat <<"EOF" _,. ,` -.) '( _/'-\\-. @@ -195,5 +220,3 @@ EOF echo "" echo "Visit http://${INTERNAL_IP}/ to view the dashboard" echo "" - - diff --git a/scripts/stop.sh b/scripts/stop.sh index e76c285b..f43a6fcb 100755 --- a/scripts/stop.sh +++ b/scripts/stop.sh @@ -8,12 +8,11 @@ else readlink=readlink fi - if [[ $UID != 0 ]]; then - echo "Tipi must be stopped as root" - echo "Please re-run this script as" - echo " sudo ./scripts/stop" - exit 1 + echo "Tipi must be stopped as root" + echo "Please re-run this script as" + echo " sudo ./scripts/stop" + exit 1 fi ROOT_FOLDER="$($readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" @@ -27,10 +26,10 @@ export DOCKER_CLIENT_TIMEOUT=240 export COMPOSE_HTTP_TIMEOUT=240 function get_json_field() { - local json_file="$1" - local field="$2" + local json_file="$1" + local field="$2" - echo $(jq -r ".${field}" "${json_file}") + echo $(jq -r ".${field}" "${json_file}") } str=$(get_json_field ${STATE_FOLDER}/apps.json installed) @@ -38,11 +37,11 @@ apps_to_start=($str) # If apps_to_start is not empty, then we're stopping all apps if [[ ${#apps_to_start[@]} -gt 0 ]]; then - for app in "${apps_to_start[@]}"; do - "${ROOT_FOLDER}/scripts/app.sh" stop $app - done + for app in "${apps_to_start[@]}"; do + "${ROOT_FOLDER}/scripts/app.sh" stop $app + done fi echo "Stopping Docker services..." echo -docker-compose down --remove-orphans --rmi local \ No newline at end of file +docker-compose down --remove-orphans --rmi local diff --git a/scripts/system-info.sh b/scripts/system-info.sh index 5d8737d4..28ee1158 100755 --- a/scripts/system-info.sh +++ b/scripts/system-info.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -e # Exit immediately if a command exits with a non-zero status. +set -e # Exit immediately if a command exits with a non-zero status. ROOT_FOLDER="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)" STATE_FOLDER="${ROOT_FOLDER}/state" @@ -19,7 +19,7 @@ MEM_USED_BYTES=$(($MEM_TOTAL_BYTES - $MEM_AVAILABLE_BYTES)) # Create temporary json file TEMP_JSON_FILE=$(mktemp) -echo '{ "cpu": { "load": '"${CPU_LOAD_PERCENTAGE}"' }, "memory": { "total": '"${MEM_TOTAL_BYTES}"' , "used": '"${MEM_USED_BYTES}"', "available": '"${MEM_AVAILABLE_BYTES}"' }, "disk": { "total": '"${TOTAL_DISK_SPACE_BYTES}"' , "used": '"${USED_DISK_SPACE_BYTES}"', "available": '"${AVAILABLE_DISK_SPACE_BYTES}"' } }' > "${TEMP_JSON_FILE}" +echo '{ "cpu": { "load": '"${CPU_LOAD_PERCENTAGE}"' }, "memory": { "total": '"${MEM_TOTAL_BYTES}"' , "used": '"${MEM_USED_BYTES}"', "available": '"${MEM_AVAILABLE_BYTES}"' }, "disk": { "total": '"${TOTAL_DISK_SPACE_BYTES}"' , "used": '"${USED_DISK_SPACE_BYTES}"', "available": '"${AVAILABLE_DISK_SPACE_BYTES}"' } }' >"${TEMP_JSON_FILE}" # Write to state file -echo "$(cat "${TEMP_JSON_FILE}")" > "${STATE_FOLDER}/system-info.json" +echo "$(cat "${TEMP_JSON_FILE}")" >"${STATE_FOLDER}/system-info.json" diff --git a/templates/env-sample b/templates/env-sample index 2441dd7c..4aa5e58c 100644 --- a/templates/env-sample +++ b/templates/env-sample @@ -10,3 +10,5 @@ ARCHITECTURE= TIPI_VERSION= JWT_SECRET= ROOT_FOLDER_HOST= +NGINX_PORT= +PROXY_PORT= \ No newline at end of file From 7edc6d4f60462cd8ef618c93f2e4edf1f99bfadd Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Wed, 18 May 2022 20:22:21 +0200 Subject: [PATCH 4/5] Fix sed typo --- scripts/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/start.sh b/scripts/start.sh index 7bd88bb7..b5bad59d 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -160,8 +160,8 @@ for template in "${ENV_FILE}"; do sed -i "s//${SED_ROOT_FOLDER}/g" "${template}" sed -i "s//$(cat "${ROOT_FOLDER}/VERSION")/g" "${template}" sed -i "s//${ARCHITECTURE}/g" "${template}" - sed -i "//${NGINX_PORT}" "${template}" - sed -i "//${PROXY_PORT}" "${template}" + sed -i "s//${NGINX_PORT}/g" "${template}" + sed -i "s//${PROXY_PORT}/g" "${template}" done mv -f "$ENV_FILE" "$ROOT_FOLDER/.env" From eac3b9d6e19c87b41a6cc3f457bbdd7e11b4c941 Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Wed, 18 May 2022 20:33:57 +0200 Subject: [PATCH 5/5] Enable CORS for custom port --- docker-compose.yml | 1 + packages/system-api/src/config/config.ts | 4 ++-- requirements.txt | 1 - scripts/start.sh | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) delete mode 100644 requirements.txt diff --git a/docker-compose.yml b/docker-compose.yml index 42e98e43..7f03d286 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,6 +29,7 @@ services: - TIPI_VERSION=${TIPI_VERSION} - JWT_SECRET=${JWT_SECRET} - ROOT_FOLDER_HOST=${ROOT_FOLDER_HOST} + - NGINX_PORT=${NGINX_PORT} networks: - tipi_main_network diff --git a/packages/system-api/src/config/config.ts b/packages/system-api/src/config/config.ts index 8737c3e7..09b31f75 100644 --- a/packages/system-api/src/config/config.ts +++ b/packages/system-api/src/config/config.ts @@ -11,13 +11,13 @@ interface IConfig { dotenv.config(); -const { NODE_ENV = 'development', JWT_SECRET = '', INTERNAL_IP = '', TIPI_VERSION = '', ROOT_FOLDER_HOST = '' } = process.env; +const { NODE_ENV = 'development', JWT_SECRET = '', INTERNAL_IP = '', TIPI_VERSION = '', ROOT_FOLDER_HOST = '', NGINX_PORT = '80' } = process.env; const config: IConfig = { NODE_ENV, ROOT_FOLDER: '/tipi', JWT_SECRET, - CLIENT_URLS: ['http://localhost:3000', `http://${INTERNAL_IP}`, `http://${INTERNAL_IP}:3000`], + CLIENT_URLS: ['http://localhost:3000', `http://${INTERNAL_IP}`, `http://${INTERNAL_IP}:${NGINX_PORT}`, `http://${INTERNAL_IP}:3000`], VERSION: TIPI_VERSION, ROOT_FOLDER_HOST, }; diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index cabb1f51..00000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -ansible \ No newline at end of file diff --git a/scripts/start.sh b/scripts/start.sh index b5bad59d..193f4061 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -217,6 +217,12 @@ cat <<"EOF" | {__) ()` EOF + +port_display="" +if [[ $NGINX_PORT != "80" ]]; then + port_display=":${NGINX_PORT}" +fi + echo "" -echo "Visit http://${INTERNAL_IP}/ to view the dashboard" +echo "Visit http://${INTERNAL_IP}${port_display}/ to view the dashboard" echo ""