forked from bashclub/zamba-lxc-toolbox
		
	qMerge branch '2022-01-14' of https://github.com/bashclub/zamba-lxc-toolbox into 2022-01-14
This commit is contained in:
		
							
								
								
									
										20
									
								
								archive/debian-priv.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								archive/debian-priv.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
source /root/zamba.conf
 | 
			
		||||
 | 
			
		||||
sed -i "s|# $LXC_LOCALE|$LXC_LOCALE|" /etc/locale.gen
 | 
			
		||||
cat << EOF > /etc/default/locale
 | 
			
		||||
LANG="$LXC_LOCALE"
 | 
			
		||||
LANGUAGE=$LXC_LOCALE
 | 
			
		||||
EOF
 | 
			
		||||
locale-gen $LXC_LOCALE
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										25
									
								
								archive/debian-unpriv.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								archive/debian-unpriv.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
source /root/zamba.conf
 | 
			
		||||
source /root/proxmox.conf
 | 
			
		||||
 | 
			
		||||
sed -i "s/^#.$HOST_LOCALE/$HOST_LOCALE/" /etc/locale.gen
 | 
			
		||||
locale-gen $HOST_LOCALE
 | 
			
		||||
 | 
			
		||||
sed -i "s/^#.$LXC_LOCALE/$LXC_LOCALE/" /etc/locale.gen
 | 
			
		||||
locale-gen $LXC_LOCALE
 | 
			
		||||
echo LANG=$LXC_LOCALE > /etc/default/locale
 | 
			
		||||
echo LANGUAGE=$LXC_LOCALE >> /etc/default/locale
 | 
			
		||||
export LANG=$LXC_LOCALE
 | 
			
		||||
export LANGUAGE=$LXC_LOCALE
 | 
			
		||||
export LC_CTYPE=C
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										187
									
								
								archive/mailpiler.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								archive/mailpiler.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,187 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
source /root/zamba.conf
 | 
			
		||||
 | 
			
		||||
sed -i "s|# $LXC_LOCALE|$LXC_LOCALE|" /etc/locale.gen
 | 
			
		||||
cat << EOF > /etc/default/locale
 | 
			
		||||
LANG="$LXC_LOCALE"
 | 
			
		||||
LANGUAGE=$LXC_LOCALE
 | 
			
		||||
EOF
 | 
			
		||||
locale-gen $LXC_LOCALE
 | 
			
		||||
 | 
			
		||||
HOSTNAME=$(hostname -f)
 | 
			
		||||
 | 
			
		||||
echo "Ensure your Hostname is set to your Piler FQDN!"
 | 
			
		||||
 | 
			
		||||
echo $HOSTNAME
 | 
			
		||||
 | 
			
		||||
if 
 | 
			
		||||
    [ "$HOSTNAME" != "$PILER_FQDN" ]
 | 
			
		||||
then
 | 
			
		||||
        echo "Hostname doesn't match PILER_FQDNain! Check install.sh, /etc/hosts, /etc/hostname." && exit
 | 
			
		||||
else
 | 
			
		||||
        echo "Hostname matches PILER_FQDNAIN, so starting installation."
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
apt update && apt full-upgrade -y
 | 
			
		||||
 | 
			
		||||
apt install -y $LXC_TOOLSET build-essential libwrap0-dev libpst-dev tnef libytnef0-dev unrtf catdoc libtre-dev tre-agrep poppler-utils libzip-dev unixodbc libpq5 software-properties-common libpoppler-dev openssl libssl-dev memcached telnet nginx mariadb-server default-libmysqlclient-dev python-mysqldb gcc libwrap0 libzip4 latex2rtf latex2html catdoc tnef zipcmp zipmerge ziptool libsodium23
 | 
			
		||||
 | 
			
		||||
# install php
 | 
			
		||||
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
 | 
			
		||||
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
 | 
			
		||||
 | 
			
		||||
apt update && apt install -y php$PILER_PHP_VERSION-{fpm,common,ldap,mysql,cli,opcache,phpdbg,gd,memcache,json,readline,zip}
 | 
			
		||||
 | 
			
		||||
apt purge -y postfix
 | 
			
		||||
 | 
			
		||||
cat > /etc/mysql/conf.d/mailpiler.conf <<EOF
 | 
			
		||||
innodb_buffer_pool_size=256M
 | 
			
		||||
innodb_flush_log_at_trx_commit=1
 | 
			
		||||
innodb_log_buffer_size=64M
 | 
			
		||||
innodb_log_file_size=16M
 | 
			
		||||
query_cache_size=0
 | 
			
		||||
query_cache_type=0
 | 
			
		||||
query_cache_limit=2M
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
systemctl restart mariadb
 | 
			
		||||
 | 
			
		||||
cd /tmp
 | 
			
		||||
wget https://download.mailpiler.com/generic-local/sphinx-$PILER_SPHINX_VERSION-bin.tar.gz
 | 
			
		||||
tar -xvzf sphinx-$PILER_SPHINX_VERSION-bin.tar.gz -C /
 | 
			
		||||
 | 
			
		||||
groupadd piler
 | 
			
		||||
useradd -g piler -m -s /bin/bash -d /var/piler piler
 | 
			
		||||
usermod -L piler
 | 
			
		||||
chmod 755 /var/piler
 | 
			
		||||
 | 
			
		||||
wget https://bitbucket.org/jsuto/piler/downloads/piler-$PILER_VERSION.tar.gz
 | 
			
		||||
tar -xvzf piler-$PILER_VERSION.tar.gz
 | 
			
		||||
cd piler-$PILER_VERSION/
 | 
			
		||||
./configure --localstatedir=/var --with-database=mysql --enable-tcpwrappers --enable-memcached
 | 
			
		||||
make
 | 
			
		||||
make install
 | 
			
		||||
ldconfig
 | 
			
		||||
 | 
			
		||||
cp util/postinstall.sh util/postinstall.sh.bak
 | 
			
		||||
sed -i "s/   PILER_SMARTHOST=.*/   PILER_SMARTHOST="\"$PILER_SMARTHOST\""/" util/postinstall.sh
 | 
			
		||||
sed -i 's/   WWWGROUP=.*/   WWWGROUP="www-data"/' util/postinstall.sh
 | 
			
		||||
 | 
			
		||||
make postinstall
 | 
			
		||||
 | 
			
		||||
cp /usr/local/etc/piler/piler.conf /usr/local/etc/piler/piler.conf.bak
 | 
			
		||||
sed -i "s/hostid=.*/hostid=$PILER_FQDN/" /usr/local/etc/piler/piler.conf
 | 
			
		||||
sed -i "s/update_counters_to_memcached=.*/update_counters_to_memcached=1/" /usr/local/etc/piler/piler.conf
 | 
			
		||||
 | 
			
		||||
su piler -c "indexer --all --config /usr/local/etc/piler/sphinx.conf"
 | 
			
		||||
 | 
			
		||||
/etc/init.d/rc.piler start
 | 
			
		||||
/etc/init.d/rc.searchd start
 | 
			
		||||
 | 
			
		||||
update-rc.d rc.piler defaults
 | 
			
		||||
update-rc.d rc.searchd defaults
 | 
			
		||||
 | 
			
		||||
mkdir -p /etc/nginx/ssl
 | 
			
		||||
openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout /etc/nginx/ssl/piler.key -out /etc/nginx/ssl/piler.crt -subj "/CN=$PILER_FQDN" -addext "subjectAltName=DNS:$PILER_FQDN"
 | 
			
		||||
 | 
			
		||||
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 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 \\
 | 
			
		||||
        listen 443 ssl http2;\n\n\
 | 
			
		||||
        ssl_certificate /etc/nginx/ssl/piler.crt;\n\
 | 
			
		||||
        ssl_certificate_key /etc/nginx/ssl/piler.key;\n\n\
 | 
			
		||||
        ssl_session_timeout 1d;\n\
 | 
			
		||||
        ssl_session_cache shared:SSL:15m;\n\
 | 
			
		||||
        ssl_session_tickets off;\n\n\
 | 
			
		||||
        # modern configuration of Mozilla SSL configurator. Tweak to your needs.\n\
 | 
			
		||||
        ssl_protocols TLSv1.2 TLSv1.3;\n\
 | 
			
		||||
        ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;\n\
 | 
			
		||||
        ssl_prefer_server_ciphers off;\n\n\
 | 
			
		||||
        add_header X-Frame-Options SAMEORIGIN;\n\
 | 
			
		||||
        add_header X-Content-Type-Options nosniff;" /etc/nginx/sites-available/piler-nginx.conf
 | 
			
		||||
 | 
			
		||||
sed -i "/^server {.*/i\
 | 
			
		||||
server {\n\
 | 
			
		||||
        listen 80;\n\
 | 
			
		||||
        server_name $PILER_FQDN default_host;\n\
 | 
			
		||||
        server_tokens off;\n\
 | 
			
		||||
        # HTTP to HTTPS redirect.\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
 | 
			
		||||
sed -i "s|\$config\['SITE_URL'\] = .*|\$config\['SITE_URL'\] = 'https://$PILER_FQDN/';|" /usr/local/etc/piler/config-site.php
 | 
			
		||||
cat >> /usr/local/etc/piler/config-site.php <<EOF
 | 
			
		||||
 | 
			
		||||
// CUSTOM
 | 
			
		||||
\$config['PROVIDED_BY'] = '$PILER_FQDN';
 | 
			
		||||
\$config['SUPPORT_LINK'] = 'https://$PILER_FQDN';
 | 
			
		||||
\$config['COMPATIBILITY'] = '';
 | 
			
		||||
 | 
			
		||||
// fancy features.
 | 
			
		||||
\$config['ENABLE_INSTANT_SEARCH'] = 1;
 | 
			
		||||
\$config['ENABLE_TABLE_RESIZE'] = 1;
 | 
			
		||||
 | 
			
		||||
\$config['ENABLE_DELETE'] = 1;
 | 
			
		||||
\$config['ENABLE_ON_THE_FLY_VERIFICATION'] = 1;
 | 
			
		||||
 | 
			
		||||
// general settings.
 | 
			
		||||
\$config['TIMEZONE'] = '$LXC_TIMEZONE';
 | 
			
		||||
 | 
			
		||||
// authentication
 | 
			
		||||
// Enable authentication against an imap server
 | 
			
		||||
//\$config['ENABLE_IMAP_AUTH'] = 1;
 | 
			
		||||
//\$config['RESTORE_OVER_IMAP'] = 1;
 | 
			
		||||
//\$config['IMAP_RESTORE_FOLDER_INBOX'] = 'INBOX';
 | 
			
		||||
//\$config['IMAP_RESTORE_FOLDER_SENT'] = 'Sent';
 | 
			
		||||
//\$config['IMAP_HOST'] = '$PILER_SMARTHOST';
 | 
			
		||||
//\$config['IMAP_PORT'] =  993;
 | 
			
		||||
//\$config['IMAP_SSL'] = true;
 | 
			
		||||
 | 
			
		||||
// authentication against an ldap directory (disabled by default)
 | 
			
		||||
//\$config['ENABLE_LDAP_AUTH'] = 1;
 | 
			
		||||
//\$config['LDAP_HOST'] = '$PILER_SMARTHOST';
 | 
			
		||||
//\$config['LDAP_PORT'] = 389;
 | 
			
		||||
//\$config['LDAP_HELPER_DN'] = 'cn=administrator,cn=users,dc=mydomain,dc=local';
 | 
			
		||||
//\$config['LDAP_HELPER_PASSWORD'] = 'myxxxxpasswd';
 | 
			
		||||
//\$config['LDAP_MAIL_ATTR'] = 'mail';
 | 
			
		||||
//\$config['LDAP_AUDITOR_MEMBER_DN'] = '';
 | 
			
		||||
//\$config['LDAP_ADMIN_MEMBER_DN'] = '';
 | 
			
		||||
//\$config['LDAP_BASE_DN'] = 'ou=Benutzer,dc=krs,dc=local';
 | 
			
		||||
 | 
			
		||||
// authentication against an Uninvention based ldap directory 
 | 
			
		||||
//\$config['ENABLE_LDAP_AUTH'] = 1;
 | 
			
		||||
//\$config['LDAP_HOST'] = '$PILER_SMARTHOST';
 | 
			
		||||
//\$config['LDAP_PORT'] = 7389;
 | 
			
		||||
//\$config['LDAP_HELPER_DN'] = 'uid=ldap-search-user,cn=users,dc=mydomain,dc=local';
 | 
			
		||||
//\$config['LDAP_HELPER_PASSWORD'] = 'myxxxxpasswd';
 | 
			
		||||
//\$config['LDAP_AUDITOR_MEMBER_DN'] = '';
 | 
			
		||||
//\$config['LDAP_ADMIN_MEMBER_DN'] = '';
 | 
			
		||||
//\$config['LDAP_BASE_DN'] = 'cn=users,dc=mydomain,dc=local';
 | 
			
		||||
//\$config['LDAP_MAIL_ATTR'] = 'mailPrimaryAddress';
 | 
			
		||||
//\$config['LDAP_ACCOUNT_OBJECTCLASS'] = 'person';
 | 
			
		||||
//\$config['LDAP_DISTRIBUTIONLIST_OBJECTCLASS'] = 'person';
 | 
			
		||||
//\$config['LDAP_DISTRIBUTIONLIST_ATTR'] = 'mailAlternativeAddress';
 | 
			
		||||
 | 
			
		||||
// special settings.
 | 
			
		||||
\$config['MEMCACHED_ENABLED'] = 1;
 | 
			
		||||
\$config['SPHINX_STRICT_SCHEMA'] = 1; // required for Sphinx $PILER_SPHINX_VERSION, see https://bitbucket.org/jsuto/piler/issues/1085/sphinx-331.
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
rm /etc/nginx/sites-enabled/default
 | 
			
		||||
 | 
			
		||||
nginx -t && systemctl restart nginx
 | 
			
		||||
 | 
			
		||||
apt autoremove -y
 | 
			
		||||
apt clean -y
 | 
			
		||||
							
								
								
									
										161
									
								
								archive/matrix.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										161
									
								
								archive/matrix.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,161 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
source /root/zamba.conf
 | 
			
		||||
 | 
			
		||||
sed -i "s|# $LXC_LOCALE|$LXC_LOCALE|" /etc/locale.gen
 | 
			
		||||
cat << EOF > /etc/default/locale
 | 
			
		||||
LANG="$LXC_LOCALE"
 | 
			
		||||
LANGUAGE=$LXC_LOCALE
 | 
			
		||||
EOF
 | 
			
		||||
locale-gen $LXC_LOCALE
 | 
			
		||||
 | 
			
		||||
MRX_PKE=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
 | 
			
		||||
 | 
			
		||||
ELE_DBNAME="synapse_db"
 | 
			
		||||
ELE_DBUSER="synapse_user"
 | 
			
		||||
ELE_DBPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
 | 
			
		||||
 | 
			
		||||
apt update && apt full-upgrade -y
 | 
			
		||||
 | 
			
		||||
apt install -y $LXC_TOOLSET apt-transport-https gpg software-properties-common nginx postgresql python3-psycopg2
 | 
			
		||||
 | 
			
		||||
wget wget -O /usr/share/keyrings/matrix-org-archive-keyring.gpg https://packages.matrix.org/debian/matrix-org-archive-keyring.gpg
 | 
			
		||||
echo "deb [signed-by=/usr/share/keyrings/matrix-org-archive-keyring.gpg] https://packages.matrix.org/debian/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/matrix-org.list
 | 
			
		||||
apt update && apt install -y matrix-synapse-py3
 | 
			
		||||
systemctl enable matrix-synapse
 | 
			
		||||
 | 
			
		||||
ss -tulpen
 | 
			
		||||
 | 
			
		||||
mkdir /etc/nginx/ssl
 | 
			
		||||
openssl req -x509 -nodes -days 3650 -newkey rsa:4096 -keyout /etc/nginx/ssl/matrix.key -out /etc/nginx/ssl/matrix.crt -subj "/CN=$MATRIX_FQDN" -addext "subjectAltName=DNS:$MATRIX_FQDN"
 | 
			
		||||
 | 
			
		||||
cat > /etc/nginx/sites-available/$MATRIX_FQDN <<EOF
 | 
			
		||||
# Virtual Host configuration for example.com
 | 
			
		||||
#
 | 
			
		||||
# You can move that to a different file under sites-available/ and symlink that
 | 
			
		||||
# to sites-enabled/ to enable it.
 | 
			
		||||
 | 
			
		||||
server {
 | 
			
		||||
    listen 80;
 | 
			
		||||
    listen [::]:80;
 | 
			
		||||
    server_name $MATRIX_FQDN;
 | 
			
		||||
 | 
			
		||||
    return 301 https://$MATRIX_FQDN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
server {
 | 
			
		||||
    listen 443 ssl;
 | 
			
		||||
    listen [::]:443 ssl;
 | 
			
		||||
    server_name $MATRIX_FQDN;
 | 
			
		||||
 | 
			
		||||
    ssl on;
 | 
			
		||||
    ssl_certificate /etc/nginx/ssl/matrix.crt;
 | 
			
		||||
    ssl_certificate_key /etc/nginx/ssl/matrix.key;
 | 
			
		||||
 | 
			
		||||
    location / {
 | 
			
		||||
      proxy_pass http://127.0.0.1:8008;
 | 
			
		||||
      proxy_set_header X-Forwarded-For \$remote_addr;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
server {
 | 
			
		||||
    listen 8448 ssl;
 | 
			
		||||
    listen [::]:8448 ssl;
 | 
			
		||||
    server_name $MATRIX_FQDN;
 | 
			
		||||
 | 
			
		||||
    ssl on;
 | 
			
		||||
    ssl_certificate /etc/nginx/ssl/matrix.crt;
 | 
			
		||||
    ssl_certificate_key /etc/nginx/ssl/matrix.key;
 | 
			
		||||
 | 
			
		||||
    # If you don't wanna serve a site, comment this out
 | 
			
		||||
    root /var/www/$MATRIX_FQDN;
 | 
			
		||||
    index index.html index.htm;
 | 
			
		||||
 | 
			
		||||
    location / {
 | 
			
		||||
        proxy_pass http://127.0.0.1:8008;
 | 
			
		||||
        proxy_set_header X-Forwarded-For \$remote_addr;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
ln -s /etc/nginx/sites-available/$MATRIX_FQDN /etc/nginx/sites-enabled/$MATRIX_FQDN
 | 
			
		||||
 | 
			
		||||
cat > /etc/nginx/sites-available/$MATRIX_ELEMENT_FQDN <<EOF
 | 
			
		||||
# Virtual Host configuration for example.com
 | 
			
		||||
#
 | 
			
		||||
# You can move that to a different file under sites-available/ and symlink that
 | 
			
		||||
# to sites-enabled/ to enable it.
 | 
			
		||||
 | 
			
		||||
server {
 | 
			
		||||
    listen 80;
 | 
			
		||||
    listen [::]:80;
 | 
			
		||||
    server_name $MATRIX_ELEMENT_FQDN;
 | 
			
		||||
    return 301 https://$MATRIX_ELEMENT_FQDN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
server {
 | 
			
		||||
    listen 443 ssl;
 | 
			
		||||
    listen [::]:443 ssl;
 | 
			
		||||
    server_name $MATRIX_ELEMENT_FQDN;
 | 
			
		||||
 | 
			
		||||
    ssl on;
 | 
			
		||||
    ssl_certificate /etc/nginx/ssl/matrix.crt;
 | 
			
		||||
    ssl_certificate_key /etc/nginx/ssl/matrix.key;
 | 
			
		||||
 | 
			
		||||
    # If you don't wanna serve a site, comment this out
 | 
			
		||||
    root /var/www/$MATRIX_ELEMENT_FQDN/element;
 | 
			
		||||
    index index.html index.htm;
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
ln -s /etc/nginx/sites-available/$MATRIX_ELEMENT_FQDN /etc/nginx/sites-enabled/$MATRIX_ELEMENT_FQDN
 | 
			
		||||
 | 
			
		||||
systemctl restart nginx
 | 
			
		||||
 | 
			
		||||
mkdir /var/www/$MATRIX_ELEMENT_FQDN
 | 
			
		||||
cd /var/www/$MATRIX_ELEMENT_FQDN
 | 
			
		||||
wget https://packages.riot.im/element-release-key.asc
 | 
			
		||||
gpg --import element-release-key.asc
 | 
			
		||||
 | 
			
		||||
wget https://github.com/vector-im/element-web/releases/download/$MATRIX_ELEMENT_VERSION/element-$MATRIX_ELEMENT_VERSION.tar.gz
 | 
			
		||||
wget https://github.com/vector-im/element-web/releases/download/$MATRIX_ELEMENT_VERSION/element-$MATRIX_ELEMENT_VERSION.tar.gz.asc
 | 
			
		||||
gpg --verify element-$MATRIX_ELEMENT_VERSION.tar.gz.asc
 | 
			
		||||
 | 
			
		||||
tar -xzvf element-$MATRIX_ELEMENT_VERSION.tar.gz
 | 
			
		||||
ln -s element-$MATRIX_ELEMENT_VERSION element
 | 
			
		||||
chown www-data:www-data -R element
 | 
			
		||||
cp ./element/config.sample.json ./element/config.json
 | 
			
		||||
sed -i "s|https://matrix-client.matrix.org|https://$MATRIX_FQDN|" ./element/config.json
 | 
			
		||||
sed -i "s|\"server_name\": \"matrix.org\"|\"server_name\": \"$MATRIX_FQDN\"|" ./element/config.json
 | 
			
		||||
 | 
			
		||||
su postgres <<EOF
 | 
			
		||||
psql -c "CREATE USER $ELE_DBUSER WITH PASSWORD '$ELE_DBPASS';"
 | 
			
		||||
psql -c "CREATE DATABASE $ELE_DBNAME ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER $ELE_DBUSER;"
 | 
			
		||||
echo "Postgres User '$ELE_DBUSER' and database '$ELE_DBNAME' created."
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
cd /
 | 
			
		||||
sed -i "s|#registration_shared_secret: <PRIVATE STRING>|registration_shared_secret: \"$MRX_PKE\"|" /etc/matrix-synapse/homeserver.yaml
 | 
			
		||||
sed -i "s|#public_baseurl: https://example.com/|public_baseurl: https://$MATRIX_FQDN/|" /etc/matrix-synapse/homeserver.yaml
 | 
			
		||||
sed -i "s|#enable_registration: false|enable_registration: true|" /etc/matrix-synapse/homeserver.yaml
 | 
			
		||||
sed -i "s|name: sqlite3|name: psycopg2|" /etc/matrix-synapse/homeserver.yaml
 | 
			
		||||
sed -i "s|database: /var/lib/matrix-synapse/homeserver.db|database: $ELE_DBNAME\n    user: $ELE_DBUSER\n    password: $ELE_DBPASS\n    host: 127.0.0.1\n    cp_min: 5\n    cp_max: 10|" /etc/matrix-synapse/homeserver.yaml
 | 
			
		||||
 | 
			
		||||
systemctl restart matrix-synapse
 | 
			
		||||
 | 
			
		||||
register_new_matrix_user -c /etc/matrix-synapse/homeserver.yaml http://127.0.0.1:8008
 | 
			
		||||
 | 
			
		||||
#curl https://download.jitsi.org/jitsi-key.gpg.key | sh -c 'gpg --dearmor > /usr/share/keyrings/jitsi-keyring.gpg'
 | 
			
		||||
#echo 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' | tee /etc/apt/sources.list.d/jitsi-stable.list > /dev/null
 | 
			
		||||
 | 
			
		||||
#apt update
 | 
			
		||||
#apt install -y jitsi-meet
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										115
									
								
								archive/zamba.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								archive/zamba.conf
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,115 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# This ist the Zamba main configuration file.
 | 
			
		||||
# Please adjust the settings to your needs before running the installer.
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
############### Linux Container Section ###############
 | 
			
		||||
 | 
			
		||||
# Defines the Proxmox storage where your LXC container template are stored (default: local)
 | 
			
		||||
LXC_TEMPLATE_STORAGE="local"
 | 
			
		||||
 | 
			
		||||
# Defines the size in GB of the LXC container's root filesystem (default: 32)
 | 
			
		||||
# Depending on your environment, you should consider increasing the size for use of `mailpiler` or `matrix`.
 | 
			
		||||
LXC_ROOTFS_SIZE="32"
 | 
			
		||||
# Defines the Proxmox storage where your LXC container's root filesystem will be generated (default: local-zfs)
 | 
			
		||||
LXC_ROOTFS_STORAGE="local-zfs"
 | 
			
		||||
 | 
			
		||||
# Defines the size in GB your LXC container's filesystem shared by Zamba (AD member & standalone) (default: 100)
 | 
			
		||||
LXC_SHAREFS_SIZE="100"
 | 
			
		||||
# Defines the Proxmox storage where your LXC container's filesystem shared by Zamba will be generated (default: local-zfs)
 | 
			
		||||
LXC_SHAREFS_STORAGE="local-zfs"
 | 
			
		||||
# Defines the mountpoint of the filesystem shared by Zamba inside your LXC container (default: tank)
 | 
			
		||||
LXC_SHAREFS_MOUNTPOINT="tank"
 | 
			
		||||
 | 
			
		||||
# Defines the amount of RAM in MB your LXC container is allowed to use (default: 1024)
 | 
			
		||||
LXC_MEM="1024"
 | 
			
		||||
 | 
			
		||||
# Defines the amount of swap space in MB your LXC container is allowed to use (default: 1024)
 | 
			
		||||
LXC_SWAP="1024"
 | 
			
		||||
 | 
			
		||||
# Defines the hostname of your LXC container
 | 
			
		||||
LXC_HOSTNAME="zamba"
 | 
			
		||||
 | 
			
		||||
# Defines the domain name / search domain of your LXC container
 | 
			
		||||
LXC_DOMAIN="zmb.rocks"
 | 
			
		||||
 | 
			
		||||
# Enable DHCP on LAN (eth0) - (Obtain an IP address automatically) [true/false]
 | 
			
		||||
LXC_DHCP=false
 | 
			
		||||
 | 
			
		||||
# Defines the local IP address and subnet of your LXC container in CIDR format
 | 
			
		||||
LXC_IP="192.168.100.200/24"
 | 
			
		||||
 | 
			
		||||
# Defines the default gateway IP address of your LXC container
 | 
			
		||||
LXC_GW="192.168.100.254"
 | 
			
		||||
 | 
			
		||||
# Defines the DNS server ip address of your LXC container
 | 
			
		||||
# `zmb-ad` used this DNS server for installation, after installation and domain provisioning it will be used as forwarding DNS
 | 
			
		||||
# For other services this should be your active directory domain controller (if present, else a DNS server of your choice)
 | 
			
		||||
LXC_DNS="192.168.100.254"
 | 
			
		||||
 | 
			
		||||
# Defines the network bridge to bind the network adapter of your LXC container
 | 
			
		||||
LXC_BRIDGE="vmbr0"
 | 
			
		||||
 | 
			
		||||
# Defines the vlan id of the LXC container's network interface, if the network adapter should be connected untagged, just leave the value empty.
 | 
			
		||||
LXC_VLAN=
 | 
			
		||||
 | 
			
		||||
# Defines the `root` password of your LXC container. Please use 'single quatation marks' to avoid unexpected behaviour.
 | 
			
		||||
LXC_PWD='S3cr3tp@ssw0rd'
 | 
			
		||||
 | 
			
		||||
# Defines an authorized_keys file to push into the LXC container.
 | 
			
		||||
# By default the authorized_keys will be inherited from your proxmox host.
 | 
			
		||||
LXC_AUTHORIZED_KEY=~/.ssh/authorized_keys
 | 
			
		||||
 | 
			
		||||
# Define your (administrative) tools, you always want to have installed into your LXC container
 | 
			
		||||
LXC_TOOLSET="vim htop net-tools dnsutils mc sysstat lsb-release curl git gnupg2 apt-transport-https"
 | 
			
		||||
 | 
			
		||||
# Define the local timezone of your LXC container (default: Euroe/Berlin)
 | 
			
		||||
LXC_TIMEZONE="Europe/Berlin"
 | 
			
		||||
 | 
			
		||||
# Define system language on LXC container (locales)
 | 
			
		||||
LXC_LOCALE=de_DE.UTF-8
 | 
			
		||||
 | 
			
		||||
# Set dark background for vim syntax highlighting (0 or 1)
 | 
			
		||||
LXC_VIM_BG_DARK=1
 | 
			
		||||
 | 
			
		||||
############### Zamba-Server-Section ###############
 | 
			
		||||
 | 
			
		||||
# Defines the REALM for the Active Directory (AD DC, AD member)
 | 
			
		||||
# IMPORTANT NOTE: ZMB_REALM is case sensitive and the value needs to be written completely in capital letters, otherwise Kerberos will fail
 | 
			
		||||
ZMB_REALM="ZMB.ROCKS"
 | 
			
		||||
# Defines the domain name in your Active Directory or Workgroup (AD DC, AD member, standalone)
 | 
			
		||||
# IMPORTANT NOTE: ZMB_DOMAIN is case sensitive and the value needs to be written completely in capital letters
 | 
			
		||||
ZMB_DOMAIN="ZMB"
 | 
			
		||||
 | 
			
		||||
# Defines the name of your domain administrator account (AD DC, AD member, standalone)
 | 
			
		||||
ZMB_ADMIN_USER="administrator"
 | 
			
		||||
# The admin password for zamba installation. Please use 'single quatation marks' to avoid unexpected behaviour
 | 
			
		||||
# `zmb-ad` domain administrator has to meet the password complexity policy, if password is too weak, domain provisioning will fail
 | 
			
		||||
ZMB_ADMIN_PASS='1c@nd0@nyth1n9'
 | 
			
		||||
 | 
			
		||||
# Defines the name of your Zamba share
 | 
			
		||||
ZMB_SHARE="share"
 | 
			
		||||
 | 
			
		||||
############### Mailpiler-Section ###############
 | 
			
		||||
 | 
			
		||||
# Defines the (public) FQDN of your piler mail archive
 | 
			
		||||
PILER_FQDN="piler.zmb.rocks"
 | 
			
		||||
# Defines the smarthost for piler mail archive
 | 
			
		||||
PILER_SMARTHOST="your.mailserver.tld"
 | 
			
		||||
 | 
			
		||||
############### Matrix-Section ###############
 | 
			
		||||
 | 
			
		||||
# Define the FQDN of your Matrix server
 | 
			
		||||
MATRIX_FQDN="matrix.zmb.rocks"
 | 
			
		||||
 | 
			
		||||
# Define the FQDN for the Element Web virtual host
 | 
			
		||||
MATRIX_ELEMENT_FQDN="element.zmb.rocks"
 | 
			
		||||
 | 
			
		||||
# Define the FQDN for the Jitsi Meet virtual host
 | 
			
		||||
MATRIX_JITSI_FQDN="meet.zmb.rocks"
 | 
			
		||||
							
								
								
									
										119
									
								
								archive/zmb-ad.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								archive/zmb-ad.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,119 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
source /root/zamba.conf
 | 
			
		||||
 | 
			
		||||
sed -i "s|# $LXC_LOCALE|$LXC_LOCALE|" /etc/locale.gen
 | 
			
		||||
cat << EOF > /etc/default/locale
 | 
			
		||||
LANG="$LXC_LOCALE"
 | 
			
		||||
LANGUAGE=$LXC_LOCALE
 | 
			
		||||
EOF
 | 
			
		||||
locale-gen $LXC_LOCALE
 | 
			
		||||
 | 
			
		||||
if [[ $ZMB_DNS_BACKEND == "BIND9_DLZ" ]]; then
 | 
			
		||||
  BINDNINE=bind9
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
## configure ntp
 | 
			
		||||
cat << EOF > /etc/ntp.conf
 | 
			
		||||
# Local clock. Note that is not the "localhost" address!
 | 
			
		||||
server 127.127.1.0
 | 
			
		||||
fudge  127.127.1.0 stratum 10
 | 
			
		||||
 | 
			
		||||
# Where to retrieve the time from
 | 
			
		||||
server 0.de.pool.ntp.org     iburst prefer
 | 
			
		||||
server 1.de.pool.ntp.org     iburst prefer
 | 
			
		||||
server 2.de.pool.ntp.org     iburst prefer
 | 
			
		||||
 | 
			
		||||
driftfile       /var/lib/ntp/ntp.drift
 | 
			
		||||
logfile         /var/log/ntp
 | 
			
		||||
ntpsigndsocket  /usr/local/samba/var/lib/ntp_signd/
 | 
			
		||||
 | 
			
		||||
# Access control
 | 
			
		||||
# Default restriction: Allow clients only to query the time
 | 
			
		||||
restrict default kod nomodify notrap nopeer mssntp
 | 
			
		||||
 | 
			
		||||
# No restrictions for "localhost"
 | 
			
		||||
restrict 127.0.0.1
 | 
			
		||||
 | 
			
		||||
# Enable the time sources to only provide time to this host
 | 
			
		||||
restrict 0.pool.ntp.org   mask 255.255.255.255    nomodify notrap nopeer noquery
 | 
			
		||||
restrict 1.pool.ntp.org   mask 255.255.255.255    nomodify notrap nopeer noquery
 | 
			
		||||
restrict 2.pool.ntp.org   mask 255.255.255.255    nomodify notrap nopeer noquery
 | 
			
		||||
 | 
			
		||||
tinker panic 0
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
# update packages
 | 
			
		||||
apt update
 | 
			
		||||
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -y -qq dist-upgrade
 | 
			
		||||
# install required packages
 | 
			
		||||
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" $LXC_TOOLSET acl attr ntpdate nginx-full rpl net-tools dnsutils ntp samba smbclient winbind libpam-winbind libnss-winbind krb5-user samba-dsdb-modules samba-vfs-modules lmdb-utils $BINDNINE
 | 
			
		||||
 | 
			
		||||
if [[ $ZMB_DNS_BACKEND == "BIND9_DLZ" ]]; then
 | 
			
		||||
  # configure bind dns service
 | 
			
		||||
  cat << EOF > /etc/default/bind9
 | 
			
		||||
#
 | 
			
		||||
# run resolvconf?
 | 
			
		||||
RESOLVCONF=no
 | 
			
		||||
 | 
			
		||||
# startup options for the server
 | 
			
		||||
OPTIONS="-4 -u bind"
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
cat << EOF > /etc/bind/named.conf.local
 | 
			
		||||
//
 | 
			
		||||
// Do any local configuration here
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
// Consider adding the 1918 zones here, if they are not used in your
 | 
			
		||||
// organization
 | 
			
		||||
//include "/etc/bind/zones.rfc1918";
 | 
			
		||||
dlz "$LXC_DOMAIN" {
 | 
			
		||||
  database "dlopen /usr/lib/x86_64-linux-gnu/samba/bind9/dlz_bind9_11.so";
 | 
			
		||||
};
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
  cat << EOF > /etc/bind/named.conf.options
 | 
			
		||||
options {
 | 
			
		||||
  directory "/var/cache/bind";
 | 
			
		||||
 | 
			
		||||
  forwarders {
 | 
			
		||||
    $LXC_DNS;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  allow-query {  any;};
 | 
			
		||||
  dnssec-validation no;
 | 
			
		||||
 | 
			
		||||
  auth-nxdomain no;    # conform to RFC1035
 | 
			
		||||
  listen-on-v6 { any; };
 | 
			
		||||
  listen-on { any; };
 | 
			
		||||
 | 
			
		||||
  tkey-gssapi-keytab "/var/lib/samba/bind-dns/dns.keytab";
 | 
			
		||||
  minimal-responses yes;
 | 
			
		||||
};
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
  mkdir -p /var/lib/samba/bind-dns/dns
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# stop + disable samba services and remove default config
 | 
			
		||||
systemctl stop smbd nmbd winbind
 | 
			
		||||
systemctl disable smbd nmbd winbind
 | 
			
		||||
rm -f /etc/samba/smb.conf
 | 
			
		||||
rm -f /etc/krb5.conf
 | 
			
		||||
 | 
			
		||||
# provision zamba domain
 | 
			
		||||
samba-tool domain provision --use-rfc2307 --realm=$ZMB_REALM --domain=$ZMB_DOMAIN --adminpass=$ZMB_ADMIN_PASS --server-role=dc --backend-store=mdb --dns-backend=$ZMB_DNS_BACKEND
 | 
			
		||||
 | 
			
		||||
cp /var/lib/samba/private/krb5.conf /etc/krb5.conf
 | 
			
		||||
 | 
			
		||||
systemctl unmask samba-ad-dc
 | 
			
		||||
systemctl enable samba-ad-dc $BINDNINE
 | 
			
		||||
systemctl restart samba-ad-dc $BINDNINE
 | 
			
		||||
 | 
			
		||||
exit 0
 | 
			
		||||
							
								
								
									
										113
									
								
								archive/zmb-member.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								archive/zmb-member.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
source /root/zamba.conf
 | 
			
		||||
 | 
			
		||||
sed -i "s|# $LXC_LOCALE|$LXC_LOCALE|" /etc/locale.gen
 | 
			
		||||
cat << EOF > /etc/default/locale
 | 
			
		||||
LANG="$LXC_LOCALE"
 | 
			
		||||
LANGUAGE=$LXC_LOCALE
 | 
			
		||||
EOF
 | 
			
		||||
locale-gen $LXC_LOCALE
 | 
			
		||||
 | 
			
		||||
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 acl samba winbind libpam-winbind libnss-winbind krb5-user krb5-config samba-dsdb-modules samba-vfs-modules 
 | 
			
		||||
 | 
			
		||||
mv /etc/krb5.conf /etc/krb5.conf.bak
 | 
			
		||||
cat > /etc/krb5.conf <<EOF
 | 
			
		||||
[libdefaults]
 | 
			
		||||
	default_realm = $ZMB_REALM
 | 
			
		||||
    ticket_lifetime = 600
 | 
			
		||||
	dns_lookup_realm = true
 | 
			
		||||
	dns_lookup_kdc = true
 | 
			
		||||
	renew_lifetime = 7d
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
echo -e "$ZMB_ADMIN_PASS" | kinit -V $ZMB_ADMIN_USER
 | 
			
		||||
klist
 | 
			
		||||
 | 
			
		||||
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
 | 
			
		||||
cat > /etc/samba/smb.conf <<EOF
 | 
			
		||||
[global]
 | 
			
		||||
	workgroup = $ZMB_DOMAIN
 | 
			
		||||
	security = ADS
 | 
			
		||||
	realm = $ZMB_REALM
 | 
			
		||||
	server string = %h server
 | 
			
		||||
 | 
			
		||||
	vfs objects = acl_xattr shadow_copy2
 | 
			
		||||
    map acl inherit = Yes
 | 
			
		||||
    store dos attributes = Yes
 | 
			
		||||
	idmap config *:backend = tdb
 | 
			
		||||
	idmap config *:range = 3000000-4000000
 | 
			
		||||
	idmap config *:schema_mode = rfc2307
 | 
			
		||||
 | 
			
		||||
	winbind refresh tickets = Yes
 | 
			
		||||
	winbind use default domain = Yes
 | 
			
		||||
	winbind separator = /
 | 
			
		||||
	winbind nested groups = yes
 | 
			
		||||
	winbind nss info = rfc2307
 | 
			
		||||
 | 
			
		||||
	pam password change = Yes
 | 
			
		||||
	passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
 | 
			
		||||
	passwd program = /usr/bin/passwd %u
 | 
			
		||||
 | 
			
		||||
	template homedir = /home/%U
 | 
			
		||||
	template shell = /bin/bash
 | 
			
		||||
	bind interfaces only = Yes
 | 
			
		||||
	interfaces = lo eth0
 | 
			
		||||
	log file = /var/log/samba/log.%m
 | 
			
		||||
	logging = syslog
 | 
			
		||||
	max log size = 1000
 | 
			
		||||
	panic action = /usr/share/samba/panic-action %d
 | 
			
		||||
 | 
			
		||||
	load printers = No
 | 
			
		||||
	printcap name = /dev/null
 | 
			
		||||
	printing = bsd
 | 
			
		||||
	disable spoolss = Yes
 | 
			
		||||
 | 
			
		||||
	allow trusted domains = No
 | 
			
		||||
	dns proxy = No
 | 
			
		||||
	shadow: snapdir = .zfs/snapshot
 | 
			
		||||
	shadow: sort = desc
 | 
			
		||||
	shadow: format = -%Y-%m-%d-%H%M
 | 
			
		||||
	shadow: snapprefix = ^zfs-auto-snap_\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}
 | 
			
		||||
	shadow: delimiter = -20
 | 
			
		||||
 | 
			
		||||
[$ZMB_SHARE]
 | 
			
		||||
	comment = Main Share
 | 
			
		||||
	path = /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
	read only = No
 | 
			
		||||
	create mask = 0660
 | 
			
		||||
	directory mask = 0770
 | 
			
		||||
	inherit acls = Yes
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
systemctl restart smbd
 | 
			
		||||
 | 
			
		||||
echo -e "$ZMB_ADMIN_PASS" | net ads join -U $ZMB_ADMIN_USER createcomputer=Computers
 | 
			
		||||
sed -i "s|files systemd|files systemd winbind|g" /etc/nsswitch.conf
 | 
			
		||||
sed -i "s|#WINBINDD_OPTS=|WINBINDD_OPTS=|" /etc/default/winbind
 | 
			
		||||
echo -e "session optional        pam_mkhomedir.so skel=/etc/skel umask=077" >> /etc/pam.d/common-session
 | 
			
		||||
 | 
			
		||||
systemctl restart winbind nmbd
 | 
			
		||||
wbinfo -u
 | 
			
		||||
wbinfo -g
 | 
			
		||||
 | 
			
		||||
mkdir /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
 | 
			
		||||
# originally 'domain users' was set, added variable for domain admins group, samba wiki recommends separate group e.g. 'unix admins'
 | 
			
		||||
chown "$ZMB_ADMIN_USER" /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
 | 
			
		||||
setfacl -Rm u:$ZMB_ADMIN_USER:rwx,g::-,o::- /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
setfacl -Rdm u:$ZMB_ADMIN_USER:rwx,g::-,o::- /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
 | 
			
		||||
systemctl restart smbd nmbd winbind
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										44
									
								
								archive/zmb-standalone.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								archive/zmb-standalone.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
# Authors:
 | 
			
		||||
# (C) 2021 Idea an concept by Christian Zengel <christian@sysops.de>
 | 
			
		||||
# (C) 2021 Script design and prototype by Markus Helmke <m.helmke@nettwarker.de>
 | 
			
		||||
# (C) 2021 Script rework and documentation by Thorsten Spille <thorsten@spille-edv.de>
 | 
			
		||||
 | 
			
		||||
source /root/zamba.conf
 | 
			
		||||
 | 
			
		||||
sed -i "s|# $LXC_LOCALE|$LXC_LOCALE|" /etc/locale.gen
 | 
			
		||||
cat << EOF > /etc/default/locale
 | 
			
		||||
LANG="$LXC_LOCALE"
 | 
			
		||||
LANGUAGE=$LXC_LOCALE
 | 
			
		||||
EOF
 | 
			
		||||
locale-gen $LXC_LOCALE
 | 
			
		||||
 | 
			
		||||
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 acl samba samba-dsdb-modules samba-vfs-modules 
 | 
			
		||||
 | 
			
		||||
USER=$(echo "$ZMB_ADMIN_USER" | awk '{print tolower($0)}')
 | 
			
		||||
useradd --comment "Zamba fileserver admin" --create-home --shell /bin/bash $USER
 | 
			
		||||
echo "$USER:$ZMB_ADMIN_PASS" | chpasswd
 | 
			
		||||
smbpasswd -x $USER
 | 
			
		||||
(echo $ZMB_ADMIN_PASS; echo $ZMB_ADMIN_PASS) | smbpasswd -a $USER
 | 
			
		||||
 | 
			
		||||
cat << EOF >> /etc/samba/smb.conf
 | 
			
		||||
[$ZMB_SHARE]
 | 
			
		||||
    comment = Main Share
 | 
			
		||||
    path = /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
    read only = No
 | 
			
		||||
    vfs objects = shadow_copy2
 | 
			
		||||
    shadow: snapdir = .zfs/snapshot
 | 
			
		||||
    shadow: sort = desc
 | 
			
		||||
    shadow: format = -%Y-%m-%d-%H%M
 | 
			
		||||
    shadow: snapprefix = ^zfs-auto-snap_\(frequent\)\{0,1\}\(hourly\)\{0,1\}\(daily\)\{0,1\}\(monthly\)\{0,1\}
 | 
			
		||||
    shadow: delimiter = -20
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
mkdir -p /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
chmod -R 770 /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
chown -R $USER:root /$LXC_SHAREFS_MOUNTPOINT/$ZMB_SHARE
 | 
			
		||||
 | 
			
		||||
systemctl restart smbd nmbd 
 | 
			
		||||
		Reference in New Issue
	
	Block a user