added Config check for Timezone and Storages

modified  Hostname with Service PREFIX "${service}.zmbrocks"
fix       "pct set -timezone" # timezone switch added in Version 6.3 https://github.com/bashclub/zamba-lxc-toolbox/issues/29
added     Set "/root/summary" file from LXC-container as pct description
modified  updated Matrix Element Version
This commit is contained in:
Patrick Greiner 2021-08-06 22:00:09 +02:00
parent f5da57b487
commit 98b1bb77d3
5 changed files with 45 additions and 11 deletions

View File

@ -34,7 +34,7 @@ LXC_MEM="1024"
LXC_SWAP="1024"
# Defines the hostname of your LXC container
LXC_HOSTNAME="zamba"
LXC_HOSTNAME="${service}.zmbrocks"
# Defines the domain name / search domain of your LXC container
LXC_DOMAIN="zmb.rocks"

View File

@ -53,6 +53,27 @@ shift $((OPTIND-1))
echo "Loading config file '$config'..."
source $config
# Check config Settings
echo "Check Setting 'Timezone'"
if [[ $LXC_TIMEZONE != $(timedatectl list-timezones | grep $LXC_TIMEZONE) ]]; then
echo "Unknown LXC_TIMEZONE setting (list available Timezones 'timedatectl list-timezones')"; exit 0
fi
echo "Check Setting 'Template Storage'"
pvstorage=$(pvesh get storage --noborder --noheader);
if [[ $LXC_TEMPLATE_STORAGE != $(echo "$pvstorage" | grep $LXC_TEMPLATE_STORAGE$) ]]; then
echo "Unknown LXC_TEMPLATE_STORAGE, please check your storage name"; exit 0
fi
echo "Check Setting 'Rootfs Storage'"
if [[ $LXC_ROOTFS_STORAGE != $(echo "$pvstorage" | grep $LXC_ROOTFS_STORAGE$) ]]; then
echo "Unknown LXC_ROOTFS_STORAGE, please check your storage name"; exit 0
fi
echo "Check Setting 'Sharefs Storage'"
if [[ $LXC_SHAREFS_STORAGE != $(echo "$pvstorage" | grep $LXC_SHAREFS_STORAGE$) ]]; then
echo "Unknown LXC_SHAREFS_STORAGE, please check your storage name"; exit 0
fi
echo -e "Settings \e[0;92mOK\e[0m"
OPTS=$(ls -d $PWD/src/*/ | grep -v __ | xargs basename -a)
valid=0
@ -90,9 +111,11 @@ if [[ "$valid" != "1" ]]; then
usage 1
fi
source $config
source $PWD/src/$service/constants-service.conf
LXC_HOSTNAME="${LXC_HOSTNAME/-/}"
# CHeck is the newest template available, else download it.
# 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)
@ -124,13 +147,12 @@ pct create $LXC_NBR -unprivileged $LXC_UNPRIVILEGED $LXC_TEMPLATE_STORAGE:vztmpl
sleep 2;
# Check vlan configuration
if [[ $LXC_VLAN != "" ]];then
VLAN=",tag=$LXC_VLAN"
else
VLAN=""
fi
if [[ $LXC_VLAN != "" ]];then VLAN=",tag=$LXC_VLAN"; else VLAN=""; fi
# Reconfigure conatiner
pct set $LXC_NBR -memory $LXC_MEM -swap $LXC_SWAP -hostname $LXC_HOSTNAME -onboot 1 -timezone $LXC_TIMEZONE -features nesting=$LXC_NESTING;
PVE_VER=$(pveversion | grep 'pve-manager' | cut -d'/' -f2 | sed 's/[^0-9]//g')
pct set $LXC_NBR -memory $LXC_MEM -swap $LXC_SWAP -hostname $LXC_HOSTNAME -onboot 1 -features nesting=$LXC_NESTING;
# timezone switch added in Version 6.3
if [ $PVE_VER -gt 630 ];then pct set $LXC_NBR -timezone $LXC_TIMEZONE;fi
if [ $LXC_DHCP == true ]; then
pct set $LXC_NBR -net0 name=eth0,bridge=$LXC_BRIDGE,ip=dhcp,type=veth$VLAN;
else
@ -163,8 +185,14 @@ lxc-attach -n$LXC_NBR bash /root/lxc-base.sh
echo "Install '$service'!"
lxc-attach -n$LXC_NBR bash /root/install-service.sh
summary=$(pct exec $LXC_NBR -- bash -c '[ -f /root/summary ] && cat /root/summary')
if [[ $summary != "" ]];then pct set $LXC_NBR --description="$(echo -e "$summary")"; fi
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
# timezone switch added in Version 6.3
if [ $PVE_VER -lt 630 ]; then echo "echo "$LXC_TIMEZONE" > /etc/timezone" | pct enter $LXC_NBR; fi

View File

@ -17,4 +17,4 @@ LXC_UNPRIVILEGED="1"
LXC_NESTING="0"
# Define the version of Element Web
MATRIX_ELEMENT_VERSION="v1.7.25"
MATRIX_ELEMENT_VERSION="v1.7.34"

View File

@ -410,7 +410,10 @@ bash /$LXC_SHAREFS_MOUNTPOINT/$NEXTCLOUD_DATA/config_nextcloud.sh
EOF
echo "*/5 * * * * www-data /usr/bin/php -f /var/www/nextcloud/cron.php > /dev/null 2>&1" > /etc/cron.d/nextcloud
echo -e "\n######################################################################\n\n Please note this user and password for the nextcloud login:\n '$NEXTCLOUD_ADMIN_USR' / '$NEXTCLOUD_ADMIN_PWD'\n Enjoy your Nextcloud intallation.\n\n######################################################################"
echo "\n\n"
echo "######################################################################\n\n Please note this user and password for the nextcloud login:\n '$NEXTCLOUD_ADMIN_USR' / '$NEXTCLOUD_ADMIN_PWD'\n Enjoy your Nextcloud intallation.\n\n######################################################################" > /root/summary
echo -e "$(cat /root/summary)"
systemctl stop nginx php$NEXTCLOUD_PHP_VERSION-fpm
systemctl restart postgresql php$NEXTCLOUD_PHP_VERSION-fpm redis-server nginx

View File

@ -52,4 +52,7 @@ chmod +x /etc/cron.daily/open3a-backup
systemctl enable --now php7.3-fpm
systemctl restart nginx
echo -e "Your open3a installation is now complete. Please continue with setup in your Browser:\nURL:\t\thttp://$LXC_IP\nLogin:\t\tAdmin\nPassword:\tAdmin\n\nMysql-Settings:\nServer:\t\tlocalhost\nUser:\t\topen3a\nPassword:\t$MYSQL_PASSWORD\nDatabase:\topen3a"
echo "Your open3a installation is now complete. Please continue with setup in your Browser:\nURL:\t\thttp://$LXC_IP\nLogin:\t\tAdmin\nPassword:\tAdmin\n\nMysql-Settings:\nServer:\t\tlocalhost\nUser:\t\topen3a\nPassword:\t$MYSQL_PASSWORD\nDatabase:\topen3a" > /root/summary
echo -e "$(cat /root/summary)"
exit 0