Browse Source

merge master

v1
Steven Foerster 4 years ago
parent
commit
ff93578f1b
  1. 193
      README.md
  2. 11
      base.yml
  3. 28
      extra/bitwarden.yml
  4. 255
      extra/jitsi-meet.yml
  5. 33
      extra/raspap.yml
  6. 35
      extra/syncthing.yml
  7. 16
      extra/tor.yml
  8. 3
      scripts/conf/docker-daemon.json
  9. 35
      scripts/env/check_env_file.sh
  10. 3
      scripts/env/setup.sh
  11. 37
      scripts/install.sh
  12. 9
      scripts/services/Mistborn-base.service
  13. 10
      scripts/subinstallers/check_updates.sh
  14. 16
      scripts/subinstallers/docker.sh
  15. 7
      scripts/subinstallers/docker_daemon.sh
  16. 5
      scripts/subinstallers/docker_manual.sh
  17. 46
      scripts/subinstallers/docker_raspbian.sh
  18. 4
      scripts/subinstallers/gen_prod_env.sh
  19. 2
      scripts/subinstallers/iptables.sh
  20. 22
      scripts/subinstallers/passwd.sh
  21. 36
      scripts/subinstallers/platform.sh
  22. 7
      scripts/update.sh
  23. 57
      scripts/wrappers/mistborn_docker.sh

193
README.md

@ -1,7 +1,7 @@
# Mistborn # Mistborn
A secure platform for easily standing up and managing your own cloud services: including firewall, ad-blocking, and multi-factor Wireguard VPN access A secure platform for easily standing up and managing your own cloud services: including firewall, ad-blocking, and multi-factor WireGuard VPN access
![Mistborn Wireguard](https://gitlab.com/cyber5k/public/-/raw/master/graphics/home.mistborn_wireguard_.png)*Wireguard Management in Mistborn* ![Mistborn WireGuard](https://gitlab.com/cyber5k/public/-/raw/master/graphics/home.mistborn_wireguard_.png)*WireGuard Management in Mistborn*
As featured in [Linux Magazine](https://www.linux-magazine.com/Issues/2020/240/Mistborn/(language)/eng-US) (Linux Pro Magazine in North America) in November 2020 As featured in [Linux Magazine](https://www.linux-magazine.com/Issues/2020/240/Mistborn/(language)/eng-US) (Linux Pro Magazine in North America) in November 2020
@ -13,13 +13,15 @@ As featured in [Linux Magazine](https://www.linux-magazine.com/Issues/2020/240/M
# What is Mistborn # What is Mistborn
The term [Mistborn](http://www.brandonsanderson.com/the-mistborn-saga-the-original-trilogy) is inspired by a type of powerful Allomancer in Brandon Sanderson's Cosmere. The term [Mistborn](http://www.brandonsanderson.com/the-mistborn-saga-the-original-trilogy) is inspired by a type of powerful Allomancer in Brandon Sanderson's Cosmere.
Mistborn started as a passion project for a husband and father protecting his family. Certain family members insisted on connecting their devices to free public WiFi networks. We needed a way to secure all family devices with a solid VPN (Wireguard). Once we had that we wanted to control DNS to block ads to all devices and block malicious websites across all family devices. Then we wanted chat, file-sharing, and webchat services that we could use for ourselves without entrusting our data to some big tech company. And then... home automation. I know I'll be adding more services so I made that easy to do. Mistborn started as a passion project for a husband and father protecting his family. Certain family members insisted on connecting their devices to free public WiFi networks. We needed a way to secure all family devices with a solid VPN (WireGuard). Once we had that we wanted to control DNS to block ads to all devices and block malicious websites across all family devices. Then we wanted chat, file-sharing, and webchat services that we could use for ourselves without entrusting our data to some big tech company. And then... home automation. I know I'll be adding more services so I made that easy to do.
As an [Offensive Security Certified Professional (OSCP)](https://resources.infosecinstitute.com/certification/the-oscp-certification-and-exam/), I designed Mistborn thinking about how it would be attacked by both external and internal threats. In making design trade-off decisions I tend to the paranoid. See [Technical and Security Insights](#technical-and-security-insights).
Ideal for teams who: Ideal for teams who:
- hate internet ads - hate internet ads
- need to be protected from malicious internet domains - need to be protected from malicious internet domains
- need to collaborate securely - need to collaborate securely
- need multi-factor authentication for Wireguard - need multi-factor authentication for WireGuard
- want to retain sole ownership of their data - want to retain sole ownership of their data
- want to easily grant and revoke access to people and devices via a simple web interface - want to easily grant and revoke access to people and devices via a simple web interface
- want secure internet access wherever they are - want secure internet access wherever they are
@ -30,7 +32,7 @@ See the [Mistborn Network Security](https://gitlab.com/cyber5k/mistborn/-/wikis/
Mistborn depends on these core open source technologies: Mistborn depends on these core open source technologies:
- [Docker](https://www.docker.com/why-docker): containerization - [Docker](https://www.docker.com/why-docker): containerization
- [Wireguard](https://www.wireguard.com): secure VPN access - [WireGuard](https://www.wireguard.com): secure VPN access
- [SSH](https://www.openssh.com): secure remote management - [SSH](https://www.openssh.com): secure remote management
These tools are not vital to Mistborn itself but are integrated to enhance security, ease, and features: These tools are not vital to Mistborn itself but are integrated to enhance security, ease, and features:
@ -40,6 +42,10 @@ These tools are not vital to Mistborn itself but are integrated to enhance secur
- [DNScrypt](https://www.dnscrypt.org): prevents DNS spoofing via cryptographic signatures to verify that responses originate from the chosen DNS resolver and haven't been tampered - [DNScrypt](https://www.dnscrypt.org): prevents DNS spoofing via cryptographic signatures to verify that responses originate from the chosen DNS resolver and haven't been tampered
- [Traefik](https://docs.traefik.io): A modern, efficient reverse-proxy - [Traefik](https://docs.traefik.io): A modern, efficient reverse-proxy
These tools can be turned on from the Mistborn Security Operations Center:
- [Wazuh](https://wazuh.com/): Wazuh is a free, open source and enterprise-ready security monitoring solution for threat detection, integrity monitoring, incident response and compliance.
- [Suricata](https://suricata-ids.org/): Suricata is a free and open source, mature, fast and robust network threat detection engine. The Suricata engine is capable of real time intrusion detection (IDS), inline intrusion prevention (IPS), network security monitoring (NSM) and offline pcap processing. Suricata inspects the network traffic using a powerful and extensive rules and signature language, and has powerful Lua scripting support for detection of complex threats.
Within Mistborn is a panel to enable and manage these free extra services (off by default), locally hosted in Docker containers: Within Mistborn is a panel to enable and manage these free extra services (off by default), locally hosted in Docker containers:
- [Home Assistant](https://www.home-assistant.io): Open source home automation that puts local control and privacy first - [Home Assistant](https://www.home-assistant.io): Open source home automation that puts local control and privacy first
- [Nextcloud](https://nextcloud.com): Nextcloud offers the industry-leading, on-premises content collaboration platform. It combines the convenience and ease of use of consumer-grade solutions like Dropbox and Google Drive with the security, privacy and control business needs. - [Nextcloud](https://nextcloud.com): Nextcloud offers the industry-leading, on-premises content collaboration platform. It combines the convenience and ease of use of consumer-grade solutions like Dropbox and Google Drive with the security, privacy and control business needs.
@ -50,6 +56,8 @@ Within Mistborn is a panel to enable and manage these free extra services (off b
- [Jellyfin](https://jellyfin.org): The Free Media Software System. - [Jellyfin](https://jellyfin.org): The Free Media Software System.
- [Tor](https://www.torproject.org): The Onion Router. One tool in the arsenal of online security and privacy. - [Tor](https://www.torproject.org): The Onion Router. One tool in the arsenal of online security and privacy.
- [Jitsi](https://jitsi.org): Multi-platform open-source video conferencing - [Jitsi](https://jitsi.org): Multi-platform open-source video conferencing
- [Guacamole](https://guacamole.apache.org): A clientless remote desktop gateway that supports standard protocols like VNC, RDP, and SSH.
- [RaspAP](https://raspap.com/): The easiest, full-featured wireless router setup for Debian-based devices. Period. (Mistborn integration in alpha testing).
# Quickstart # Quickstart
Tested Operating Systems (in order of thoroughness): Tested Operating Systems (in order of thoroughness):
@ -69,17 +77,18 @@ The Mistborn docker images exist for these architectures:
| Mistborn Docker Images (hub.docker.com) | Architectures | | Mistborn Docker Images (hub.docker.com) | Architectures |
|------------------------------------------------|---------------------| |------------------------------------------------|---------------------|
| mistborn (django, celery{worker,beat}, flower) | amd64, arm64, arm/v7 | | mistborn (django, celery{worker,beat}) | amd64, arm64, arm/v7 |
| dnscrypt-proxy | amd64, arm64, arm/v7 | | dnscrypt-proxy | amd64, arm64, arm/v7 |
Recommended System Specifications: Recommended System Specifications:
| Use Case | Description | RAM | Hard Disk | | Use Case | Description | RAM | Hard Disk |
|------------------------|-------------------------------------------------------------------------------|-------|-----------| |------------------------|-------------------------------------------------------------------------------|-------|-----------|
| Bare bones | Wireguard, Pihole (no Cockpit, no extra services) | 2 GB | 15 GB | | Bare bones | WireGuard, Pihole (no Cockpit, no extra services) | 2 GB | 15 GB |
| Default | Bare bones + Cockpit | 2 GB+ | 15 GB | | Default | Bare bones + Cockpit | 2 GB+ | 15 GB |
| Low-resource services | Default + Bitwarden, Tor, Syncthing | 4 GB | 20 GB | | Low-resource services | Default + Bitwarden, Tor, Syncthing | 4 GB | 20 GB |
| High-resource services | Default + Jitsi, Nextcloud, Jellyfin, Rocket.Chat, Home Assistant, OnlyOffice | 6 GB+ | 25 GB+ | | High-resource services | Default + Jitsi, Nextcloud, Jellyfin, Rocket.Chat, Home Assistant, OnlyOffice | 6 GB+ | 25 GB+ |
| SIEM | Default + Wazuh + Extras | 16 GB+ | 100 GB+ |
Starting from base installation Starting from base installation
``` ```
@ -87,26 +96,45 @@ git clone https://gitlab.com/cyber5k/mistborn.git
sudo -E bash ./mistborn/scripts/install.sh sudo -E bash ./mistborn/scripts/install.sh
``` ```
Get default admin Wireguard profile Get default admin WireGuard profile
*wait 1 minute after "Mistborn Installed" message* *wait 1 minute after "Mistborn Installed" message*
``` ```
sudo mistborn-cli getconf sudo mistborn-cli getconf
``` ```
Connect via Wireguard then visit `http://home.mistborn` Connect via WireGuard then visit `http://home.mistborn`
For more information, see the `Installation` section below. For more information, see the [Installation](#installation) section below.
# Network Diagram # Network Diagram
![Mistborn Network Diagram](https://gitlab.com/cyber5k/public/-/raw/master/graphics/mistborn_network.png) ![Mistborn Network Diagram](https://gitlab.com/cyber5k/public/-/raw/master/graphics/mistborn_network.png)
Mistborn protects your data in a variety of ways: Mistborn protects your data in a variety of ways:
- All of your devices are protected wherever they go with the Wireguard VPN protocol - All of your devices are protected wherever they go with the WireGuard VPN protocol
- The Mistborn firewall blocks unsolicited incoming internet packets - The Mistborn firewall blocks unsolicited incoming internet packets
- Pi-hole running on Mistborn blocks outgoing internet requests to configurable blocked domains (ads, malicious/phishing domains, etc.) - Pi-hole running on Mistborn blocks outgoing internet requests to configurable blocked domains (ads, malicious/phishing domains, etc.)
See the [Mistborn Network Security](https://gitlab.com/cyber5k/mistborn/-/wikis/Mistborn-Network-Security) wiki page to see more network diagrams and the network scan results for Mistborn. See the [Mistborn Network Security](https://gitlab.com/cyber5k/mistborn/-/wikis/Mistborn-Network-Security) wiki page to see more network diagrams and the network scan results for Mistborn.
# Status
![Mistborn Home](https://gitlab.com/cyber5k/public/-/raw/master/graphics/home_status.png)
The home page receives WireGuard status updates from the server via WebSocket connections. Superusers receive detailed updates about all connections and profiles. Regular users see details about their own devices.
# Security Information & Event Management (SIEM)
![Mistborn Security Center](https://gitlab.com/cyber5k/public/-/raw/master/graphics/home.mistborn_soc.png)
The Mistborn Security Operations Center provides SIEM services with Wazuh. The Wazuh Manager requires an Open Distro for Elasticsearch backend. When the Mistborn host has >8 GB RAM the provided Elasticsearch backend can be used. Just click "Start Wazuh" on the `Security Center` page and enjoy your Enterprise-grade SIEM. Wazuh agents can be installed on just about any OS and all Wazuh agent traffic is communicated over the WireGuard connections. Instructions for adding endpoint agents can be found within Wazuh itself.
Mistborn's Wazuh installs and integrates with Suricata running on Mistborn with logs ingested into Wazuh.
![Mistborn Security Center: Wazuh Modules](https://gitlab.com/cyber5k/public/-/raw/master/graphics/wazuh_modules.png)
The Wazuh Kibana plugin leverages the power of Elasticsearch:
![Mistborn Security Center: Wazuh Dashboard](https://gitlab.com/cyber5k/public/-/raw/master/graphics/wazuh_se_dashboard.png)
# Coppercloud # Coppercloud
Pihole provides a way to block outgoing DNS requests for given lists of blocked domains. Coppercloud provides a way to block outgoing network calls of all types to given lists of IP addresses (IPv4 only for now). This is especially useful for blocking outgoing telemetry (data and state sharing) to owners of software running on all of your devices. Pihole provides a way to block outgoing DNS requests for given lists of blocked domains. Coppercloud provides a way to block outgoing network calls of all types to given lists of IP addresses (IPv4 only for now). This is especially useful for blocking outgoing telemetry (data and state sharing) to owners of software running on all of your devices.
@ -121,19 +149,28 @@ We were getting frustrated at being forced to choose between being connected to
*Netflix blocking my connections that it sees coming from a DigitalOcean droplet* *Netflix blocking my connections that it sees coming from a DigitalOcean droplet*
In Mistborn, Gateways are upstream from the VPN server so connections to third-party services (e.g. Netflix, Hulu, etc.) will appear to be coming from the public IP address of the Gateway. I setup a Gateway at home (Raspberry Pi with `wireguard` and `openresolv` installed) and with our Mistborn on DigitalOcean, all Wireguard profiles created with this Gateway will appear to be coming from my house and are not blocked. No port-forwarding required (assuming Mistborn is publicly accessible). In Mistborn, Gateways are upstream from the VPN server so connections to third-party services (e.g. Netflix, Hulu, etc.) will appear to be coming from the public IP address of the Gateway. I setup a Gateway at home (Raspberry Pi with `wireguard` and `openresolv` installed) and with our Mistborn on DigitalOcean, all WireGuard profiles created with this Gateway will appear to be coming from my house and are not blocked. No port-forwarding required (assuming Mistborn is publicly accessible).
![Mistborn Gateway Diagram](https://gitlab.com/cyber5k/public/-/raw/master/graphics/gateway_network.png) ![Mistborn Gateway Diagram](https://gitlab.com/cyber5k/public/-/raw/master/graphics/gateway_network.png)
The Gateway adds an extra network hop. DNS is still resolved in Mistborn so pihole is still blocking ads. The Gateway adds an extra network hop. DNS is still resolved in Mistborn so pihole is still blocking ads.
# Remote Desktop
Remote desktops enable multiple users to share desktop resources and data. Remote desktops also enable groups to prevent sensitive data from ever entering an endpoint devices such as a smartphone. For reference, some United States Government regulations require controls to protect Controlled Unclassified Information (CUI) that are not feasible to implement on all endpoint devices and remote desktops prevent the data from entering the device (see NIST SP 800-171 3.1.19, CMMC AC.3.022).
Mistborn enables remote desktop access via the Apache Guacamole extra service, which supports VNC, RDP, SSH, and other protocols.
![Guacamole Recent Connections](https://gitlab.com/cyber5k/public/-/raw/master/graphics/guacamole_connections.png)
Guacamole implements its own users and groups access controls to manage access to individual desktops. All Mistborn users must be authenticated with Mistborn (via WireGuard only or MFA) to access the Guacamole interface.
# Client to client communication # Client to client communication
By default direct communication between network clients is blocked. Mistborn clients can all talk to Mistborn and communicate via shared services (Jitsi, Nextcloud, etc). Direct client to client communication can be enabled via the "client-to-client" toggle. By default direct communication between network clients is blocked. Mistborn clients can all talk to Mistborn and communicate via shared services (Jitsi, Nextcloud, etc). Direct client to client communication can be enabled via the "client-to-client" toggle.
![System Settings](https://gitlab.com/cyber5k/public/-/raw/master/graphics/system_settings_dropdown.png) ![System Settings](https://gitlab.com/cyber5k/public/-/raw/master/graphics/system_settings_dropdown.png)
# Installation # Installation
Mistborn is regularly tested on Ubuntu 20.04 LTS (DigitalOcean droplet with 2 GB RAM). It has also been successfully used on Debian Buster and Raspbian Buster systems (though not regularly tested). Make sure to install OS updates and restart before installing Mistborn (Wireguard installs differently on recent kernels). Mistborn is regularly tested on Ubuntu 20.04 LTS (DigitalOcean droplet with 2 GB RAM). It has also been successfully used on Debian Buster and Raspbian Buster systems (though not regularly tested). Make sure to install OS updates and restart before installing Mistborn (WireGuard installs differently on recent kernels).
Clone the git repository and run the install script: Clone the git repository and run the install script:
``` ```
@ -148,7 +185,7 @@ Running `install.sh` will do the following:
- install iptables-persistent - install iptables-persistent
- install Docker - install Docker
- install OpenSSH - install OpenSSH
- install Wireguard - install WireGuard
- install Cockpit (optional) - install Cockpit (optional)
- create a `cockpit` system user (if Cockpit is installed) - create a `cockpit` system user (if Cockpit is installed)
- configure unattended-upgrades - configure unattended-upgrades
@ -176,23 +213,23 @@ sudo -E bash -c "source ./mistborn/scripts/noninteractive/.install_barebones &&
``` ```
# Post-Installation # Post-Installation
When Mistborn-base starts up it will create volumes, initialize the PostgreSQL database, start pihole, run Django migrations and then check to see if a Mistborn superuser named `admin` exists yet. If not, it will create the superuser `admin` along with an accompanying default Wireguard configuration file and start the Wireguard service. You can watch all of this happen with: When Mistborn-base starts up it will create volumes, initialize the PostgreSQL database, start pihole, run Django migrations and then check to see if a Mistborn superuser named `admin` exists yet. If not, it will create the superuser `admin` along with an accompanying default WireGuard configuration file and start the WireGuard service. You can watch all of this happen with:
``` ```
sudo journalctl -xfu Mistborn-base sudo journalctl -xfu Mistborn-base
``` ```
The default Wireguard configuration file for `admin` may be obtained via: The default WireGuard configuration file for `admin` may be obtained via:
``` ```
sudo mistborn-cli getconf sudo mistborn-cli getconf
``` ```
Please notice that the following lines are **NOT** part of the Wireguard config: Please notice that the following lines are **NOT** part of the WireGuard config:
``` ```
Starting mistborn_production_postgres ... done Starting mistborn_production_postgres ... done
Starting mistborn_production_redis ... done Starting mistborn_production_redis ... done
PostgreSQL is available PostgreSQL is available
``` ```
The Wireguard config will look like this: The WireGuard config will look like this:
``` ```
# "10.15.91.2" - WireGuard Client Profile # "10.15.91.2" - WireGuard Client Profile
[Interface] [Interface]
@ -214,18 +251,18 @@ AllowedIPs = 0.0.0.0/0,::/0
Endpoint = <Mistborn public IP address>:39207 Endpoint = <Mistborn public IP address>:39207
``` ```
## Login via Wireguard ## Login via WireGuard
[Install wireguard](https://www.wireguard.com/install/) on your computer. If you get a `resolvconf: command not found` error when starting Wireguard then install openresolv: `sudo apt-get install -y openresolv` [Install wireguard](https://www.wireguard.com/install/) on your computer. If you get a `resolvconf: command not found` error when starting WireGuard then install openresolv: `sudo apt-get install -y openresolv`
- Copy the text of the default admin Wireguard config to `/etc/wireguard/wg_admin.conf` on your computer - Copy the text of the default admin WireGuard config to `/etc/wireguard/wg_admin.conf` on your computer
- Run `sudo systemctl start wg-quick@wg_admin` - Run `sudo systemctl start wg-quick@wg_admin`
- Run `sudo systemctl enable wg-quick@wg_admin` - Run `sudo systemctl enable wg-quick@wg_admin`
- Open your browser and go to "http://home.mistborn" - Open your browser and go to "http://home.mistborn"
- Browse your Mistborn system! - Browse your Mistborn system!
**Note:** The home.mistborn server takes a minute to come up after Mistborn is up (collectstatic on all that frontend JavaScript and CSS) **Note:** The home.mistborn server takes a minute to come up after Mistborn is up (collectstatic on all that frontend JavaScript and CSS)
## Wireguard Management ## WireGuard Management
Mistborn users can be added (non-privileged or superuser) and removed by superusers. Multiple Wireguard profiles can be created for each user. A non-privileged user can create profiles for themselves. Mistborn users can be added (non-privileged or superuser) and removed by superusers. Multiple WireGuard profiles can be created for each user. A non-privileged user can create profiles for themselves.
![Mistborn Wireguard](https://gitlab.com/cyber5k/public/-/raw/master/graphics/home.mistborn_wireguard_.png)*Wireguard Management in Mistborn* ![Mistborn WireGuard](https://gitlab.com/cyber5k/public/-/raw/master/graphics/home.mistborn_wireguard_.png)*WireGuard Management in Mistborn*
## Extra Services ## Extra Services
Mistborn makes extra services available. Mistborn makes extra services available.
@ -240,11 +277,11 @@ There are multiple ways to authenticate and use the system.
![Mistborn Multi Factor Authentication - Authenticator App Setup](https://gitlab.com/cyber5k/public/-/raw/master/graphics/mfa_qr.png)*Mistborn Multi Factor Authentication - Authenticator App Setup* ![Mistborn Multi Factor Authentication - Authenticator App Setup](https://gitlab.com/cyber5k/public/-/raw/master/graphics/mfa_qr.png)*Mistborn Multi Factor Authentication - Authenticator App Setup*
## Profile: Wireguard Authentication ## Profile: WireGuard Authentication
Mistborn always authenticates with Wireguard. You must have a valid Wireguard configuration file associated with the correct internal IP address. A classic Mistborn profile (Wireguard Only) will allow you to access the internet and all services hosted by Mistborn once you have connected via Wireguard. Note: individual services may require passwords or additional authentication. Mistborn always authenticates with WireGuard. You must have a valid WireGuard configuration file associated with the correct internal IP address. A classic Mistborn profile (WireGuard Only) will allow you to access the internet and all services hosted by Mistborn once you have connected via WireGuard. Note: individual services may require passwords or additional authentication.
## Profile: Multi Factor Authentication (MFA) ## Profile: Multi Factor Authentication (MFA)
In addition to Wireguard, you may create a Mistborn profile enabling multi-factor authentication (MFA). You must first connect to Mistborn via Wireguard. Then all internet traffic will route you to the Mistborn webserver where you must first setup and thereafter authenticate with an app (Google Authenticator, Authy, etc.). You must go to [http://home.mistborn](http://home.mistborn) to complete the authentication process. In addition to WireGuard, you may create a Mistborn profile enabling multi-factor authentication (MFA). You must first connect to Mistborn via WireGuard. Then all internet traffic will route you to the Mistborn webserver where you must first setup and thereafter authenticate with an app (Google Authenticator, Authy, etc.). You must go to [http://home.mistborn](http://home.mistborn) to complete the authentication process.
![Mistborn Multi Factor Authentication](https://gitlab.com/cyber5k/public/-/raw/master/graphics/mfa1.png)*Mistborn Multi Factor Authentication Prompt* ![Mistborn Multi Factor Authentication](https://gitlab.com/cyber5k/public/-/raw/master/graphics/mfa1.png)*Mistborn Multi Factor Authentication Prompt*
@ -262,7 +299,7 @@ Mistborn service access is blocked via traefik until Mistborn authentication is
- **Sessions**: Traefik checks the authenticated sessions on the server side to determine whether to allow access to the Mistborn service web pages. If an open session exists for your Mistborn IP address then access will be granted. You may close all sessions by clicking "Sign Out" on the Mistborn home page. Expired sessions are regularly cleaned by the Mistborn system (celery periodic task). - **Sessions**: Traefik checks the authenticated sessions on the server side to determine whether to allow access to the Mistborn service web pages. If an open session exists for your Mistborn IP address then access will be granted. You may close all sessions by clicking "Sign Out" on the Mistborn home page. Expired sessions are regularly cleaned by the Mistborn system (celery periodic task).
# Mistborn Subdomains # Mistborn Subdomains
Mistborn uses the following domains (that can be reached by all Wireguard clients): Mistborn uses the following domains (that can be reached by all WireGuard clients):
| Service | Domain | Default Status | | Service | Domain | Default Status |
| ------- | ------ | -------------- | | ------- | ------ | -------------- |
@ -277,6 +314,9 @@ Mistborn uses the following domains (that can be reached by all Wireguard client
| Syncthing | syncthing.mistborn | Off | | Syncthing | syncthing.mistborn | Off |
| OnlyOffice | onlyoffice.mistborn | Off | | OnlyOffice | onlyoffice.mistborn | Off |
| Jitsi | jitsi.mistborn | Off | | Jitsi | jitsi.mistborn | Off |
| Guacamole | guac.mistborn | Off |
| RaspAP | raspap.mistborn | Off |
| Wazuh | wazuh.mistborn | Off |
# Default Credentials # Default Credentials
These are the default credentials to use in the services you choose to use: These are the default credentials to use in the services you choose to use:
@ -285,19 +325,22 @@ These are the default credentials to use in the services you choose to use:
| ------- | -------- | -------- | | ------- | -------- | -------- |
| Pihole | | {{default mistborn password}} | | Pihole | | {{default mistborn password}} |
| Cockpit | cockpit | {{default mistborn password}} | | Cockpit | cockpit | {{default mistborn password}} |
| Wazuh | mistborn | {{default mistborn password}} |
| Nextcloud | mistborn | {{default mistborn password}} | | Nextcloud | mistborn | {{default mistborn password}} |
| Guacamole | mistborn | {{default mistborn password }} |
| RaspAP | mistborn | {{default mistborn password}} |
You can find the credentials sent to the Docker containers in: `/opt/mistborn/.envs/.production/` You can find the credentials sent to the Docker containers in: `/opt/mistborn/.envs/.production/`
# Gateway Setup # Gateway Setup
Mistborn will generate the Wireguard configuration script for the Gateway. From a base Ubuntu/Debian/Raspbian operating system the following packages are recommended to be installed beforehand: Mistborn will generate the WireGuard configuration script for the Gateway. From a base Ubuntu/Debian/Raspbian operating system the following packages are recommended to be installed beforehand:
## Gateway Requirements ## Gateway Requirements
- Wireguard (you can consult the Mistborn Wireguard installer: `mistborn/scripts/subinstallers/wireguard.sh`) - WireGuard (you can consult the Mistborn WireGuard installer: `mistborn/scripts/subinstallers/wireguard.sh`)
- Openresolv (a Wireguard dependency that is also installed via the Mistborn Wireguard installer) - Openresolv (a WireGuard dependency that is also installed via the Mistborn WireGuard installer)
- Fail2ban - Fail2ban
## Install Gateway Wireguard config file ## Install Gateway WireGuard config file
On Mistborn: On Mistborn:
- Click `View Config` on the Gateways tab in Mistborn - Click `View Config` on the Gateways tab in Mistborn
- Highlight the config - Highlight the config
@ -309,15 +352,15 @@ On Gateway:
- Run `sudo systemctl enable wg-quick@gateway` - Run `sudo systemctl enable wg-quick@gateway`
# Phones and Mobile Devices # Phones and Mobile Devices
All your devices can be connected to Mistborn as Wireguard clients. All your devices can be connected to Mistborn as WireGuard clients.
First steps: First steps:
1. Device: Download the Wireguard app on your device. Links: [Android](https://play.google.com/store/apps/details?id=com.wireguard.android) [Apple](https://apps.apple.com/us/app/wireguard/id1441195209) 1. Device: Download the WireGuard app on your device. Links: [Android](https://play.google.com/store/apps/details?id=com.wireguard.android) [Apple](https://apps.apple.com/us/app/wireguard/id1441195209)
1. Mistborn: Create a Wireguard profile for the device. 1. Mistborn: Create a WireGuard profile for the device.
1. Device: Scan Wireguard client QR code in Wireguard app. 1. Device: Scan WireGuard client QR code in WireGuard app.
1. Device: Enable Wireguard connection. 1. Device: Enable WireGuard connection.
All of you device network traffic is now being routed through Wireguard. Ads and malicious sites are blocked by pihole. DNS queries are verified via DNScrypt. All of you device network traffic is now being routed through WireGuard. Ads and malicious sites are blocked by pihole. DNS queries are verified via DNScrypt.
But wait, there's more! You can: But wait, there's more! You can:
- visit the [Mistborn web interface](http://home.mistborn) through your phone's browser. - visit the [Mistborn web interface](http://home.mistborn) through your phone's browser.
@ -332,11 +375,11 @@ But wait, there's more! You can:
| Jitsi Meet | [Jitsi Meet](https://play.google.com/store/apps/details?id=org.jitsi.meet) | [Jitsi Meet](https://apps.apple.com/us/app/jitsi-meet/id1165103905) | | Jitsi Meet | [Jitsi Meet](https://play.google.com/store/apps/details?id=org.jitsi.meet) | [Jitsi Meet](https://apps.apple.com/us/app/jitsi-meet/id1165103905) |
| Bitwarden | [Bitwarden](https://play.google.com/store/apps/details?id=com.x8bit.bitwarden) | [Bitwarden](https://apps.apple.com/us/app/bitwarden-password-manager/id1137397744) | | Bitwarden | [Bitwarden](https://play.google.com/store/apps/details?id=com.x8bit.bitwarden) | [Bitwarden](https://apps.apple.com/us/app/bitwarden-password-manager/id1137397744) |
| Jellyfin | [Jellyfin](https://play.google.com/store/apps/details?id=org.jellyfin.mobile) | [Jellyfin](https://apps.apple.com/us/app/jellyfin-mobile/id1480192618) | | Jellyfin | [Jellyfin](https://play.google.com/store/apps/details?id=org.jellyfin.mobile) | [Jellyfin](https://apps.apple.com/us/app/jellyfin-mobile/id1480192618) |
| Home Assistant | [Home Assistant](https://play.google.com/store/apps/details?id=io.homeassistant.companion.android) | | | Home Assistant | [Home Assistant](https://play.google.com/store/apps/details?id=io.homeassistant.companion.android) | [Home Assistant](https://apps.apple.com/us/app/home-assistant/id1099568401) |
| Rocket.Chat | [Rocket.Chat](https://play.google.com/store/apps/details?id=chat.rocket.android) | [Rocket.Chat](https://apps.apple.com/us/app/rocket-chat/id1148741252) | | Rocket.Chat | [Rocket.Chat](https://play.google.com/store/apps/details?id=chat.rocket.android) | [Rocket.Chat](https://apps.apple.com/us/app/rocket-chat/id1148741252) |
## TLS Certificate ## TLS Certificate
Some apps require TLS (HTTPS). All traffic to Mistborn domains already occurs over Wireguard but to keep apps running, a TLS certificate exists for Mistborn and can be imported into your device's trusted credentials in the security settings. This certificate is checked every day and will be re-generated when expiration is less than 30 days away. Some apps require TLS (HTTPS). All traffic to Mistborn domains already occurs over WireGuard but to keep apps running, a TLS certificate exists for Mistborn and can be imported into your device's trusted credentials in the security settings. This certificate is checked every day and will be re-generated when expiration is less than 30 days away.
The TLS certificate can be found here: The TLS certificate can be found here:
``` ```
@ -346,7 +389,7 @@ The TLS certificate can be found here:
# FAQ # FAQ
Frequently Asked Questions Frequently Asked Questions
## Where is My Data? ## Where is my data?
The Docker services mount volumes located in: The Docker services mount volumes located in:
``` ```
@ -363,11 +406,11 @@ Your data from Nextcloud, Syncthing, Bitwarden, etc. will be located there.
## How do I SSH into Mistborn? ## How do I SSH into Mistborn?
If Mistborn is installed via SSH then an iptables rule is added allowing external SSH connections from the same source IP address only. If Mistborn was installed locally then no external SSH is permitted. If Mistborn is installed via SSH then an iptables rule is added allowing external SSH connections from the same source IP address only. If Mistborn was installed locally then no external SSH is permitted.
SSH is permitted from any device connected to Mistborn by Wireguard. SSH is permitted from any device connected to Mistborn by WireGuard.
Password authentication in enabled. Fail2ban blocks IPs with excessive failed login attempts. Password authentication in enabled. Fail2ban blocks IPs with excessive failed login attempts.
You can SSH using the Mistborn domain when connected by Wireguard: You can SSH using the Mistborn domain when connected by WireGuard:
``` ```
ssh user@home.mistborn ssh user@home.mistborn
``` ```
@ -388,9 +431,38 @@ services:
The available options are here: https://download.dnscrypt.info/dnscrypt-resolvers/v2/public-resolvers.md The available options are here: https://download.dnscrypt.info/dnscrypt-resolvers/v2/public-resolvers.md
## How do I purge an extra service/start fresh?
This is a manual process for the foreseeable future because it is destructive and cannot be undone. In order to purge an extra service do the following:
- Stop and disable the service
This can be done from the Mistborn GUI or:
```
sudo systemctl stop Mistborn-<service name>
sudo systemctl disable Mistborn-<service name>
```
- Remove the data folder
Locate the correct folder: `sudo ls -ahl /opt/mistborn_volumes/extra/`
**Be careful:**
Now remove the folder: `sudo rm -r /opt/mistborn_volumes/extra/<service name>`
- Remove the variables file
Locate the file: `sudo ls -ahl /opt/mistborn/.envs/.production/`
**Be careful:**
Now remove the file: `sudo rm /opt/mistborn/.envs/.production/.<service name>`
Now you can restart the service from the GUI or manually and it should be a first run experience.
# Troubleshooting # Troubleshooting
Once you're connected to Wireguard you should see .mistborn domains and the internet should work as expected. Be sure to use http (http://home.mistborn). Wireguard is the encrypted channel so there's usually no need to bother with TLS certs (WebRTC functionality and some mobile apps require TLS so it is available). Here are some things to check if you have issues: Once you're connected to WireGuard you should see .mistborn domains and the internet should work as expected. Be sure to use http (http://home.mistborn). WireGuard is the encrypted channel so there's usually no need to bother with TLS certs (WebRTC functionality and some mobile apps require TLS so it is available). Here are some things to check if you have issues:
Check if you can ping an external IP address: Check if you can ping an external IP address:
``` ```
@ -422,18 +494,18 @@ Mistborn-base is a systemd process and at any time restarting it should get you
sudo systemctl restart Mistborn-base sudo systemctl restart Mistborn-base
``` ```
The Wireguard processes run independently of Mistborn and will still be up if Mistborn is down. You can check running Wireguard interfaces with: The WireGuard processes run independently of Mistborn and will still be up if Mistborn is down. You can check running WireGuard interfaces with:
``` ```
sudo wg show sudo wg show
``` ```
Note the Mistborn naming convention for Wireguard interfaces on the server is wg<listening port>. So if the particular Wireguard process is listening on UDP port 56392 then the interface will be named wg56392 and the config will be in `/etc/wireguard/wg56392.conf` Note the Mistborn naming convention for WireGuard interfaces on the server is wg<listening port>. So if the particular WireGuard process is listening on UDP port 56392 then the interface will be named wg56392 and the config will be in `/etc/wireguard/wg56392.conf`
The `dev/` folder contains a script for completing a hard reset: destroying and rebuilding the system from the original backup: The `dev/` folder contains a script for completing a hard reset: destroying and rebuilding the system from the original backup:
``` ```
sudo ./dev/rebuild.sh sudo ./dev/rebuild.sh
``` ```
## Troubleshooting Wireguard ## Troubleshooting WireGuard
Ensure that your public IP address in your client profile (e.g. `Endpoint = <Mistborn public IP address>:<random port>`) is actually publicly available (not in 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16) if you are attempting to access Mistborn across the internet. Ensure that your public IP address in your client profile (e.g. `Endpoint = <Mistborn public IP address>:<random port>`) is actually publicly available (not in 10.0.0.0/8, 172.16.0.0/12, or 192.168.0.0/16) if you are attempting to access Mistborn across the internet.
## Troubleshooting Extra Services ## Troubleshooting Extra Services
@ -445,9 +517,12 @@ sudo journalctl -xfu Mistborn-syncthing
sudo journalctl -xfu Mistborn-jellyfin sudo journalctl -xfu Mistborn-jellyfin
sudo journalctl -xfu Mistborn-nextcloud sudo journalctl -xfu Mistborn-nextcloud
sudo journalctl -xfu Mistborn-jitsi sudo journalctl -xfu Mistborn-jitsi
sudo journalctl -xfu Mistborn-guacamole
sudo journalctl -xfu Mistborn-rocketchat sudo journalctl -xfu Mistborn-rocketchat
sudo journalctl -xfu Mistborn-onlyoffice sudo journalctl -xfu Mistborn-onlyoffice
sudo journalctl -xfu Mistborn-tor sudo journalctl -xfu Mistborn-tor
sudo journalctl -xfu Mistborn-raspap
sudo journalctl -xfu Mistborn-wazuh
``` ```
## Troubleshooting Docker ## Troubleshooting Docker
@ -464,13 +539,13 @@ sudo systemctl restart docker
## Troubleshooting Upgrade from Ubuntu 18.04 to 20.04 ## Troubleshooting Upgrade from Ubuntu 18.04 to 20.04
New installations of 18.04 and 20.04 after 25 April 2020 don't seem to be having issues. If you installed Mistborn on Ubuntu 18.04 prior to 25 April 2020 and then upgrade to 20.04 you may have one minor issue described below. New installations of 18.04 and 20.04 after 25 April 2020 don't seem to be having issues. If you installed Mistborn on Ubuntu 18.04 prior to 25 April 2020 and then upgrade to 20.04 you may have one minor issue described below.
Owing to changes in docker NAT rules and container DNS resolution, some Wireguard client configurations generated with Mistborn before 25 April 2020 (be sure to update Mistborn) may experience issues after upgrading to Ubuntu 20.04 LTS. Symptoms: can ping but can't resolve DNS. Owing to changes in docker NAT rules and container DNS resolution, some WireGuard client configurations generated with Mistborn before 25 April 2020 (be sure to update Mistborn) may experience issues after upgrading to Ubuntu 20.04 LTS. Symptoms: can ping but can't resolve DNS.
Solution: Edit the Wireguard client config and set the DNS directive as follows: Solution: Edit the WireGuard client config and set the DNS directive as follows:
``` ```
DNS = 10.2.3.1 DNS = 10.2.3.1
``` ```
Close the config and restart the client Wireguard process. Close the config and restart the client WireGuard process.
## Troubleshooting Raspberry Pi OS (Raspbian) ## Troubleshooting Raspberry Pi OS (Raspbian)
Be sure to always reboot after updating the kernel. When the kernel is updated the kernel modules are deleted (for the currently running kernel) and you will have issues with any function requiring kernel modules (e.g. `iptables` or `wireguard`). Be sure to always reboot after updating the kernel. When the kernel is updated the kernel modules are deleted (for the currently running kernel) and you will have issues with any function requiring kernel modules (e.g. `iptables` or `wireguard`).
@ -478,7 +553,7 @@ Be sure to always reboot after updating the kernel. When the kernel is updated t
**Note**: The Raspberry Pi OS 64-bit BETA (versions from May 2020 and prior) have a bug where the os-release info indicates that it is Debian. Mistborn proceeds to install as though it were Debian. Since it's not Debian there are errors. **Note**: The Raspberry Pi OS 64-bit BETA (versions from May 2020 and prior) have a bug where the os-release info indicates that it is Debian. Mistborn proceeds to install as though it were Debian. Since it's not Debian there are errors.
## Troubleshooting Debian 10 ## Troubleshooting Debian 10
Run updates and restart before installing Mistborn (`sudo apt-get update && sudo apt-get -y dist-upgrade && sudo shutdown -r now`). Some older Linux kernels will prevent newer Wireguard versions from installing. Run updates and restart before installing Mistborn (`sudo apt-get update && sudo apt-get -y dist-upgrade && sudo shutdown -r now`). Some older Linux kernels will prevent newer WireGuard versions from installing.
# Technical and Security Insights # Technical and Security Insights
These are some notes regarding the technical design and implementations of Mistborn. Feel free to contact me for additional details. These are some notes regarding the technical design and implementations of Mistborn. Feel free to contact me for additional details.
@ -487,15 +562,15 @@ These are some notes regarding the technical design and implementations of Mistb
See the [Mistborn Network Security](https://gitlab.com/cyber5k/mistborn/-/wikis/Mistborn-Network-Security) wiki entry. See the [Mistborn Network Security](https://gitlab.com/cyber5k/mistborn/-/wikis/Mistborn-Network-Security) wiki entry.
- **Wireguard**: Wireguard is the only way in to Mistborn. When new Wireguard profiles are generated they are attached to a random UDP port. Wireguard does not respond to unauthenticated traffic. External probes on the active Wireguard listening ports are not logged and do not appear on the Metrics page. - **WireGuard**: WireGuard is the only way in to Mistborn. When new WireGuard profiles are generated they are attached to a random UDP port. WireGuard does not respond to unauthenticated traffic. External probes on the active WireGuard listening ports are not logged and do not appear on the Metrics page.
- **SSH**: If Mistborn is installed over SSH (most common) then an iptables rule is added allowing future SSH connections from the same source IP address. All other external SSH is blocked. Internal SSH (over the Wireguard tunnels) is allowed. Password authentication is allowed. The SSH key for the `mistborn` user is only accepted from internal source IP addresses. Fail2ban is also installed. - **SSH**: If Mistborn is installed over SSH (most common) then an iptables rule is added allowing future SSH connections from the same source IP address. All other external SSH is blocked. Internal SSH (over the WireGuard tunnels) is allowed. Password authentication is allowed. The SSH key for the `mistborn` user is only accepted from internal source IP addresses. Fail2ban is also installed.
- **Traefik**: Iptables closes web ports (TCP 80 and 443) from external access and additonally all web interfaces are behind the Traefik reverse-proxy. All web requests (e.g. home.mistborn) must be resolved by Mistborn DNS (Pihole/dnsmasq) and originate from a Wireguard tunnel. - **Traefik**: Iptables closes web ports (TCP 80 and 443) from external access and additonally all web interfaces are behind the Traefik reverse-proxy. All web requests (e.g. home.mistborn) must be resolved by Mistborn DNS (Pihole/dnsmasq) and originate from a WireGuard tunnel.
- **Docker**: When Docker exposes a port it creates a PREROUTING rule in the NAT table to catch eligible network requests. This means that even if your INPUT chain policy is DROP, your docker containers with exposed ports can receive and respond to traffic. Whenever Mistborn brings up a docker container with an exposed port it creates an iptables rule to block external traffic to that service. - **Docker**: When Docker exposes a port it creates a PREROUTING rule in the NAT table to catch eligible network requests. This means that even if your INPUT chain policy is DROP, your docker containers with exposed ports can receive and respond to traffic. Whenever Mistborn brings up a docker container with an exposed port it creates an iptables rule to block external traffic to that service.
## Firewall ## Firewall
- **IPtables**: Iptables rules and chains are manipulated directly. If UFW is present it is disabled. IPtables-persistent is used to save a simple set of secure default rules (most importantly setting the INPUT and FORWARD policies to DROP and allowing ESTABLISHED and RELATED traffic) that will be effective immediately upon system startup. Additional rules and chains are created by Docker on startup. Mistborn also creates some iptables chains during installation that are saved in the persistent rules. Mistborn iptables chains and rules are designed to work with Docker's with logic that is easy to follow. A power cycle will always result in a working state. - **IPtables**: Iptables rules and chains are manipulated directly. If UFW is present it is disabled. IPtables-persistent is used to save a simple set of secure default rules (most importantly setting the INPUT and FORWARD policies to DROP and allowing ESTABLISHED and RELATED traffic) that will be effective immediately upon system startup. Additional rules and chains are created by Docker on startup. Mistborn also creates some iptables chains during installation that are saved in the persistent rules. Mistborn iptables chains and rules are designed to work with Docker's with logic that is easy to follow. A power cycle will always result in a working state.
- **PostUp/PostDown**: Wireguard configuration files on Mistborn include PostUp and PostDown directives that set routes and iptables rules for each Wireguard client individually. - **PostUp/PostDown**: WireGuard configuration files on Mistborn include PostUp and PostDown directives that set routes and iptables rules for each WireGuard client individually.
- **Wireguard**: There is a one-to-one mapping between each Wireguard client and server instance listening on Mistborn. By default Wireguard clients cannot talk directly to each other but can use shared services and resources on Mistborn (e.g. Syncthing, Nextcloud, Jitisi, etc). Toggling the "client-to-client" option will enable direct client-to-client communication. - **WireGuard**: There is a one-to-one mapping between each WireGuard client and server instance listening on Mistborn. By default WireGuard clients cannot talk directly to each other but can use shared services and resources on Mistborn (e.g. Syncthing, Nextcloud, Jitisi, etc). Toggling the "client-to-client" option will enable direct client-to-client communication.
- **Metrics**: In addition to the iptables INPUT policy set to DROP, an iptables chain exists that logs the packet meta data before dropping it. Mistborn redirects packets that will be dropped to this chain instead. A summary of the data about these dropped packets (unsolicited network traffic) can be found on the Metrics page. - **Metrics**: In addition to the iptables INPUT policy set to DROP, an iptables chain exists that logs the packet meta data before dropping it. Mistborn redirects packets that will be dropped to this chain instead. A summary of the data about these dropped packets (unsolicited network traffic) can be found on the Metrics page.
- **Coppercloud**: Coppercloud works by populating ipsets with the ipset module in iptables to DROP (blacklist) or ACCEPT (whitelist) a given set of IP addresses. Upon system startup a celery task will compile the IP addresses, create the ipsets, and iptables rules. - **Coppercloud**: Coppercloud works by populating ipsets with the ipset module in iptables to DROP (blacklist) or ACCEPT (whitelist) a given set of IP addresses. Upon system startup a celery task will compile the IP addresses, create the ipsets, and iptables rules.
@ -505,6 +580,7 @@ See the [Mistborn Network Security](https://gitlab.com/cyber5k/mistborn/-/wikis/
- The generated TLS certificate has an RSA modulus of 4096 bits, is signed with SHA-256, and is good for 397 days. The certificate is checked daily and will regenerate when expiration is within 30 days. - The generated TLS certificate has an RSA modulus of 4096 bits, is signed with SHA-256, and is good for 397 days. The certificate is checked daily and will regenerate when expiration is within 30 days.
- Outbound UDP on port 53 is blocked. All DNS requests should be handled by the dnscrypt_proxy service and if any client, service, etc. tries to circumvent that it is blocked. - Outbound UDP on port 53 is blocked. All DNS requests should be handled by the dnscrypt_proxy service and if any client, service, etc. tries to circumvent that it is blocked.
- Unattended upgrades are set to automatically install operating system security updates. - Unattended upgrades are set to automatically install operating system security updates.
- Ownership of mistborn files is set to the system mistborn user and access to environment variables is disabled for users other than the owner.
# Roadmap (not necessarily in order) # Roadmap (not necessarily in order)
Many features and refinements are in the works at various stages including: Many features and refinements are in the works at various stages including:
@ -512,14 +588,13 @@ Many features and refinements are in the works at various stages including:
- Plugins for Extra Services (enabling third-party development) - Plugins for Extra Services (enabling third-party development)
- Plugin repository - Plugin repository
- IPv6 support - IPv6 support
- Integration with RaspAP to enable managing an Access Point for local network connections
- Internal network scan tool and feedback
- Anomaly detection in network traffic - Anomaly detection in network traffic
# Featured In # Featured In
- [Linux Magazine](https://www.linux-magazine.com/Issues/2020/240/Mistborn/(language)/eng-US) November 2020 (featuring Mistborn version from early May 2020) - [Linux Magazine](https://www.linux-magazine.com/Issues/2020/240/Mistborn/(language)/eng-US) November 2020 (featuring Mistborn version from early May 2020)
- [Awesome Open Source](https://www.youtube.com/watch?v=hekP0_crotw) July 2020 (featuring Mistborn version from early July 2020) - [Awesome Open Source](https://www.youtube.com/watch?v=hekP0_crotw) July 2020
- [DB Tech](https://www.youtube.com/watch?v=UE_OuAOgoZI) May 2021
# Follow # Follow
You can find recent bugfixes, functional additions, some extra documentation and more at the Cyber5K Patreon page: [https://www.patreon.com/cyber5k](https://www.patreon.com/cyber5k) You can find recent bugfixes, functional additions, some extra documentation and more at the Cyber5K Patreon page: [https://www.patreon.com/cyber5k](https://www.patreon.com/cyber5k)

11
base.yml

@ -158,9 +158,9 @@ services:
pihole: pihole:
container_name: mistborn_production_pihole container_name: mistborn_production_pihole
image: pihole/pihole:v5.5.1 image: pihole/pihole:v5.7
env_file: env_file:
- /opt/mistborn_volumes/base/base.txt - ./.envs/.production/.pihole
ports: ports:
- "${MISTBORN_DNS_BIND_IP}:53:53/tcp" - "${MISTBORN_DNS_BIND_IP}:53:53/tcp"
- "${MISTBORN_DNS_BIND_IP}:53:53/udp" - "${MISTBORN_DNS_BIND_IP}:53:53/udp"
@ -168,11 +168,12 @@ services:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.pihole-http.rule=Host(`pihole.mistborn`)" - "traefik.http.routers.pihole-http.rule=Host(`pihole.mistborn`)"
- "traefik.http.routers.pihole-http.entrypoints=web" - "traefik.http.routers.pihole-http.entrypoints=web"
- "traefik.http.routers.pihole-http.middlewares=mistborn_auth@file" - "traefik.http.routers.pihole-http.middlewares=mistborn_auth@file,add-pihole-admin"
- "traefik.http.routers.pihole-https.rule=Host(`pihole.mistborn`)" - "traefik.http.routers.pihole-https.rule=Host(`pihole.mistborn`)"
- "traefik.http.routers.pihole-https.entrypoints=websecure" - "traefik.http.routers.pihole-https.entrypoints=websecure"
- "traefik.http.routers.pihole-https.middlewares=mistborn_auth@file" - "traefik.http.routers.pihole-https.middlewares=mistborn_auth@file,add-pihole-admin"
- "traefik.http.routers.pihole-https.tls.certresolver=basic" - "traefik.http.routers.pihole-https.tls.certresolver=basic"
- "traefik.http.middlewares.add-pihole-admin.addPrefix.prefix=/admin"
- "traefik.http.services.pihole-service.loadbalancer.server.port=80" - "traefik.http.services.pihole-service.loadbalancer.server.port=80"
environment: environment:
- ServerIP=10.2.0.3 - ServerIP=10.2.0.3
@ -182,8 +183,6 @@ services:
- DNSMASQ_LISTENING=all - DNSMASQ_LISTENING=all
# TZ: 'America/New York' # TZ: 'America/New York'
# Volumes store your data between container upgrades # Volumes store your data between container upgrades
env_file:
- ./.envs/.production/.pihole
volumes: volumes:
- ../mistborn_volumes/base/pihole/etc-pihole:/etc/pihole/ - ../mistborn_volumes/base/pihole/etc-pihole:/etc/pihole/
- ../mistborn_volumes/base/pihole/etc-dnsmasqd:/etc/dnsmasq.d/ - ../mistborn_volumes/base/pihole/etc-dnsmasqd:/etc/dnsmasq.d/

28
extra/bitwarden.yml

@ -0,0 +1,28 @@
version: '3'
services:
bitwarden:
image: bitwardenrs/server:latest
container_name: mistborn_production_bitwarden
env_file:
- ../.envs/.production/.bitwarden
volumes:
- ../../mistborn_volumes/extra/bitwarden:/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.bitwarden-http.rule=Host(`bitwarden.mistborn`)"
- "traefik.http.routers.bitwarden-http.entrypoints=web"
- "traefik.http.routers.bitwarden-http.middlewares=mistborn_auth@file"
- "traefik.http.routers.bitwarden-https.rule=Host(`bitwarden.mistborn`)"
- "traefik.http.routers.bitwarden-https.entrypoints=websecure"
- "traefik.http.routers.bitwarden-https.middlewares=mistborn_auth@file"
- "traefik.http.routers.bitwarden-https.tls.certresolver=basic"
- "traefik.http.services.bitwarden-service.loadbalancer.server.port=80"
ports:
- "${MISTBORN_BIND_IP}:3012:3012/tcp"
restart: unless-stopped
networks:
default:
external:
name: mistborn_default

255
extra/jitsi-meet.yml

@ -0,0 +1,255 @@
version: '3'
services:
# Frontend
jitsi-web:
image: jitsi/web:latest
restart: unless-stopped
#ports:
#- '${HTTP_PORT}:80'
#- '${HTTPS_PORT}:443'
labels:
- "traefik.enable=true"
- "traefik.http.routers.jitsi-http.rule=Host(`jitsi.mistborn`)"
- "traefik.http.routers.jitsi-http.entrypoints=web"
- "traefik.http.routers.jitsi-http.middlewares=mistborn_auth@file"
- "traefik.http.routers.jitsi-https.rule=Host(`jitsi.mistborn`)"
- "traefik.http.routers.jitsi-https.entrypoints=websecure"
- "traefik.http.routers.jitsi-https.middlewares=mistborn_auth@file"
- "traefik.http.routers.jitsi-https.tls.certresolver=basic"
- "traefik.http.services.jitsi-service.loadbalancer.server.port=${HTTP_PORT}"
volumes:
- ${CONFIG}/web:/config:Z
- ${CONFIG}/transcripts:/usr/share/jitsi-meet/transcripts:Z
env_file:
- ../.envs/.production/.jitsi
environment:
- ENABLE_LETSENCRYPT
- ENABLE_HTTP_REDIRECT
- ENABLE_XMPP_WEBSOCKET
- DISABLE_HTTPS
- LETSENCRYPT_DOMAIN
- LETSENCRYPT_EMAIL
- LETSENCRYPT_USE_STAGING
- PUBLIC_URL
- TZ
- AMPLITUDE_ID
- ANALYTICS_SCRIPT_URLS
- ANALYTICS_WHITELISTED_EVENTS
- BRIDGE_CHANNEL
- BRANDING_DATA_URL
- CALLSTATS_CUSTOM_SCRIPT_URL
- CALLSTATS_ID
- CALLSTATS_SECRET
- CHROME_EXTENSION_BANNER_JSON
- CONFCODE_URL
- CONFIG_EXTERNAL_CONNECT
- DEPLOYMENTINFO_ENVIRONMENT
- DEPLOYMENTINFO_ENVIRONMENT_TYPE
- DEPLOYMENTINFO_USERREGION
- DIALIN_NUMBERS_URL
- DIALOUT_AUTH_URL
- DIALOUT_CODES_URL
- DROPBOX_APPKEY
- DROPBOX_REDIRECT_URI
- ENABLE_AUDIO_PROCESSING
- ENABLE_AUTH
- ENABLE_CALENDAR
- ENABLE_FILE_RECORDING_SERVICE
- ENABLE_FILE_RECORDING_SERVICE_SHARING
- ENABLE_GUESTS
- ENABLE_IPV6
- ENABLE_LIPSYNC
- ENABLE_NO_AUDIO_DETECTION
- ENABLE_P2P
- ENABLE_PREJOIN_PAGE
- ENABLE_RECORDING
- ENABLE_REMB
- ENABLE_REQUIRE_DISPLAY_NAME
- ENABLE_SIMULCAST
- ENABLE_STATS_ID
- ENABLE_STEREO
- ENABLE_SUBDOMAINS
- ENABLE_TALK_WHILE_MUTED
- ENABLE_TCC
- ENABLE_TRANSCRIPTIONS
- ETHERPAD_PUBLIC_URL
- ETHERPAD_URL_BASE
- GOOGLE_ANALYTICS_ID
- GOOGLE_API_APP_CLIENT_ID
- INVITE_SERVICE_URL
- JICOFO_AUTH_USER
- MATOMO_ENDPOINT
- MATOMO_SITE_ID
- MICROSOFT_API_APP_CLIENT_ID
- NGINX_RESOLVER
- NGINX_WORKER_PROCESSES
- NGINX_WORKER_CONNECTIONS
- PEOPLE_SEARCH_URL
- RESOLUTION
- RESOLUTION_MIN
- RESOLUTION_WIDTH
- RESOLUTION_WIDTH_MIN
- START_AUDIO_ONLY
- START_AUDIO_MUTED
- START_BITRATE
- START_VIDEO_MUTED
- TESTING_CAP_SCREENSHARE_BITRATE
- TESTING_OCTO_PROBABILITY
- XMPP_AUTH_DOMAIN
- XMPP_BOSH_URL_BASE
- XMPP_DOMAIN
- XMPP_GUEST_DOMAIN
- XMPP_MUC_DOMAIN
- XMPP_RECORDER_DOMAIN
- TOKEN_AUTH_URL
networks:
default:
meet.jitsi:
aliases:
- ${XMPP_DOMAIN}
# XMPP server
jitsi-prosody:
image: jitsi/prosody:latest
restart: unless-stopped
expose:
- '5222'
- '5347'
- '5280'
volumes:
- ${CONFIG}/prosody/config:/config:Z
- ${CONFIG}/prosody/prosody-plugins-custom:/prosody-plugins-custom:Z
env_file:
- ../.envs/.production/.jitsi
environment:
- AUTH_TYPE
- ENABLE_AUTH
- ENABLE_GUESTS
- ENABLE_LOBBY
- ENABLE_XMPP_WEBSOCKET
- GLOBAL_MODULES
- GLOBAL_CONFIG
- LDAP_URL
- LDAP_BASE
- LDAP_BINDDN
- LDAP_BINDPW
- LDAP_FILTER
- LDAP_AUTH_METHOD
- LDAP_VERSION
- LDAP_USE_TLS
- LDAP_TLS_CIPHERS
- LDAP_TLS_CHECK_PEER
- LDAP_TLS_CACERT_FILE
- LDAP_TLS_CACERT_DIR
- LDAP_START_TLS
- XMPP_DOMAIN
- XMPP_AUTH_DOMAIN
- XMPP_GUEST_DOMAIN
- XMPP_MUC_DOMAIN
- XMPP_INTERNAL_MUC_DOMAIN
- XMPP_MODULES
- XMPP_MUC_MODULES
- XMPP_INTERNAL_MUC_MODULES
- XMPP_RECORDER_DOMAIN
- XMPP_CROSS_DOMAIN
- JICOFO_COMPONENT_SECRET
- JICOFO_AUTH_USER
- JICOFO_AUTH_PASSWORD
- JVB_AUTH_USER
- JVB_AUTH_PASSWORD
- JIGASI_XMPP_USER
- JIGASI_XMPP_PASSWORD
- JIBRI_XMPP_USER
- JIBRI_XMPP_PASSWORD
- JIBRI_RECORDER_USER
- JIBRI_RECORDER_PASSWORD
- JWT_APP_ID
- JWT_APP_SECRET
- JWT_ACCEPTED_ISSUERS
- JWT_ACCEPTED_AUDIENCES
- JWT_ASAP_KEYSERVER
- JWT_ALLOW_EMPTY
- JWT_AUTH_TYPE
- JWT_TOKEN_AUTH_MODULE
- LOG_LEVEL
- PUBLIC_URL
- TZ
networks:
meet.jitsi:
aliases:
- ${XMPP_SERVER}
# Focus component
jitsi-jicofo:
image: jitsi/jicofo:latest
restart: unless-stopped
volumes:
- ${CONFIG}/jicofo:/config:Z
env_file:
- ../.envs/.production/.jitsi
environment:
- AUTH_TYPE
- ENABLE_AUTH
- XMPP_DOMAIN
- XMPP_AUTH_DOMAIN
- XMPP_INTERNAL_MUC_DOMAIN
- XMPP_MUC_DOMAIN
- XMPP_SERVER
- JICOFO_COMPONENT_SECRET
- JICOFO_AUTH_USER
- JICOFO_AUTH_PASSWORD
- JICOFO_RESERVATION_REST_BASE_URL
- JVB_BREWERY_MUC
- JIGASI_BREWERY_MUC
- JIGASI_SIP_URI
- JIBRI_BREWERY_MUC
- JIBRI_PENDING_TIMEOUT
- TZ
depends_on:
- jitsi-prosody
networks:
meet.jitsi:
# Video bridge
jitsi-jvb:
image: jitsi/jvb:latest
restart: unless-stopped
ports:
- "${MISTBORN_BIND_IP}:${JVB_PORT}:${JVB_PORT}/udp"
- "${MISTBORN_BIND_IP}:${JVB_TCP_PORT}:${JVB_TCP_PORT}"
volumes:
- ${CONFIG}/jvb:/config:Z
env_file:
- ../.envs/.production/.jitsi
environment:
- DOCKER_HOST_ADDRESS
- XMPP_AUTH_DOMAIN
- XMPP_INTERNAL_MUC_DOMAIN
- XMPP_SERVER
- JVB_AUTH_USER
- JVB_AUTH_PASSWORD
- JVB_BREWERY_MUC
- JVB_PORT
- JVB_TCP_HARVESTER_DISABLED
- JVB_TCP_PORT
- JVB_TCP_MAPPED_PORT
- JVB_STUN_SERVERS
- JVB_ENABLE_APIS
- JVB_WS_DOMAIN
- JVB_WS_SERVER_ID
- PUBLIC_URL
- TZ
depends_on:
- jitsi-prosody
networks:
meet.jitsi:
aliases:
- jvb.meet.jitsi
# Custom network so all services can communicate using a FQDN
networks:
default:
external:
name: mistborn_default
meet.jitsi:

33
extra/raspap.yml

@ -0,0 +1,33 @@
version: '3'
services:
raspap:
image: "cyber5k/raspap:${MISTBORN_TAG}"
container_name: mistborn_production_raspap
#network_mode: host
labels:
- "traefik.enable=true"
- "traefik.http.routers.raspap-http.rule=Host(`raspap.mistborn`)"
- "traefik.http.routers.raspap-http.entrypoints=web"
- "traefik.http.routers.raspap-http.middlewares=mistborn_auth@file"
- "traefik.http.routers.raspap-https.rule=Host(`raspap.mistborn`)"
- "traefik.http.routers.raspap-https.entrypoints=websecure"
- "traefik.http.routers.raspap-https.middlewares=mistborn_auth@file"
- "traefik.http.routers.raspap-https.tls.certresolver=basic"
- "traefik.http.services.raspap-service.loadbalancer.server.port=80"
env_file:
- ../.envs/.production/.raspap
cap_add:
#- NET_ADMIN
- SYS_ADMIN
#- CAP_FOWNER
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
#command: /start
restart: unless-stopped
networks:
default:
external:
name: mistborn_default

35
extra/syncthing.yml

@ -0,0 +1,35 @@
version: '3'
services:
syncthing:
image: linuxserver/syncthing
container_name: mistborn_production_syncthing
environment:
- PUID=1000
- PGID=1000
- TZ=Amereica/New_York
- UMASK_SET=022
volumes:
- ../../mistborn_volumes/extra/syncthing/config:/config
- ../../mistborn_volumes/extra/syncthing/data1:/data1
- ../../mistborn_volumes/extra/syncthing/data2:/data2
ports:
#- 8384:8384
- "${MISTBORN_BIND_IP}:22000:22000/tcp" # listening port
- "${MISTBORN_BIND_IP}:21027:21027/udp" # protocol discovery
labels:
- "traefik.enable=true"
- "traefik.http.routers.syncthing-http.rule=Host(`syncthing.mistborn`)"
- "traefik.http.routers.syncthing-http.entrypoints=web"
- "traefik.http.routers.syncthing-http.middlewares=mistborn_auth@file"
- "traefik.http.routers.syncthing-https.rule=Host(`syncthing.mistborn`)"
- "traefik.http.routers.syncthing-https.entrypoints=websecure"
- "traefik.http.routers.syncthing-https.middlewares=mistborn_auth@file"
- "traefik.http.routers.syncthing-https.tls.certresolver=basic"
- "traefik.http.services.syncthing-service.loadbalancer.server.port=8384"
restart: unless-stopped
networks:
default:
external:
name: mistborn_default

16
extra/tor.yml

@ -0,0 +1,16 @@
version: '3'
services:
tor-client:
build:
context: ../compose/production/tor
dockerfile: ./Dockerfile
image: mistborn_production_tor
container_name: mistborn_production_tor
ports:
- "${MISTBORN_BIND_IP}:9150:9150/tcp"
networks:
default:
external:
name: mistborn_default

3
scripts/conf/docker-daemon.json

@ -0,0 +1,3 @@
{
"shutdown-timeout": 60
}

35
scripts/env/check_env_file.sh vendored

@ -0,0 +1,35 @@
#!/bin/bash
set -e
SERVICE="$1"
export MISTBORN_HOME=/opt/mistborn
export SERVICE_ENV_INSTALLER="${MISTBORN_HOME}/scripts/subinstallers/extra/${SERVICE}.sh"
export SERVICE_ENV_FILE="${MISTBORN_HOME}/.envs/.production/.${SERVICE}"
# read in global variables
set -a
source ${MISTBORN_HOME}/.env
source ${MISTBORN_HOME}/.envs/.production/.django
source ${MISTBORN_HOME}/.envs/.production/.postgres
source ${MISTBORN_HOME}/.envs/.production/.pihole
set +a
if [[ -f "${SERVICE_ENV_INSTALLER}" ]]; then
if [[ -f "${SERVICE_ENV_FILE}" ]]; then
echo "Environment file already exists."
else
# create env file for service
echo "Creating environment file"
source $SERVICE_ENV_INSTALLER $SERVICE_ENV_FILE
chown mistborn:mistborn $SERVICE_ENV_FILE
chmod 600 $SERVICE_ENV_FILE
fi
else
echo "No subinstaller found."
fi

3
scripts/env/setup.sh vendored

@ -16,6 +16,7 @@ source /opt/mistborn/scripts/subinstallers/platform.sh
# setup env file # setup env file
echo "" | sudo tee ${VAR_FILE} echo "" | sudo tee ${VAR_FILE}
sudo chown mistborn:mistborn ${VAR_FILE} sudo chown mistborn:mistborn ${VAR_FILE}
sudo chmod 600 ${VAR_FILE}
# Version env variables # Version env variables
echo "MISTBORN_VERSION=${MISTBORN_MAJOR_VERSION}.${MISTBORN_MINOR_VERSION}.${MISTBORN_PATCH_NUMBER}" | sudo tee -a ${VAR_FILE} echo "MISTBORN_VERSION=${MISTBORN_MAJOR_VERSION}.${MISTBORN_MINOR_VERSION}.${MISTBORN_PATCH_NUMBER}" | sudo tee -a ${VAR_FILE}
@ -77,4 +78,6 @@ echo "MISTBORN_VOL_PATH=../../../mistborn_volumes/extra/" >> $GLOBAL_ENV
# default interface # default interface
#sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/DIFACE/$iface/" #sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/DIFACE/$iface/"
echo "DIFACE=${iface}" | sudo tee -a ${VAR_FILE}
sudo systemctl daemon-reload sudo systemctl daemon-reload

37
scripts/install.sh

@ -59,13 +59,22 @@ echo -e "| | | | \__ \ |_| |_) | (_) | | | | | |"
echo -e "|_| |_|_|___/\__|_.__/ \___/|_| |_| |_|" echo -e "|_| |_|_|___/\__|_.__/ \___/|_| |_| |_|"
echo -e "" echo -e ""
# INPUT default admin password sudo rm -rf /opt/mistborn 2>/dev/null || true
if [ -z "${MISTBORN_DEFAULT_PASSWORD}" ]; then
read -p "(Mistborn) Set default admin password: " -s MISTBORN_DEFAULT_PASSWORD # clone to /opt and change directory
echo echo "Cloning $GIT_BRANCH branch from mistborn repo"
else sudo git clone https://gitlab.com/cyber5k/mistborn.git -b $GIT_BRANCH /opt/mistborn
echo "MISTBORN_DEFAULT_PASSWORD is already set" sudo chown -R $USER:$USER /opt/mistborn
fi pushd .
cd /opt/mistborn
git submodule update --init --recursive
# Check updates
echo "Checking updates"
source ./scripts/subinstallers/check_updates.sh
# MISTBORN_DEFAULT_PASSWORD
source ./scripts/subinstallers/passwd.sh
# SSH keys # SSH keys
if [ ! -f ~/.ssh/id_rsa ]; then if [ ! -f ~/.ssh/id_rsa ]; then
@ -78,18 +87,7 @@ else
echo "SSH key exists for $USER" echo "SSH key exists for $USER"
fi fi
sudo rm -rf /opt/mistborn 2>/dev/null || true # initial load update package list during check_updates.sh
# clone to /opt and change directory
echo "Cloning $GIT_BRANCH branch from mistborn repo"
sudo git clone https://gitlab.com/cyber5k/mistborn.git -b $GIT_BRANCH /opt/mistborn
sudo chown -R $USER:$USER /opt/mistborn
pushd .
cd /opt/mistborn
git submodule update --init --recursive
# initial load update package list
sudo apt-get update
# install figlet # install figlet
sudo -E apt-get install -y figlet sudo -E apt-get install -y figlet
@ -228,6 +226,7 @@ sudo resolvconf -u 1>/dev/null 2>&1
echo "backup up original volumes folder" echo "backup up original volumes folder"
sudo mkdir -p ../mistborn_backup sudo mkdir -p ../mistborn_backup
sudo chmod 700 ../mistborn_backup
sudo tar -czf ../mistborn_backup/mistborn_volumes_backup.tar.gz ../mistborn_volumes 1>/dev/null 2>&1 sudo tar -czf ../mistborn_backup/mistborn_volumes_backup.tar.gz ../mistborn_volumes 1>/dev/null 2>&1
# clean docker # clean docker

9
scripts/services/Mistborn-base.service

@ -9,10 +9,17 @@ After=netfilter-persistent.service
EnvironmentFile=/opt/mistborn/.envs/.production/.global EnvironmentFile=/opt/mistborn/.envs/.production/.global
EnvironmentFile=/opt/mistborn/.env EnvironmentFile=/opt/mistborn/.env
Restart=always Restart=always
User=mistborn RestartSec=15
User=root
Group=docker Group=docker
PermissionsStartOnly=true PermissionsStartOnly=true
# Shutdown container (if running) when unit is stopped # Shutdown container (if running) when unit is stopped
EnvironmentFile=/opt/mistborn/.env
# stop all containers joined to mistborn_default network
ExecStartPre=-/usr/bin/bash -c "docker container stop $(docker network inspect mistborn_default | grep Name | tail -n +2 | cut -d':' -f2 | tr -d ',\"') 2>/dev/null"
# bring down the base service
ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/base.yml down ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/base.yml down
ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/base.yml build ExecStartPre=/usr/local/bin/docker-compose -f /opt/mistborn/base.yml build

10
scripts/subinstallers/check_updates.sh

@ -0,0 +1,10 @@
#!/bin/bash
sudo apt-get update
UPDATES=$(sudo apt-get dist-upgrade -s --quiet=2 | grep ^Inst | wc -l)
if [[ "$UPDATES" -ne "0" ]]; then
echo "Please run updates and reboot before installing Mistborn: sudo apt-get update && sudo apt-get -y dist-upgrade"
exit 1;
fi

16
scripts/subinstallers/docker.sh

@ -6,7 +6,18 @@ figlet "Mistborn: Installing Docker"
sudo apt update sudo apt update
sudo -E apt install -y python python3-pip python3-setuptools libffi-dev python3-dev libssl-dev sudo -E apt install -y python python3-pip python3-setuptools libffi-dev python3-dev libssl-dev
if [ "$DISTRO" == "ubuntu" ] && [ "$VERSION_ID" == "20.04" ]; then # Ubuntu version >= 20.04
set +e
vercomp "$VERSION_ID" "19.10"
case $? in
0) op='=';;
1) op='>';;
2) op='<';;
esac
set -e
if [ "$DISTRO" == "ubuntu" ] && [ "$op" == ">" ]; then
echo "Automated Docker install" echo "Automated Docker install"
sudo -E apt-get install -y docker-compose sudo -E apt-get install -y docker-compose
else else
@ -18,3 +29,6 @@ fi
if [ ! -f /usr/local/bin/docker-compose ]; then if [ ! -f /usr/local/bin/docker-compose ]; then
sudo -E ln -s $(which docker-compose) /usr/local/bin/docker-compose sudo -E ln -s $(which docker-compose) /usr/local/bin/docker-compose
fi fi
# daemon.json
#source ./scripts/subinstallers/docker_daemon.sh

7
scripts/subinstallers/docker_daemon.sh

@ -0,0 +1,7 @@
#!/bin/bash
# daemon.json
if [ ! -f /etc/docker/daemon.json ]; then
sudo -E cp ./scripts/conf/docker-daemon.json /etc/docker/daemon.json
sudo -E systemctl restart docker
fi

5
scripts/subinstallers/docker_manual.sh

@ -67,3 +67,8 @@ echo "Installing Docker Compose"
sudo pip3 install cryptography==3.3.2 docker-compose sudo pip3 install cryptography==3.3.2 docker-compose
#fi #fi
# check raspbian fixes
if [ "$DISTRO" == "raspbian" ] || [ "$DISTRO" == "raspios" ]; then
source ./scripts/subinstallers/docker_raspbian.sh
fi

46
scripts/subinstallers/docker_raspbian.sh

@ -0,0 +1,46 @@
#!/bin/bash
set +e
compare_version() {
local versionOne="${1}"
local comparision="${2}"
local versionTwo="${3}"
local result=
local sortOpt=
local returncode=1
if [[ "${versionOne}" == "${versionTwo}" ]] ; then
return 3
fi
case ${comparision} in
lower|smaller|older|lt|"<" ) sortOpt= ;;
higher|bigger|newer|bt|">" ) sortOpt='r' ;;
* ) return 2 ;;
esac
result=($(printf "%s\n" "${versionOne}" "${versionTwo}" | sort -${sortOpt}V ))
if [[ "${versionOne}" == "${result[0]}" ]] ; then
returncode=0
fi
return ${returncode}
} # end of function compare_version
# libseccomp2
LIBSECCOMP2_VERSION=$(sudo -E apt-cache policy libseccomp2 | egrep ^\ *Inst | awk '{print $2}')
compare_version $LIBSECCOMP2_VERSION '<' '2.5.1-1'
if [ $? -eq 0 ]; then
# this is dumb but the raspbian repo managers aren't impressive
echo "Installing newer libseccomp2"
pushd .
cd /tmp
wget http://ftp.us.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_$(dpkg --print-architecture).deb
sudo dpkg -i libseccomp2_2.5.1-1_$(dpkg --print-architecture).deb
popd
fi
set -e

4
scripts/subinstallers/gen_prod_env.sh

@ -4,6 +4,7 @@ figlet "Mistborn: Container Credentials"
# generate production .env file for Django # generate production .env file for Django
mkdir -p ./.envs/.production mkdir -p ./.envs/.production
chmod 700 ./.envs
DJANGO_PROD_FILE="./.envs/.production/.django" DJANGO_PROD_FILE="./.envs/.production/.django"
DJANGO_SECRET_KEY=$(python3 -c "import secrets; import string; print(f''.join([secrets.choice(string.ascii_letters+string.digits) for x in range(50)]))") DJANGO_SECRET_KEY=$(python3 -c "import secrets; import string; print(f''.join([secrets.choice(string.ascii_letters+string.digits) for x in range(50)]))")
#CELERY_FLOWER_PASSWORD=$(python3 -c "import secrets; import string; print(f''.join([secrets.choice(string.ascii_letters+string.digits) for x in range(32)]))") #CELERY_FLOWER_PASSWORD=$(python3 -c "import secrets; import string; print(f''.join([secrets.choice(string.ascii_letters+string.digits) for x in range(32)]))")
@ -22,6 +23,7 @@ echo "#SENTRY_DNS=" >> $DJANGO_PROD_FILE
echo "MISTBORN_INSTALL_COCKPIT=$MISTBORN_INSTALL_COCKPIT" >> $DJANGO_PROD_FILE echo "MISTBORN_INSTALL_COCKPIT=$MISTBORN_INSTALL_COCKPIT" >> $DJANGO_PROD_FILE
echo "MISTBORN_PORTAL_IP=10.2.3.1" >> $DJANGO_PROD_FILE echo "MISTBORN_PORTAL_IP=10.2.3.1" >> $DJANGO_PROD_FILE
echo "MISTBORN_PORTAL_PORT=5000" >> $DJANGO_PROD_FILE echo "MISTBORN_PORTAL_PORT=5000" >> $DJANGO_PROD_FILE
chmod 600 $DJANGO_PROD_FILE
# generate production .env file for postgresql # generate production .env file for postgresql
POSTGRES_PROD_FILE="./.envs/.production/.postgres" POSTGRES_PROD_FILE="./.envs/.production/.postgres"
@ -31,6 +33,7 @@ echo "POSTGRES_PORT=5432" >> $POSTGRES_PROD_FILE
echo "POSTGRES_DB=mistborn" >> $POSTGRES_PROD_FILE echo "POSTGRES_DB=mistborn" >> $POSTGRES_PROD_FILE
echo "POSTGRES_USER=prod" >> $POSTGRES_PROD_FILE echo "POSTGRES_USER=prod" >> $POSTGRES_PROD_FILE
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $POSTGRES_PROD_FILE echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $POSTGRES_PROD_FILE
chmod 600 $POSTGRES_PROD_FILE
# generate production .env file for pihole # generate production .env file for pihole
@ -40,3 +43,4 @@ WEBPASSWORD="$1"
echo "TZ=\"America/New York\"" > $PIHOLE_PROD_FILE echo "TZ=\"America/New York\"" > $PIHOLE_PROD_FILE
echo "WEBPASSWORD=$WEBPASSWORD" >> $PIHOLE_PROD_FILE echo "WEBPASSWORD=$WEBPASSWORD" >> $PIHOLE_PROD_FILE
chmod 600 $PIHOLE_PROD_FILE

2
scripts/subinstallers/iptables.sh

@ -6,7 +6,7 @@ figlet "Mistborn: Configuring Firewall"
echo "stop iptables wrappers" echo "stop iptables wrappers"
if [ "$DISTRO" == "ubuntu" ]; then if [ "$DISTRO" == "ubuntu" ]; then
# Disable UFW echo "Disabling UFW"
sudo systemctl stop ufw || true sudo systemctl stop ufw || true
sudo systemctl disable ufw || true sudo systemctl disable ufw || true
fi fi

22
scripts/subinstallers/passwd.sh

@ -0,0 +1,22 @@
#!/bin/bash
# INPUT default admin password
while [ -z "${MISTBORN_DEFAULT_PASSWORD}" ]; do
echo
echo "(Mistborn) The default admin password may only container alphanumeric characters and _"
read -p "(Mistborn) Set default admin password: " -s MISTBORN_DEFAULT_PASSWORD
echo
if [[ ${MISTBORN_DEFAULT_PASSWORD} =~ ^[A-Za-z0-9_]+$ ]]; then
# it matches
echo "(Mistborn) Password is accepted"
else
unset MISTBORN_DEFAULT_PASSWORD
echo "(Mistborn) Try again"
fi
done
echo
echo "MISTBORN_DEFAULT_PASSWORD is set"
echo

36
scripts/subinstallers/platform.sh

@ -15,3 +15,39 @@ fi
figlet "UNAME: $UNAME" figlet "UNAME: $UNAME"
figlet "DISTRO: $DISTRO" figlet "DISTRO: $DISTRO"
figlet "VERSION: $VERSION_ID" figlet "VERSION: $VERSION_ID"
vercomp () {
# case $? in
# 0) op='=';;
# 1) op='>';;
# 2) op='<';;
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}

7
scripts/update.sh

@ -18,6 +18,13 @@ sudo mistborn-cli pullbuild
sudo docker container prune -f sudo docker container prune -f
sudo docker image prune -f sudo docker image prune -f
# RESTART
sudo systemctl stop Mistborn-base sudo systemctl stop Mistborn-base
# docker daemon
#source ./scripts/subinstallers/docker_daemon.sh
sudo systemctl restart Mistborn-setup sudo systemctl restart Mistborn-setup
sudo systemctl restart Mistborn-base sudo systemctl restart Mistborn-base

57
scripts/wrappers/mistborn_docker.sh

@ -0,0 +1,57 @@
#!/bin/bash
set -e
MISTBORN_HOME="/opt/mistborn"
SERVICES="$1"
shift
IFS=','
read -ra SERVICES_ARRAY <<< "${SERVICES}"
for SERVICE in "${SERVICES_ARRAY[@]}"; do
MISTBORN_SERVICE_FILE=${MISTBORN_HOME}/.envs/.production/.${SERVICE}
MISTBORN_SERVICE_INIT=${MISTBORN_HOME}/scripts/services/${SERVICE}/init.sh
# check and create file if needed
${MISTBORN_HOME}/scripts/env/check_env_file.sh ${SERVICE}
# read in variables
set -a
source ${MISTBORN_HOME}/.env
if [[ -f "${MISTBORN_SERVICE_FILE}" ]]; then
echo "Loading service variables"
source ${MISTBORN_SERVICE_FILE}
else
echo "No service variables to load. Proceeding."
fi
set +a
# init script
if [[ -f "${MISTBORN_SERVICE_INIT}" ]]; then
echo "Running init script"
${MISTBORN_SERVICE_INIT}
else
echo "No init script. Proceeding."
fi
done
# check that netcat exists
if ! [ -x "$(command -v nc)" ]; then
echo "Installing netcat"
sudo apt-get install -y netcat
fi
# ensure base is up and listening
echo "Checking that Mistborn-base has finished starting up..."
while ! nc -z 10.2.3.1 5000; do
WAIT_TIME=$((5 + $RANDOM % 15))
echo "Waiting ${WAIT_TIME} seconds for Mistborn-base..."
sleep ${WAIT_TIME}
done
echo "Mistborn-base is running"
exec "$@"
Loading…
Cancel
Save