From e2877c1cb11ffc34958a92f02bd57375b45417a9 Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 13:31:17 -0400 Subject: [PATCH] setup env --- scripts/env/setup.sh | 13 +++++++++++++ scripts/install.sh | 17 ++++------------- scripts/services/Mistborn-setup.service | 1 + scripts/update.sh | 7 ------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/scripts/env/setup.sh b/scripts/env/setup.sh index 8234cd1..afe352e 100755 --- a/scripts/env/setup.sh +++ b/scripts/env/setup.sh @@ -1,5 +1,7 @@ #!/bin/bash +#### ENV file + VAR_FILE=/opt/mistborn/.env source /opt/mistborn/scripts/subinstallers/platform.sh @@ -19,3 +21,14 @@ if [ "$GIT_BRANCH" != "master" ]; then fi echo "MISTBORN_TAG=$MISTBORN_TAG" | sudo tee -a ${VAR_FILE} + +#### install and base services +iface=$(ip -o -4 route show to default | egrep -o 'dev [^ ]*' | awk 'NR==1{print $2}') + +# default interface +sudo cp ./scripts/services/Mistborn* /etc/systemd/system/ +sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/User=root/User=$USER/" +#sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/ root:root / $USER:$USER /" +sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/DIFACE/$iface/" + +sudo systemctl daemon-reload \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh index e777b79..b931f27 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -117,10 +117,10 @@ fi # SSH Server sudo -E apt-get install -y openssh-server -sudo sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config -sudo sed -i 's/PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config -sudo sed -i 's/#PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config -sudo sed -i 's/PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config +#sudo sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config +#sudo sed -i 's/PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config +#sudo sed -i 's/#PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config +#sudo sed -i 's/PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config sudo sed -i 's/#Port.*/Port 22/' /etc/ssh/sshd_config sudo sed -i 's/Port.*/Port 22/' /etc/ssh/sshd_config sudo systemctl enable ssh @@ -166,8 +166,6 @@ sudo pip3 install -e ./modules/mistborn-cli # Mistborn # final setup vars -iface=$(ip -o -4 route show to default | egrep -o 'dev [^ ]*' | awk 'NR==1{print $2}') -figlet "Mistborn default NIC: $iface" #IPV4_PUBLIC=$(ip -o -4 route show default | egrep -o 'dev [^ ]*' | awk '{print $2}' | xargs ip -4 addr show | grep 'inet ' | awk '{print $2}' | grep -o "^[0-9.]*" | tr -cd '\11\12\15\40-\176' | head -1) # tail -1 to get last IPV4_PUBLIC="10.2.3.1" @@ -188,13 +186,6 @@ sudo systemctl restart unattended-upgrades # setup Mistborn services -# install and start base services -# default interface -sudo cp ./scripts/services/Mistborn* /etc/systemd/system/ -sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/User=root/User=$USER/" -#sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/ root:root / $USER:$USER /" -sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/DIFACE/$iface/" - #if [ "$DISTRO" == "debian" ] || [ "$DISTRO" == "raspbian" ]; then # # remove systemd-resolved lines # sudo sed -i '/.*systemd-resolved/d' /etc/systemd/system/Mistborn-base.service diff --git a/scripts/services/Mistborn-setup.service b/scripts/services/Mistborn-setup.service index 9b83c71..706942e 100644 --- a/scripts/services/Mistborn-setup.service +++ b/scripts/services/Mistborn-setup.service @@ -4,6 +4,7 @@ Before=Mistborn-base.service [Service] Type=oneshot +User=mistborn ExecStart=/opt/mistborn/scripts/env/setup.sh [Install] diff --git a/scripts/update.sh b/scripts/update.sh index ce5a4e2..0e03642 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -10,16 +10,9 @@ sudo git -C /opt/mistborn submodule update --init --recursive # ensure mistborn-cli is installed sudo pip3 install -e /opt/mistborn/modules/mistborn-cli -# handle updates to Mistborn systemd scripts -iface=$(ip -o -4 route show to default | egrep -o 'dev [^ ]*' | awk 'NR==1{print $2}') -sudo cp /opt/mistborn/scripts/services/Mistborn* /etc/systemd/system/ -sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/User=root/User=mistborn/" -sudo find /etc/systemd/system/ -type f -name 'Mistborn*' | xargs sudo sed -i "s/DIFACE/$iface/" - # handle updates to traefik #sudo cp /opt/mistborn/compose/production/traefik/traefik.toml.template /opt/mistborn/compose/production/traefik/traefik.toml -sudo systemctl daemon-reload sudo systemctl enable Mistborn-setup.service sudo systemctl restart Mistborn-setup.service