From e2877c1cb11ffc34958a92f02bd57375b45417a9 Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 13:31:17 -0400 Subject: [PATCH 1/7] 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 From c690824b877f481c650b261644eb3df7955207ce Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 13:39:39 -0400 Subject: [PATCH 2/7] setup service --- scripts/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install.sh b/scripts/install.sh index b931f27..c87bc2f 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -191,6 +191,8 @@ sudo systemctl restart unattended-upgrades # sudo sed -i '/.*systemd-resolved/d' /etc/systemd/system/Mistborn-base.service #fi +sudo cp ./scripts/services/Mistborn-setup.service /etc/systemd/system/ + # setup local volumes for pihole sudo mkdir -p ../mistborn_volumes/ sudo chown -R root:root ../mistborn_volumes/ From 34db39029bf888ca609cbfdb9b2c2ef1042763d8 Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 13:43:25 -0400 Subject: [PATCH 3/7] abs path --- scripts/env/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/env/setup.sh b/scripts/env/setup.sh index afe352e..b7c9643 100755 --- a/scripts/env/setup.sh +++ b/scripts/env/setup.sh @@ -26,7 +26,7 @@ echo "MISTBORN_TAG=$MISTBORN_TAG" | sudo tee -a ${VAR_FILE} 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 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=$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/" From 9e688286ce196823af352b28fbfd6aa32face495 Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 20:34:52 -0400 Subject: [PATCH 4/7] restart.sh --- scripts/restart.sh | 8 ++++++++ scripts/update.sh | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 scripts/restart.sh diff --git a/scripts/restart.sh b/scripts/restart.sh new file mode 100755 index 0000000..f806173 --- /dev/null +++ b/scripts/restart.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +export DEBIAN_FRONTEND=noninteractive + +sudo systemctl restart Mistborn-setup.service +sudo systemctl restart Mistborn-base \ No newline at end of file diff --git a/scripts/update.sh b/scripts/update.sh index 0e03642..a461468 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -13,7 +13,6 @@ sudo pip3 install -e /opt/mistborn/modules/mistborn-cli # handle updates to traefik #sudo cp /opt/mistborn/compose/production/traefik/traefik.toml.template /opt/mistborn/compose/production/traefik/traefik.toml -sudo systemctl enable Mistborn-setup.service sudo systemctl restart Mistborn-setup.service sudo mistborn-cli pullbuild From f0a8e081be3cc77d7d3c28a2ce1777ef2140694b Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 20:38:39 -0400 Subject: [PATCH 5/7] add some pruning --- scripts/update.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/update.sh b/scripts/update.sh index a461468..3f6082d 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -17,4 +17,7 @@ sudo systemctl restart Mistborn-setup.service sudo mistborn-cli pullbuild +sudo docker container prune -f +sudo docker image prune -f + sudo systemctl restart Mistborn-base From 616186e3a1f59445b46d1948ae4ff9d0d5e77cbf Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 21:01:25 -0400 Subject: [PATCH 6/7] uniformity --- scripts/restart.sh | 2 +- scripts/update.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/restart.sh b/scripts/restart.sh index f806173..423908f 100755 --- a/scripts/restart.sh +++ b/scripts/restart.sh @@ -4,5 +4,5 @@ set -e export DEBIAN_FRONTEND=noninteractive -sudo systemctl restart Mistborn-setup.service +sudo systemctl restart Mistborn-setup sudo systemctl restart Mistborn-base \ No newline at end of file diff --git a/scripts/update.sh b/scripts/update.sh index 3f6082d..3a9e00a 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -13,7 +13,7 @@ sudo pip3 install -e /opt/mistborn/modules/mistborn-cli # handle updates to traefik #sudo cp /opt/mistborn/compose/production/traefik/traefik.toml.template /opt/mistborn/compose/production/traefik/traefik.toml -sudo systemctl restart Mistborn-setup.service +sudo systemctl restart Mistborn-setup sudo mistborn-cli pullbuild From ee0b0b1dff0bbec0d3539f99abe3ad8ba4783f61 Mon Sep 17 00:00:00 2001 From: Steven Foerster Date: Sun, 23 Aug 2020 21:25:00 -0400 Subject: [PATCH 7/7] stop setup restart --- scripts/restart.sh | 1 + scripts/update.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/restart.sh b/scripts/restart.sh index 423908f..b3a59a8 100755 --- a/scripts/restart.sh +++ b/scripts/restart.sh @@ -4,5 +4,6 @@ set -e export DEBIAN_FRONTEND=noninteractive +sudo systemctl stop Mistborn-base sudo systemctl restart Mistborn-setup sudo systemctl restart Mistborn-base \ No newline at end of file diff --git a/scripts/update.sh b/scripts/update.sh index 3a9e00a..8026316 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -13,11 +13,11 @@ sudo pip3 install -e /opt/mistborn/modules/mistborn-cli # handle updates to traefik #sudo cp /opt/mistborn/compose/production/traefik/traefik.toml.template /opt/mistborn/compose/production/traefik/traefik.toml -sudo systemctl restart Mistborn-setup - sudo mistborn-cli pullbuild sudo docker container prune -f sudo docker image prune -f +sudo systemctl stop Mistborn-base +sudo systemctl restart Mistborn-setup sudo systemctl restart Mistborn-base