chore: merge conflicts

This commit is contained in:
Nicolas Meienberger 2022-11-04 08:59:31 +01:00
commit 8d766c82fe
20 changed files with 119 additions and 57 deletions

View File

@ -1,7 +1,11 @@
# ⛺️ Tipi — A personal homeserver for everyone
# Tipi — A personal homeserver for everyone
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
[![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)
@ -9,11 +13,14 @@
[![Docker Image Size](https://badgen.net/docker/size/meienberger/runtipi?icon=docker&label=image%20size)](https://hub.docker.com/r/meienberger/runtipi/)
![Build](https://github.com/meienberger/runtipi/workflows/Tipi%20CI/badge.svg)
[![codecov](https://codecov.io/gh/meienberger/runtipi/branch/master/graph/badge.svg?token=FZGO7ZOPSF)](https://codecov.io/gh/meienberger/runtipi)
#### Join the discussion
[![Discord](https://img.shields.io/discord/976934649643294750?label=discord&logo=discord)](https://discord.gg/Bu9qEPnHsc)
[![Matrix](https://img.shields.io/matrix/runtipi:matrix.org?label=matrix&logo=matrix)](https://matrix.to/#/#runtipi:matrix.org)
![Preview](https://raw.githubusercontent.com/meienberger/runtipi/develop/screenshots/appstore.png)
> ⚠️ Tipi is still at an early stage of development and issues are to be expected. Feel free to open an issue or pull request if you find a bug.
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.
@ -21,13 +28,14 @@ Tipi is a personal homeserver orchestrator. It is running docker containers unde
Check our demo instance : **[demo.runtipi.com](https://demo.runtipi.com)** / username: **user@runtipi.com** / password: **runtipi**
## Apps available
- [Adguard Home](https://github.com/AdguardTeam/AdGuardHome) - Adguard Home DNS adblocker
- [Booksonic](https://github.com/popeen) - A server for streaming your audiobooks
- [BookStack](https://www.bookstackapp.com/) - BookStack is a self-hosted platform for organising and storing information.
- [Calibre-Web](https://github.com/janeczku/calibre-web) - Web Ebook Reader
- [Code-Server](https://github.com/coder/code-server) - Web VS Code
- [Code-Server](https://github.com/coder/code-server) - Web VS Code
- [Filebrowser](https://github.com/filebrowser/filebrowser) - Web File Browser
- [Firefly III](https://github.com/firefly-iii/firefly-iii) - A personal finances manager
- [Firefly III](https://github.com/firefly-iii/firefly-iii) - A personal finances manager
- [FreshRSS](https://github.com/FreshRSS/FreshRSS) - A free, self-hostable RSS aggregator
- [Ghost](https://github.com/TryGhost/Ghost) - Ghost - Turn your audience into a business
- [Gitea](https://github.com/go-gitea/gitea) - Gitea - A painless self-hosted Git service
@ -84,9 +92,11 @@ You can find and submit new apps inside of the [RunTipi Appstore](https://github
## 🛠 Installation
### Installation Requirements
Ubuntu 18.04 LTS or higher is recommended. However other major Linux distribution are supported but may lead to installation issues. Please file an issue if you encounter one.
### Step 1. Download Tipi
Run this in an empty directory where you want to install Tipi.
```bash
@ -94,6 +104,7 @@ git clone https://github.com/meienberger/runtipi.git
```
### Step 2. Run Tipi
cd into the downloaded directory and run the start script.
```bash
@ -115,45 +126,73 @@ sudo ./scripts/stop.sh
```
### Custom settings
You can change the default settings by creating a `settings.json` file. The file should be located in the `state` directory. This file will make your changes persist across restarts. Example file with all possible values:
You can change the default settings by creating a `settings.json` file. The file should be located in the `state` directory. This file will make your changes persist across restarts. Example file:
```json
{
"dnsIp": "9.9.9.9", // DNS IP address
"domain": "mydomain.com", // Domain name to link to the dashboard
"port": 7000, // Change default http port 80
"sslPort": 7001, // Change default ssl port 443
"listenIp": "192.168.1.1", // Change default listen ip (advanced)
"storagePath": "/mnt/usb", // Change default storage path of app data
"dnsIp": "9.9.9.9",
"domain": "mydomain.com"
}
```
## Linking a domain to your dashboard
Available settings:
- `dnsIp` - The IP address of the DNS server to use. Default: `9.9.9.9`
- `domain` - The domain name to use for the dashboard. Default: `localhost`
- `port` - The port to use for the dashboard. Default: `80`
- `sslPort` - The port to use for the dashboard with SSL. Default: `443`
- `listenIp` - The IP address to listen on. Default: `automatically detected`
- `storagePath` - The path to use for storing data. Default: `runtipi/app-data`
### Linking a domain to your dashboard
If you want to link a domain to your dashboard, you can do so by providing the `--domain` option in the start script.
```bash
sudo ./scripts/start.sh --domain mydomain.com
```
You can also specify it in the `settings.json` file as shown in the previous section.
You can also specify it in the `settings.json` file as shown in the previous section to keep the setting saved across restarts.
A Let's Encrypt certificate will be generated and installed automatically. Make sure to have ports 80 and 443 open on your firewall and that your domain has an **A** record pointing to your server IP.
Please note that this setting will only expose the dashboard. If you want to expose other apps, you need to configure them individually. You cannot use the `--domain` option to expose apps.
This option will only work if you keep the default port 80 and 443 for the dashboard.
### Uninstalling Tipi
Make sure Tipi is completely stopped and then remove the `runtipi` directory.
```bash
sudo ./scripts/stop.sh
cd ..
sudo rm -rf runtipi
```
## 📚 Documentation
You can find more documentation and tutorials / FAQ in the [Wiki](https://github.com/meienberger/runtipi/wiki).
## ❤️ Contributing
Tipi is made to be very easy to plug in new apps. We welcome and appreciate new contributions.
If you want to add a new app or feature, you can follow the [Contribution guide](https://github.com/meienberger/runtipi/wiki/Adding-your-own-app) for instructions on how to do so.
We are looking for contributions of all kinds. If you know design, development, or have ideas for new features, please get in touch.
## 📜 License
[![License](https://img.shields.io/github/license/meienberger/runtipi)](https://github.com/meienberger/runtipi/blob/master/LICENSE)
Tipi is licensed under the GNU General Public License v3.0. TL;DR — You may copy, distribute and modify the software as long as you track changes/dates in source files. Any modifications to or software including (via compiler) GPL-licensed code must also be made available under the GPL along with build & install instructions.
The bash scripts `app.sh` contained in the `scripts` folder contains some snippets from [Umbrel](https://github.com/getumbrel/umbrel)'s code. Therefore some parts of the code are licensed under the PolyForm Noncommercial License 1.0.0 license. You can for now consider the whole file under this license. We are actively working on re-writing those parts in order to make them available under the GPL license like the rest of our code.
The bash script `app.sh` located in the `scripts` folder contains some snippets from [Umbrel](https://github.com/getumbrel/umbrel)'s code. Therefore some parts of the code are licensed under the PolyForm Noncommercial License 1.0.0 license. You can for now consider the whole file under this license. We are actively working on re-writing those parts in order to make them available under the GPL license like the rest of our code.
## 🗣 Community
- [Matrix](https://matrix.to/#/#runtipi:matrix.org)<br />
- [Twitter](https://twitter.com/runtipi)
- [Telegram](https://t.me/+72-y10MnLBw2ZGI0)

View File

@ -4,7 +4,7 @@ services:
reverse-proxy:
container_name: reverse-proxy
image: traefik:v2.8
restart: always
restart: unless-stopped
ports:
- ${NGINX_PORT-80}:80
- ${NGINX_PORT_SSL-443}:443
@ -21,7 +21,7 @@ services:
tipi-db:
container_name: tipi-db
image: postgres:14
restart: on-failure
restart: unless-stopped
stop_grace_period: 1m
volumes:
- ./data/postgres:/var/lib/postgresql/data

View File

@ -4,7 +4,7 @@ services:
reverse-proxy:
container_name: reverse-proxy
image: traefik:v2.8
restart: always
restart: unless-stopped
ports:
- ${NGINX_PORT-80}:80
- ${NGINX_PORT_SSL-443}:443
@ -20,7 +20,7 @@ services:
tipi-db:
container_name: tipi-db
image: postgres:14
restart: on-failure
restart: unless-stopped
stop_grace_period: 1m
volumes:
- ./data/postgres:/var/lib/postgresql/data

View File

@ -4,7 +4,7 @@ services:
reverse-proxy:
container_name: reverse-proxy
image: traefik:v2.8
restart: always
restart: unless-stopped
ports:
- ${NGINX_PORT-80}:80
- ${NGINX_PORT_SSL-443}:443
@ -19,7 +19,7 @@ services:
tipi-db:
container_name: tipi-db
image: postgres:14
restart: on-failure
restart: unless-stopped
stop_grace_period: 1m
volumes:
- ${PWD}/data/postgres:/var/lib/postgresql/data

View File

@ -1,6 +1,6 @@
{
"name": "runtipi",
"version": "0.7.1",
"version": "0.7.2",
"description": "A homeserver for everyone",
"scripts": {
"prepare": "husky install",

View File

@ -1,6 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
verbose: true,
// testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.test.ts'],

View File

@ -1,6 +1,6 @@
{
"name": "dashboard",
"version": "0.7.1",
"version": "0.7.2",
"private": true,
"scripts": {
"test": "jest --colors",

View File

@ -1,3 +1,4 @@
import { useApolloClient } from '@apollo/client';
import { useToast } from '@chakra-ui/react';
import React, { useState } from 'react';
import { useRegisterMutation } from '../../../generated/graphql';
@ -5,6 +6,7 @@ import AuthFormLayout from '../components/AuthFormLayout';
import RegisterForm from '../components/RegisterForm';
const Onboarding: React.FC = () => {
const client = useApolloClient();
const toast = useToast();
const [register] = useRegisterMutation({ refetchQueries: ['Me'] });
const [loading, setLoading] = useState(false);
@ -24,7 +26,13 @@ const Onboarding: React.FC = () => {
const handleRegister = async (values: { email: string; password: string }) => {
try {
setLoading(true);
await register({ variables: { input: { username: values.email, password: values.password } } });
const { data } = await register({ variables: { input: { username: values.email, password: values.password } } });
if (data?.register?.token) {
localStorage.setItem('token', data.register.token);
}
await client.refetchQueries({ include: ['Me'] });
} catch (error) {
handleError(error);
} finally {

View File

@ -1,11 +1,13 @@
module.exports = {
createClient: jest.fn(() => {
const values = new Map();
const expirations = new Map();
return {
isOpen: true,
connect: jest.fn(),
set: (key: string, value: string) => {
set: (key: string, value: string, exp: number) => {
values.set(key, value);
expirations.set(key, exp);
},
get: (key: string) => {
return values.get(key);
@ -14,6 +16,9 @@ module.exports = {
del: (key: string) => {
return values.delete(key);
},
ttl: (key: string) => {
return expirations.get(key);
},
};
}),
};

View File

@ -1,6 +1,6 @@
{
"name": "system-api",
"version": "0.7.1",
"version": "0.7.2",
"description": "",
"exports": "./dist/server.js",
"type": "module",

View File

@ -51,6 +51,11 @@ class TipiCache {
public async close() {
return this.client.quit();
}
public async ttl(key: string) {
const client = await this.getClient();
return client.ttl(key);
}
}
export default TipiCache.getInstance();

View File

@ -497,7 +497,7 @@ describe('List apps', () => {
it('Should list apps that have no supportedArchitectures specified', async () => {
// Arrange
setConfig('architecture', AppSupportedArchitecturesEnum.ARM);
const app3 = await createApp({});
const app3 = await createApp({ supportedArchitectures: undefined });
// @ts-ignore
fs.__createMockFiles(Object.assign(app3.MockFiles));

View File

@ -159,19 +159,16 @@ const listApps = async (): Promise<ListAppsResonse> => {
const apps: AppInfo[] = folders
.map((app) => {
try {
return readJsonFile(`/runtipi/repos/${getConfig().appsRepoId}/apps/${app}/config.json`);
} catch (e) {
return null;
}
return readJsonFile(`/runtipi/repos/${getConfig().appsRepoId}/apps/${app}/config.json`);
})
.filter(Boolean);
apps.forEach((app) => {
app.description = readFile(`/runtipi/repos/${getConfig().appsRepoId}/apps/${app.id}/metadata/description.md`);
const filteredApps = filterApps(apps).map((app) => {
const description = readFile(`/runtipi/repos/${getConfig().appsRepoId}/apps/${app.id}/metadata/description.md`);
return { ...app, description };
});
return { apps: filterApps(apps), total: apps.length };
return { apps: filteredApps, total: apps.length };
};
/**

View File

@ -182,19 +182,20 @@ describe('Test: refreshToken', () => {
expect(result?.token).not.toBe(session);
});
it('Should delete old session from cache', async () => {
it('Should put expiration in 6 seconds for old session', async () => {
// Arrange
const session = faker.random.alphaNumeric(32);
await TipiCache.set(session, '1');
// Act
const result = await AuthService.refreshToken(session);
const expiration = await TipiCache.ttl(session);
// Assert
expect(result).not.toBeNull();
expect(result).toHaveProperty('token');
expect(result?.token).not.toBe(session);
expect(await TipiCache.get(session)).toBeUndefined();
expect(expiration).toMatchObject({ EX: 6 });
});
});

View File

@ -81,7 +81,8 @@ const refreshToken = async (session?: string): Promise<TokenResponse | null> =>
const userId = await TipiCache.get(session);
if (!userId) return null;
await TipiCache.del(session);
// Expire token in 6 seconds
await TipiCache.set(session, userId, 6);
const newSession = v4();
const token = jwt.sign({ id: userId, session: newSession }, getConfig().jwtSecret, { expiresIn: '1d' });

View File

@ -54,7 +54,7 @@ function ensure_linux() {
function clean_logs() {
# Clean logs folder
logs_folder="${ROOT_FOLDER}/logs"
local logs_folder="${ROOT_FOLDER}/logs"
# Create the folder if it doesn't exist
if [[ ! -d "${logs_folder}" ]]; then
@ -64,7 +64,7 @@ function clean_logs() {
if [ "$(find "${logs_folder}" -maxdepth 1 -type f | wc -l)" -gt 0 ]; then
echo "Cleaning logs folder..."
files=($(ls -d "${logs_folder}"/* | xargs -n 1 basename | sed 's/\///g'))
local files=($(ls -d "${logs_folder}"/* | xargs -n 1 basename | sed 's/\///g'))
for file in "${files[@]}"; do
echo "Removing ${file}"
@ -74,16 +74,18 @@ function clean_logs() {
}
function kill_watcher() {
watcher_pid="$(ps aux | grep "scripts/watcher" | grep -v grep | awk '{print $2}')"
local watcher_pid="$(ps aux | grep "scripts/watcher" | grep -v grep | awk '{print $2}')"
# kill it if it's running
if [[ -n $watcher_pid ]]; then
# If multiline kill each pid
if [[ $watcher_pid == *" "* ]]; then
for pid in $watcher_pid; do
# shellcheck disable=SC2086
kill -9 $pid
done
else
# shellcheck disable=SC2086
kill -9 $watcher_pid
fi
fi

View File

@ -1,5 +1,10 @@
#!/usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
source "${BASH_SOURCE%/*}/common.sh"

View File

@ -1,7 +1,11 @@
#!/usr/bin/env bash
set -e # Exit immediately if a command exits with a non-zero status.
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}"
@ -80,12 +84,12 @@ fi
### --------------------------------
### CLI arguments
### --------------------------------
while [ -n "$1" ]; do
while [ -n "${1-}" ]; do
case "$1" in
--rc) rc="true" ;;
--ci) ci="true" ;;
--port)
port="$2"
port="${2-}"
if [[ "${port}" =~ ^[0-9]+$ ]]; then
NGINX_PORT="${port}"
@ -96,7 +100,7 @@ while [ -n "$1" ]; do
shift
;;
--ssl-port)
ssl_port="$2"
ssl_port="${2-}"
if [[ "${ssl_port}" =~ ^[0-9]+$ ]]; then
NGINX_PORT_SSL="${ssl_port}"
@ -107,7 +111,7 @@ while [ -n "$1" ]; do
shift
;;
--domain)
domain="$2"
domain="${2-}"
if [[ "${domain}" =~ ^[a-zA-Z0-9.-]+$ ]]; then
DOMAIN="${domain}"
@ -118,7 +122,7 @@ while [ -n "$1" ]; do
shift
;;
--listen-ip)
listen_ip="$2"
listen_ip="${2-}"
if [[ "${listen_ip}" =~ ^[a-fA-F0-9.:]+$ ]]; then
INTERNAL_IP="${listen_ip}"
@ -230,9 +234,9 @@ mv -f "$ENV_FILE" "$ROOT_FOLDER/.env"
### --------------------------------
### Start the project
### --------------------------------
if [[ ! $ci == "true" ]]; then
if [[ ! "${ci-false}" == "true" ]]; then
if [[ $rc == "true" ]]; then
if [[ "${rc-false}" == "true" ]]; then
docker compose -f docker-compose.rc.yml --env-file "${ROOT_FOLDER}/.env" pull
# Run docker compose
docker compose -f docker-compose.rc.yml --env-file "${ROOT_FOLDER}/.env" up --detach --remove-orphans --build || {

View File

@ -16,7 +16,7 @@ export COMPOSE_HTTP_TIMEOUT=240
# Stop all installed apps if there are any
apps_folder="${ROOT_FOLDER}/apps"
if [ "$(find "${apps_folder}" -maxdepth 1 -type d | wc -l)" -gt 1 ]; then
apps_names=($(ls -d ${apps_folder}/*/ | xargs -n 1 basename | sed 's/\///g'))
apps_names=($(ls -d "${apps_folder}"/*/ | xargs -n 1 basename | sed 's/\///g'))
for app_name in "${apps_names[@]}"; do
# if folder ${ROOT_FOLDER}/app-data/app_name exists, then stop app
@ -29,6 +29,7 @@ else
echo "No app installed that can be stopped."
fi
kill_watcher
echo "Stopping Docker services..."
echo
docker compose down --remove-orphans --rmi local

View File

@ -6,8 +6,6 @@ ROOT_FOLDER="${PWD}"
WATCH_FILE="${ROOT_FOLDER}/state/events"
function clean_events() {
echo "Cleaning events..."
# Create the file if it doesn't exist
if [[ ! -f "${WATCH_FILE}" ]]; then
touch "${WATCH_FILE}"
@ -43,8 +41,6 @@ function run_command() {
local result=$?
echo "Command ${command_path} exited with code ${result}"
if [[ $result -eq 0 ]]; then
set_status "$id" "success"
else
@ -105,7 +101,6 @@ function select_command() {
return 0
fi
echo "Unknown command ${command}"
return 0
}