diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b2a1e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*__pycache__* +.vscode/* \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d423b7a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +**** Zamba LXC Toolbox v0.1 **** +- `locales` are now configured noninteractive #21 +- timezone is now configured with `pct set` command in `install.sh` #22 +- changed command sequence in `install.sh` - select container first, then start the installation +- improved / updated documentation +- replaced `just-lxc` container by `debian-priv` and `debian-unpriv` container +- (un)privileged now defined as constant based on created service #6 +- improved log messages in `install.sh` +- `mailpiler`: website is now also `default_host`, removed nginx default site, dns entry is still required +- changed `mailpiler` version to 1.3.11 +- changed `element-web` version to 1.7.25 +- `LXC_AUTHORIZED_KEY` variable now defines an `authorized_keys` file, by default the configuration of you proxmox host will be inherited (`~/.ssh/authorized_keys`) \ No newline at end of file diff --git a/README.md b/README.md index eb4f460..287bd0f 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,13 @@ The package also provides LXC container installers for `mailpiler`, `matrix-syna ### Requirements Proxmox VE Server with at least one configured ZFS Pool. ### Included services: -- `just-lxc` => Debian LXC Container only -- `zmb-ad` => ZMB (Samba) Active Directory Domain Controller, DNS Backends `SAMBA_INTERNAL` and `BIND9_DLZ` are supported -- `zmb-member` => ZMB (Samba) AD member with ZFS volume snapshot support - `zmb-standalone` => ZMB (Samba) standalone server with ZFS volume snapshot support (previous versions) +- `zmb-ad` => ZMB (Samba) Active Directory Domain Controller, DNS Backends `SAMBA_INTERNAL` and `BIND9_DLZ` are supported +- `zmb-member` => ZMB (Samba) AD member with ZFS volume snapshot support (previous versions) - `mailpiler` => mailpiler mail archive [mailpiler.org](https://www.mailpiler.org/) - `matrix` => Matrix Synapse Homeserver [matrix.org](https://matrix.org/docs/projects/server/synapse) with Element Web [Element on github](https://github.com/vector-im/element-web) +- `debian-unpriv` => Debian unprivileged container with basic toolset +- `debian-unpriv` => Debian privileged container with basic toolset ## Usage Just ssh into your Proxmox machine and clone this git repository. Make sure you have installed `git`. ```bash diff --git a/just_lxc.sh b/debian-priv.sh similarity index 100% rename from just_lxc.sh rename to debian-priv.sh diff --git a/debian-unpriv.sh b/debian-unpriv.sh new file mode 100644 index 0000000..881a310 --- /dev/null +++ b/debian-unpriv.sh @@ -0,0 +1,18 @@ +#!/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 + +dpkg-reconfigure locales + +source /root/zamba.conf + +# Set Timezone +ln -sf /usr/share/zoneinfo/$LXC_TIMEZONE /etc/localtime + +apt update +DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq dist-upgrade +DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" $LXC_TOOLSET +sed -i "s|\"syntax on|syntax on|g" /etc/vim/vimrc diff --git a/install.sh b/install.sh index d23a800..35b2f2e 100644 --- a/install.sh +++ b/install.sh @@ -17,7 +17,60 @@ ############### ZAMBA INSTALL SCRIPT ############### # Load configuration file -source ./zamba.conf +source $PWD/zamba.conf + +LXC_MP="0" +LXC_UNPRIVILEGED="1" +LXC_NESTING="0" + +select opt in zmb-standalone zmb-ad zmb-member mailpiler matrix debian-unpriv debian-priv quit; do + case $opt in + debian-unpriv) + echo "Debian-only LXC container unprivileged mode selected" + break + ;; + debian-priv) + echo "Debian-only LXC container privileged mode selected" + LXC_UNPRIVILEGED="0" + break + ;; + zmb-standalone) + echo "Configuring LXC container '$opt'!" + LXC_MP="1" + LXC_UNPRIVILEGED="0" + break + ;; + zmb-member) + echo "Configuring LXC container '$opt'!" + LXC_MP="1" + LXC_UNPRIVILEGED="0" + break + ;; + zmb-ad) + echo "Selected Zamba AD DC" + LXC_NESTING="1" + LXC_UNPRIVILEGED="0" + break + ;; + mailpiler) + echo "Configuring LXC container for '$opt'!" + LXC_NESTING="1" + break + ;; + matrix) + echo "Install Matrix chat server and element web service" + break + ;; + quit) + echo "Script aborted by user interaction." + exit 0 + ;; + *) + echo "Invalid option! Exiting..." + exit 1 + ;; + esac +done # CHeck is the newest template available, else download it. DEB_LOC=$(pveam list $LXC_TEMPLATE_STORAGE | grep debian-10-standard | cut -d'_' -f2) @@ -53,66 +106,30 @@ else VLAN="" fi # Reconfigure conatiner -pct set $LXC_NBR -memory $LXC_MEM -swap $LXC_SWAP -hostname $LXC_HOSTNAME \-nameserver $LXC_DNS -searchdomain $LXC_DOMAIN -onboot 1 -timezone $LXC_TIMEZONE -net0 name=eth0,bridge=$LXC_BRIDGE,firewall=1,gw=$LXC_GW,ip=$LXC_IP,type=veth$VLAN; +pct set $LXC_NBR -memory $LXC_MEM -swap $LXC_SWAP -hostname $LXC_HOSTNAME \-nameserver $LXC_DNS -searchdomain $LXC_DOMAIN -onboot 1 -timezone $LXC_TIMEZONE -features nesting=$LXC_NESTING -net0 name=eth0,bridge=$LXC_BRIDGE,firewall=1,gw=$LXC_GW,ip=$LXC_IP,type=veth$VLAN; +sleep 2 + +if [ $LXC_MP -gt 0 ]; then + pct set $LXC_NBR -mp0 $LXC_SHAREFS_STORAGE:$LXC_SHAREFS_SIZE,mp=/$LXC_SHAREFS_MOUNTPOINT +fi sleep 2; PS3="Select the Server-Function: " -select opt in just_lxc zmb-standalone zmb-member zmb-ad mailpiler matrix quit; do - case $opt in - just_lxc) - echo "Debian-only LXC container selected" - break - ;; - zmb-standalone) - echo "Configuring LXC container '$opt'!" - pct set $LXC_NBR -mp0 $LXC_SHAREFS_STORAGE:$LXC_SHAREFS_SIZE,mp=/$LXC_SHAREFS_MOUNTPOINT - sleep 2; - break - ;; - zmb-member) - echo "Configuring LXC container '$opt'!" - pct set $LXC_NBR -mp0 $LXC_SHAREFS_STORAGE:$LXC_SHAREFS_SIZE,mp=/$LXC_SHAREFS_MOUNTPOINT - sleep 2; - break - ;; - zmb-ad) - echo "Selected Zamba AD DC" - # Enable nesting for ntp service - pct set $LXC_NBR -features nesting=1 - sleep 2 - break - ;; - mailpiler) - echo "Configuring LXC container for '$opt'!" - pct set $LXC_NBR -features nesting=1 - sleep 2; - break - ;; - matrix) - echo "Install Matrix chat server and element web service" - break - ;; - quit) - echo "Script aborted by user interaction." - exit 0 - ;; - *) - echo "Invalid option! Exiting..." - exit 1 - ;; - esac -done - - pct start $LXC_NBR; sleep 5; # Set the root password and key +echo "Setting root password" echo -e "$LXC_PWD\n$LXC_PWD" | lxc-attach -n$LXC_NBR passwd; +echo "Creating /root/.ssh" lxc-attach -n$LXC_NBR mkdir /root/.ssh; -echo -e "$LXC_AUTHORIZED_KEY" | lxc-attach -n$LXC_NBR tee /root/.ssh/authorized_keys; +echo "Copying authorized_keys" +pct push $LXC_NBR $LXC_AUTHORIZED_KEY /root/.ssh/authorized_keys +echo "Copying sources.list" pct push $LXC_NBR ./sources.list /etc/apt/sources.list +echo "Copying zamba.conf" pct push $LXC_NBR ./zamba.conf /root/zamba.conf +echo "Copying install script" pct push $LXC_NBR ./$opt.sh /root/$opt.sh echo "Install '$opt'!" lxc-attach -n$LXC_NBR bash /root/$opt.sh diff --git a/mailpiler.sh b/mailpiler.sh index ca58533..9b65461 100644 --- a/mailpiler.sh +++ b/mailpiler.sh @@ -94,7 +94,7 @@ cd /etc/nginx/sites-available cp /tmp/piler-$PILER_VERSION/contrib/webserver/piler-nginx.conf /etc/nginx/sites-available/ ln -s /etc/nginx/sites-available/piler-nginx.conf /etc/nginx/sites-enabled/piler-nginx.conf -sed -i "s|PILER_HOST|$PILER_FQDN|g" /etc/nginx/sites-available/piler-nginx.conf +sed -i "s|PILER_HOST|$PILER_FQDN default_host|g" /etc/nginx/sites-available/piler-nginx.conf sed -i "s|/var/run/php/php7.4-fpm.sock|/var/run/php/php$PILER_PHP_VERSION-fpm.sock|g" /etc/nginx/sites-available/piler-nginx.conf sed -i "/server_name.*/a \\ @@ -114,10 +114,10 @@ sed -i "/server_name.*/a \\ sed -i "/^server {.*/i\ server {\n\ listen 80;\n\ - server_name $PILER_FQDN;\n\ + server_name $PILER_FQDN default_host;\n\ server_tokens off;\n\ # HTTP to HTTPS redirect.\n\ - return 301 https://$PILER_FQDN;\n\ + return 301 https://\$host\$request_uri;\n\ }" /etc/nginx/sites-available/piler-nginx.conf cp /usr/local/etc/piler/config-site.php /usr/local/etc/piler/config-site.php.bak @@ -137,7 +137,7 @@ cat >> /usr/local/etc/piler/config-site.php <> /usr/local/etc/piler/config-site.php <