merge master
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"shutdown-timeout": 60
|
||||
}
|
||||
+35
@@ -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
|
||||
Vendored
+3
@@ -16,6 +16,7 @@ source /opt/mistborn/scripts/subinstallers/platform.sh
|
||||
# setup env file
|
||||
echo "" | sudo tee ${VAR_FILE}
|
||||
sudo chown mistborn:mistborn ${VAR_FILE}
|
||||
sudo chmod 600 ${VAR_FILE}
|
||||
|
||||
# Version env variables
|
||||
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
|
||||
#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
|
||||
|
||||
+18
-19
@@ -59,13 +59,22 @@ echo -e "| | | | \__ \ |_| |_) | (_) | | | | | |"
|
||||
echo -e "|_| |_|_|___/\__|_.__/ \___/|_| |_| |_|"
|
||||
echo -e ""
|
||||
|
||||
# INPUT default admin password
|
||||
if [ -z "${MISTBORN_DEFAULT_PASSWORD}" ]; then
|
||||
read -p "(Mistborn) Set default admin password: " -s MISTBORN_DEFAULT_PASSWORD
|
||||
echo
|
||||
else
|
||||
echo "MISTBORN_DEFAULT_PASSWORD is already set"
|
||||
fi
|
||||
sudo rm -rf /opt/mistborn 2>/dev/null || true
|
||||
|
||||
# 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
|
||||
|
||||
# Check updates
|
||||
echo "Checking updates"
|
||||
source ./scripts/subinstallers/check_updates.sh
|
||||
|
||||
# MISTBORN_DEFAULT_PASSWORD
|
||||
source ./scripts/subinstallers/passwd.sh
|
||||
|
||||
# SSH keys
|
||||
if [ ! -f ~/.ssh/id_rsa ]; then
|
||||
@@ -78,18 +87,7 @@ else
|
||||
echo "SSH key exists for $USER"
|
||||
fi
|
||||
|
||||
sudo rm -rf /opt/mistborn 2>/dev/null || true
|
||||
|
||||
# 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
|
||||
# initial load update package list during check_updates.sh
|
||||
|
||||
# install 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"
|
||||
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
|
||||
|
||||
# clean docker
|
||||
|
||||
@@ -9,10 +9,17 @@ After=netfilter-persistent.service
|
||||
EnvironmentFile=/opt/mistborn/.envs/.production/.global
|
||||
EnvironmentFile=/opt/mistborn/.env
|
||||
Restart=always
|
||||
User=mistborn
|
||||
RestartSec=15
|
||||
User=root
|
||||
Group=docker
|
||||
PermissionsStartOnly=true
|
||||
# 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 build
|
||||
|
||||
Executable
+10
@@ -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
|
||||
@@ -6,7 +6,18 @@ figlet "Mistborn: Installing Docker"
|
||||
sudo apt update
|
||||
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"
|
||||
sudo -E apt-get install -y docker-compose
|
||||
else
|
||||
@@ -18,3 +29,6 @@ fi
|
||||
if [ ! -f /usr/local/bin/docker-compose ]; then
|
||||
sudo -E ln -s $(which docker-compose) /usr/local/bin/docker-compose
|
||||
fi
|
||||
|
||||
# daemon.json
|
||||
#source ./scripts/subinstallers/docker_daemon.sh
|
||||
|
||||
Executable
+7
@@ -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
|
||||
@@ -67,3 +67,8 @@ echo "Installing Docker Compose"
|
||||
sudo pip3 install cryptography==3.3.2 docker-compose
|
||||
#fi
|
||||
|
||||
|
||||
# check raspbian fixes
|
||||
if [ "$DISTRO" == "raspbian" ] || [ "$DISTRO" == "raspios" ]; then
|
||||
source ./scripts/subinstallers/docker_raspbian.sh
|
||||
fi
|
||||
|
||||
Executable
+46
@@ -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,6 +4,7 @@ figlet "Mistborn: Container Credentials"
|
||||
|
||||
# generate production .env file for Django
|
||||
mkdir -p ./.envs/.production
|
||||
chmod 700 ./.envs
|
||||
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)]))")
|
||||
#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_PORTAL_IP=10.2.3.1" >> $DJANGO_PROD_FILE
|
||||
echo "MISTBORN_PORTAL_PORT=5000" >> $DJANGO_PROD_FILE
|
||||
chmod 600 $DJANGO_PROD_FILE
|
||||
|
||||
# generate production .env file for postgresql
|
||||
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_USER=prod" >> $POSTGRES_PROD_FILE
|
||||
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> $POSTGRES_PROD_FILE
|
||||
chmod 600 $POSTGRES_PROD_FILE
|
||||
|
||||
|
||||
# generate production .env file for pihole
|
||||
@@ -40,3 +43,4 @@ WEBPASSWORD="$1"
|
||||
echo "TZ=\"America/New York\"" > $PIHOLE_PROD_FILE
|
||||
echo "WEBPASSWORD=$WEBPASSWORD" >> $PIHOLE_PROD_FILE
|
||||
|
||||
chmod 600 $PIHOLE_PROD_FILE
|
||||
|
||||
@@ -6,7 +6,7 @@ figlet "Mistborn: Configuring Firewall"
|
||||
|
||||
echo "stop iptables wrappers"
|
||||
if [ "$DISTRO" == "ubuntu" ]; then
|
||||
# Disable UFW
|
||||
echo "Disabling UFW"
|
||||
sudo systemctl stop ufw || true
|
||||
sudo systemctl disable ufw || true
|
||||
fi
|
||||
|
||||
Executable
+22
@@ -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
|
||||
@@ -15,3 +15,39 @@ fi
|
||||
figlet "UNAME: $UNAME"
|
||||
figlet "DISTRO: $DISTRO"
|
||||
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
|
||||
}
|
||||
@@ -18,6 +18,13 @@ sudo mistborn-cli pullbuild
|
||||
sudo docker container prune -f
|
||||
sudo docker image prune -f
|
||||
|
||||
|
||||
# RESTART
|
||||
|
||||
sudo systemctl stop Mistborn-base
|
||||
|
||||
# docker daemon
|
||||
#source ./scripts/subinstallers/docker_daemon.sh
|
||||
|
||||
sudo systemctl restart Mistborn-setup
|
||||
sudo systemctl restart Mistborn-base
|
||||
|
||||
Executable
+57
@@ -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 "$@"
|
||||
Reference in New Issue
Block a user