From bda8bb9e86b5a4c9d8b214a654f8e9b7fe213dbd Mon Sep 17 00:00:00 2001 From: DerFossibaer Date: Fri, 14 Jan 2022 22:44:06 +0100 Subject: [PATCH] coder weekend --- install.sh | 15 ++++++------ src/checkmk/constants-service.conf | 3 +++ src/debian-priv/constants-service.conf | 3 +++ src/debian-unpriv/constants-service.conf | 3 +++ src/lxc-base.sh | 30 +++++++++++++++++++++-- src/mailpiler/constants-service.conf | 2 ++ src/matrix/constants-service.conf | 3 +++ src/nextcloud/constants-service.conf | 2 ++ src/onlyoffice/constants-service.conf | 3 +++ src/open3a/constants-service.conf | 3 +++ src/proxmox-pbs/constants-service.conf | 23 +++++++++++++++++ src/proxmox-pbs/install-service.sh | 22 +++++++++++++++++ src/urbackup/constants-service.conf | 23 +++++++++++++++++ src/urbackup/install-service.sh | 20 +++++++++++++++ src/zmb-ad/constants-service.conf | 3 +++ src/zmb-member/constants-service.conf | 3 +++ src/zmb-standalone/constants-service.conf | 3 +++ testinstall | 14 +++++++++++ 18 files changed, 168 insertions(+), 10 deletions(-) mode change 100644 => 100755 install.sh create mode 100644 src/proxmox-pbs/constants-service.conf create mode 100644 src/proxmox-pbs/install-service.sh create mode 100644 src/urbackup/constants-service.conf create mode 100644 src/urbackup/install-service.sh create mode 100755 testinstall diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index a903d14..d283175 --- a/install.sh +++ b/install.sh @@ -93,15 +93,15 @@ fi source $PWD/src/$service/constants-service.conf # CHeck is the newest template available, else download it. -DEB_LOC=$(pveam list $LXC_TEMPLATE_STORAGE | grep debian-10-standard | cut -d'_' -f2) -DEB_REP=$(pveam available --section system | grep debian-10-standard | cut -d'_' -f2) +DEB_LOC=$(pveam list $LXC_TEMPLATE_STORAGE | grep $LXC_TEMPLATE_VERSION | cut -d'_' -f2) +DEB_REP=$(pveam available --section system | grep $LXC_TEMPLATE_VERSION | cut -d'_' -f2) if [[ $DEB_LOC == $DEB_REP ]]; then - echo "Newest Version of Debian 10 Standard $DEP_REP exists."; + echo "Newest Version of $LXC_TEMPLATE_VERSION $DEP_REP exists."; else - echo "Will now download newest Debian 10 Standard $DEP_REP."; - pveam download $LXC_TEMPLATE_STORAGE debian-10-standard_$DEB_REP\_amd64.tar.gz + echo "Will now download newest $LXC_TEMPLATE_VERSION $DEP_REP."; + pveam download $LXC_TEMPLATE_STORAGE "$LXC_TEMPLATE_VERSION"_$DEB_REP\_amd64.tar.gz fi if [ $ctid -gt 99 ]; then @@ -120,7 +120,7 @@ fi echo "Will now create LXC Container $LXC_NBR!"; # Create the container -pct create $LXC_NBR -unprivileged $LXC_UNPRIVILEGED $LXC_TEMPLATE_STORAGE:vztmpl/debian-10-standard_$DEB_REP\_amd64.tar.gz -rootfs $LXC_ROOTFS_STORAGE:$LXC_ROOTFS_SIZE; +pct create $LXC_NBR -unprivileged $LXC_UNPRIVILEGED $LXC_TEMPLATE_STORAGE:vztmpl/"$LXC_TEMPLATE_VERSION"_$DEB_REP\_amd64.tar.gz -rootfs $LXC_ROOTFS_STORAGE:$LXC_ROOTFS_SIZE; sleep 2; # Check vlan configuration @@ -147,7 +147,6 @@ sleep 5; echo -e "$LXC_PWD\n$LXC_PWD" | lxc-attach -n$LXC_NBR passwd; lxc-attach -n$LXC_NBR mkdir /root/.ssh; pct push $LXC_NBR $LXC_AUTHORIZED_KEY /root/.ssh/authorized_keys -pct push $LXC_NBR $PWD/src/sources.list /etc/apt/sources.list pct push $LXC_NBR $config /root/zamba.conf pct push $LXC_NBR $PWD/src/constants.conf /root/constants.conf pct push $LXC_NBR $PWD/src/lxc-base.sh /root/lxc-base.sh @@ -163,4 +162,4 @@ if [[ $service == "zmb-ad" ]]; then pct stop $LXC_NBR pct set $LXC_NBR \-nameserver $(echo $LXC_IP | cut -d'/' -f 1) pct start $LXC_NBR -fi +fi \ No newline at end of file diff --git a/src/checkmk/constants-service.conf b/src/checkmk/constants-service.conf index d6a75fa..f896b3f 100644 --- a/src/checkmk/constants-service.conf +++ b/src/checkmk/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-11-standard" + # Create sharefs mountpoint LXC_MP="0" diff --git a/src/debian-priv/constants-service.conf b/src/debian-priv/constants-service.conf index 9439c47..2855c22 100644 --- a/src/debian-priv/constants-service.conf +++ b/src/debian-priv/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-11-standard" + # Create sharefs mountpoint LXC_MP="0" diff --git a/src/debian-unpriv/constants-service.conf b/src/debian-unpriv/constants-service.conf index 382f437..bb64eeb 100644 --- a/src/debian-unpriv/constants-service.conf +++ b/src/debian-unpriv/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-10-standard" + # Create sharefs mountpoint LXC_MP="0" diff --git a/src/lxc-base.sh b/src/lxc-base.sh index 4ded575..b89d820 100644 --- a/src/lxc-base.sh +++ b/src/lxc-base.sh @@ -9,6 +9,7 @@ echo "Loading configuration..." source /root/zamba.conf source /root/constants.conf +source /root/constants-service.conf echo "Updating locales" # update locales @@ -17,11 +18,36 @@ cat << EOF > /etc/default/locale LANG="$LXC_LOCALE" LANGUAGE=$LXC_LOCALE EOF -locale-gen $LXC_LOCALE +locale-gen $LXC_LOCALE + +# Generate sources +if [ "$LXC_TEMPLATE_VERSION" == "debian-11-standard" ] ; then + +cat << EOF > /etc/apt/sources.list +deb http://ftp.de.debian.org/debian bullseye main contrib + +deb http://ftp.de.debian.org/debian bullseye-updates main contrib + +# security updates +deb http://security.debian.org bullseye-security main contrib +EOF + +elif [ "$LXC_TEMPLATE_VERSION" == "debian-10-standard" ] ; then + +cat << EOF > /etc/apt/sources.list +deb http://ftp.de.debian.org/debian buster main contrib + +deb http://ftp.de.debian.org/debian buster-updates main contrib + +# security updates +deb http://security.debian.org buster/updates main contrib +EOF +else echo "LXC Debian Version false. Please check configuration files!" ; exit +fi # update package lists echo "Updating package database..." -apt update +apt --allow-releaseinfo-change update # install latest packages echo "Installing latest updates" diff --git a/src/mailpiler/constants-service.conf b/src/mailpiler/constants-service.conf index 2f48d83..f70dc46 100644 --- a/src/mailpiler/constants-service.conf +++ b/src/mailpiler/constants-service.conf @@ -7,6 +7,8 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-10-standard" # Create sharefs mountpoint LXC_MP="0" diff --git a/src/matrix/constants-service.conf b/src/matrix/constants-service.conf index a8136ea..5ae596c 100644 --- a/src/matrix/constants-service.conf +++ b/src/matrix/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-10-standard" + # Create sharefs mountpoint LXC_MP="0" diff --git a/src/nextcloud/constants-service.conf b/src/nextcloud/constants-service.conf index 5c78dbd..5015602 100644 --- a/src/nextcloud/constants-service.conf +++ b/src/nextcloud/constants-service.conf @@ -7,6 +7,8 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-10-standard" # Create sharefs mountpoint LXC_MP="1" diff --git a/src/onlyoffice/constants-service.conf b/src/onlyoffice/constants-service.conf index 07c2aa6..7666975 100644 --- a/src/onlyoffice/constants-service.conf +++ b/src/onlyoffice/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-11-standard" + # Create sharefs mountpoint LXC_MP="0" diff --git a/src/open3a/constants-service.conf b/src/open3a/constants-service.conf index 382f437..bb64eeb 100644 --- a/src/open3a/constants-service.conf +++ b/src/open3a/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-10-standard" + # Create sharefs mountpoint LXC_MP="0" diff --git a/src/proxmox-pbs/constants-service.conf b/src/proxmox-pbs/constants-service.conf new file mode 100644 index 0000000..6fa62ad --- /dev/null +++ b/src/proxmox-pbs/constants-service.conf @@ -0,0 +1,23 @@ +#!/bin/bash + +# Authors: +# (C) 2021 Idea an concept by Christian Zengel +# (C) 2021 Script design and prototype by Markus Helmke +# (C) 2021 Script rework and documentation by Thorsten Spille + +# This file contains the project constants on service level + +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-11-standard" + +# Create sharefs mountpoint +LXC_MP="1" + +# Create unprivileged container +LXC_UNPRIVILEGED="1" + +# enable nesting feature +LXC_NESTING="0" + +# Backup ubdir where Urbackup will store backups +PBS_DATA="backup" \ No newline at end of file diff --git a/src/proxmox-pbs/install-service.sh b/src/proxmox-pbs/install-service.sh new file mode 100644 index 0000000..1771d45 --- /dev/null +++ b/src/proxmox-pbs/install-service.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Authors: +# (C) 2021 Idea an concept by Christian Zengel +# (C) 2021 Script design and prototype by Markus Helmke +# (C) 2021 Script rework and documentation by Thorsten Spille + +source /root/zamba.conf +source /root/constants-service.conf + +cat << EOF > /etc/apt/sources.list.d/pbs-no-subscription.list +# PBS pbs-no-subscription repository provided by proxmox.com, +# NOT recommended for production use +deb http://download.proxmox.com/debian/pbs bullseye pbs-no-subscription +EOF + +wget https://enterprise.proxmox.com/debian/proxmox-release-bullseye.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bullseye.gpg + +apt update && apt upgrade -y +DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" proxmox-backup-server + +proxmox-backup-manager datastore create $PBS_DATA /$LXC_SHAREFS_MOUNTPOINT/$PBS_DATA diff --git a/src/urbackup/constants-service.conf b/src/urbackup/constants-service.conf new file mode 100644 index 0000000..17d6e12 --- /dev/null +++ b/src/urbackup/constants-service.conf @@ -0,0 +1,23 @@ +#!/bin/bash + +# Authors: +# (C) 2021 Idea an concept by Christian Zengel +# (C) 2021 Script design and prototype by Markus Helmke +# (C) 2021 Script rework and documentation by Thorsten Spille + +# This file contains the project constants on service level + +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-10-standard" + +# Create sharefs mountpoint +LXC_MP="1" + +# Create unprivileged container +LXC_UNPRIVILEGED="1" + +# enable nesting feature +LXC_NESTING="0" + +# Backup ubdir where Urbackup will store backups +URBACKUP_DATA="urbackup" \ No newline at end of file diff --git a/src/urbackup/install-service.sh b/src/urbackup/install-service.sh new file mode 100644 index 0000000..b7f6893 --- /dev/null +++ b/src/urbackup/install-service.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Authors: +# (C) 2021 Idea an concept by Christian Zengel +# (C) 2021 Script design and prototype by Markus Helmke +# (C) 2021 Script rework and documentation by Thorsten Spille + +source /root/zamba.conf +source /root/constants-service.conf + +mkdir /$LXC_SHAREFS_MOUNTPOINT/$URBACKUP_DATA +mkdir /etc/urbackup +echo "/$LXC_SHAREFS_MOUNTPOINT/$URBACKUP_DATA" > /etc/urbackup/backupfolder + +echo 'deb http://download.opensuse.org/repositories/home:/uroni/Debian_10/ /' | tee /etc/apt/sources.list.d/home:uroni.list +curl -fsSL https://download.opensuse.org/repositories/home:uroni/Debian_10/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/home_uroni.gpg > /dev/null + +apt update +DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install -y --no-install-recommends -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" urbackup-server +chown urbackup:urbackup /$LXC_SHAREFS_MOUNTPOINT/$URBACKUP_DATA \ No newline at end of file diff --git a/src/zmb-ad/constants-service.conf b/src/zmb-ad/constants-service.conf index a403e3c..148d75d 100644 --- a/src/zmb-ad/constants-service.conf +++ b/src/zmb-ad/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-11-standard" + # Defines the desired DNS server backend, supported are `SAMBA_INTERNAL` and `BIND9_DLZ` for more advanced usage ZMB_DNS_BACKEND="SAMBA_INTERNAL" diff --git a/src/zmb-member/constants-service.conf b/src/zmb-member/constants-service.conf index a2d006f..a3d76c9 100644 --- a/src/zmb-member/constants-service.conf +++ b/src/zmb-member/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-11-standard" + # Create sharefs mountpoint LXC_MP="1" diff --git a/src/zmb-standalone/constants-service.conf b/src/zmb-standalone/constants-service.conf index b5d26cf..e650fc8 100644 --- a/src/zmb-standalone/constants-service.conf +++ b/src/zmb-standalone/constants-service.conf @@ -7,6 +7,9 @@ # This file contains the project constants on service level +# Debian Version, which will be installed +LXC_TEMPLATE_VERSION="debian-11-standard" + # Create sharefs mountpoint LXC_MP="1" diff --git a/testinstall b/testinstall new file mode 100755 index 0000000..6a6c464 --- /dev/null +++ b/testinstall @@ -0,0 +1,14 @@ + +bash -vx install.sh -s checkmk > checkmk.inst.log +bash -vx install.sh -s debian-unpriv > debian-unpriv.inst.log +bash -vx install.sh -s matrix > matrix.inst.log +bash -vx install.sh -s nextcloud > nextcloud.inst.log +bash -vx install.sh -s open3a > open3a.inst.log +bash -vx install.sh -s zmb-ad > zmb-ad.inst.log +bash -vx install.sh -s zmb-member > zmb-member.inst.log +bash -vx install.sh -s zmb-standalone > zmb-standalone.inst.log +bash -vx install.sh -s debian-priv > debian-priv.inst.log +bash -vx install.sh -s mailpiler > mailpiler.inst.log +bash -vx install.sh -s onlyoffice > onlyoffice.inst.log +bash -vx install.sh -s proxmox-pbs > proxmox-pbs.inst.log +bash -vx install.sh -s urbackup > urbackup.inst.log