mirror of
https://github.com/bashclub/zamba-lxc-toolbox.git
synced 2024-12-25 03:30:12 +01:00
Optimized code
This commit is contained in:
parent
06d6d03445
commit
4b927bf5a5
84
install.sh
84
install.sh
@ -20,9 +20,7 @@
|
|||||||
source ./zamba.conf
|
source ./zamba.conf
|
||||||
|
|
||||||
# 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_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_REP=$(pveam available --section system | grep debian-10-standard | cut -d'_' -f2)
|
||||||
|
|
||||||
if [[ $DEB_LOC == $DEB_REP ]];
|
if [[ $DEB_LOC == $DEB_REP ]];
|
||||||
@ -42,19 +40,19 @@ if [ $LXC_CHK -lt 100 ] || [ -f /etc/pve/qemu-server/$LXC_CHK.conf ]; then
|
|||||||
else
|
else
|
||||||
LXC_NBR=$LXC_CHK;
|
LXC_NBR=$LXC_CHK;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Will now create LXC Container $LXC_NBR!";
|
echo "Will now create LXC Container $LXC_NBR!";
|
||||||
|
|
||||||
# Create the container
|
# 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/debian-10-standard_$DEB_REP\_amd64.tar.gz -rootfs $LXC_ROOTFS_STORAGE:$LXC_ROOTFS_SIZE;
|
||||||
sleep 2;
|
sleep 2;
|
||||||
|
|
||||||
|
# Check vlan configuration
|
||||||
if [[ $LXC_VLAN != "" ]];then
|
if [[ $LXC_VLAN != "" ]];then
|
||||||
VLAN=",vlan=$LXC_VLAN"
|
VLAN=",vlan=$LXC_VLAN"
|
||||||
else
|
else
|
||||||
VLAN=""
|
VLAN=""
|
||||||
fi
|
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 Europe/Berlin -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 Europe/Berlin -net0 name=eth0,bridge=$LXC_BRIDGE,firewall=1,gw=$LXC_GW,ip=$LXC_IP,type=veth$VLAN;
|
||||||
sleep 2;
|
sleep 2;
|
||||||
|
|
||||||
@ -63,80 +61,56 @@ PS3="Select the Server-Function: "
|
|||||||
select opt in just_lxc zmb-standalone zmb-member zmb-pdc mailpiler matrix quit; do
|
select opt in just_lxc zmb-standalone zmb-member zmb-pdc mailpiler matrix quit; do
|
||||||
case $opt in
|
case $opt in
|
||||||
just_lxc)
|
just_lxc)
|
||||||
lxc-start $LXC_NBR;
|
echo "Debian-only LXC container selected"
|
||||||
sleep 5;
|
|
||||||
# Set the root password and key
|
|
||||||
echo -e "$LXC_PWD\n$LXC_PWD" | lxc-attach -n$LXC_NBR passwd;
|
|
||||||
lxc-attach -n$LXC_NBR mkdir /root/.ssh;
|
|
||||||
echo -e "$LXC_AUTHORIZED_KEY" | lxc-attach -n$LXC_NBR tee /root/.ssh/authorized_keys;
|
|
||||||
lxc-attach -n$LXC_NBR service ssh restart;
|
|
||||||
echo "Should be ready!"
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
zmb-standalone)
|
zmb-standalone)
|
||||||
break
|
echo "Selected Zamba standalone"
|
||||||
|
echo "This function is not implemented yet! Exiting..."
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
zmb-member)
|
zmb-member)
|
||||||
echo "Make some additions to LXC for AD-Member-Server!"
|
echo "Configuring LXC container '$opt'!"
|
||||||
pct set $LXC_NBR -mp0 $LXC_FILEFS_STORAGE:$LXC_FILEFS_SIZE,mp=/$LXC_FILEFS_MOUNTPOINT
|
pct set $LXC_NBR -mp0 $LXC_FILEFS_STORAGE:$LXC_FILEFS_SIZE,mp=/$LXC_FILEFS_MOUNTPOINT
|
||||||
sleep 2;
|
sleep 2;
|
||||||
lxc-start $LXC_NBR;
|
|
||||||
sleep 5;
|
|
||||||
# Set the root password and key
|
|
||||||
echo -e "$LXC_PWD\n$LXC_PWD" | lxc-attach -n$LXC_NBR passwd;
|
|
||||||
lxc-attach -n$LXC_NBR mkdir /root/.ssh;
|
|
||||||
echo -e "$LXC_AUTHORIZED_KEY" | lxc-attach -n$LXC_NBR tee /root/.ssh/authorized_keys;
|
|
||||||
lxc-attach -n$LXC_NBR service ssh restart;
|
|
||||||
cp /root/zmb_mem.orig /root/zmb_mem.sh
|
|
||||||
sed -i "s|#ZMB_VAR|#ZMB_VAR\nLXC_FILEFS_MOUNTPOINT='$LXC_FILEFS_MOUNTPOINT'\nZMB_SHARE='$ZMB_SHARE'\nZMB_REALM='$ZMB_REALM'\nZMB_DOMAIN='$ZMB_DOMAIN'\nZMB_ADMIN_USER='$ZMB_ADMIN_USER'\nZMB_ADMIN_PASS='$ZMB_ADMIN_PASS'\nZMB_DOMAIN_ADMINS_GROUP='$ZMB_DOMAIN_ADMINS_GROUP'|" /root/zmb_mem.sh
|
|
||||||
pct push $LXC_NBR /root/zmb_mem.sh /root/zmb_mem.sh
|
|
||||||
echo "Install zamba as AD-Member-Server!"
|
|
||||||
lxc-attach -n$LXC_NBR bash /root/zmb_mem.sh
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
zmb-pdc)
|
zmb-pdc)
|
||||||
break
|
echo "Selected Zamba AD DC"
|
||||||
|
echo "This function is not implemented yet! Exiting..."
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
mailpiler)
|
mailpiler)
|
||||||
echo "Make some additions to LXC for Mailpiler!"
|
echo "Configuring LXC container for '$opt'!"
|
||||||
pct set $LXC_NBR -features nesting=1
|
pct set $LXC_NBR -features nesting=1
|
||||||
sleep 2;
|
sleep 2;
|
||||||
lxc-start $LXC_NBR;
|
|
||||||
sleep 5;
|
|
||||||
# Set the root password and key
|
|
||||||
echo -e "$LXC_PWD\n$LXC_PWD" | lxc-attach -n$LXC_NBR passwd;
|
|
||||||
lxc-attach -n$LXC_NBR mkdir /root/.ssh;
|
|
||||||
echo -e "$LXC_AUTHORIZED_KEY" | lxc-attach -n$LXC_NBR tee /root/.ssh/authorized_keys;
|
|
||||||
lxc-attach -n$LXC_NBR service ssh restart;
|
|
||||||
cp /root/mailpiler.orig /root/mailpiler.sh
|
|
||||||
sed -i "s|#PILER_VAR|#PILER_VAR\nPILER_FQDN='$PILER_FQDN'\nPILER_SMARTHOST='$PILER_SMARTHOST'\nPILER_VERSION='$PILER_VERSION'\nPILER_SPHINX_VERSION='$PILER_SPHINX_VERSION'\nPILER_PHP_VERSION='$PILER_PHP_VERSION'|" /root/mailpiler.sh
|
|
||||||
pct push $LXC_NBR /root/mailpiler.sh /root/mailpiler.sh
|
|
||||||
echo "Install Mailpiler mailarchiv!"
|
|
||||||
lxc-attach -n$LXC_NBR bash mailpiler.sh
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
matrix)
|
matrix)
|
||||||
echo "Make some additions to LXC for Matrix!"
|
echo "Install Matrix chat server and element web service"
|
||||||
lxc-start $LXC_NBR;
|
|
||||||
sleep 5;
|
|
||||||
# Set the root password and key
|
|
||||||
echo -e "$LXC_PWD\n$LXC_PWD" | lxc-attach -n$LXC_NBR passwd;
|
|
||||||
lxc-attach -n$LXC_NBR mkdir /root/.ssh;
|
|
||||||
echo -e "$LXC_AUTHORIZED_KEY" | lxc-attach -n$LXC_NBR tee /root/.ssh/authorized_keys;
|
|
||||||
lxc-attach -n$LXC_NBR service ssh restart;
|
|
||||||
cp /root/matrix.orig /root/matrix.sh
|
|
||||||
sed -i "s|#MATRIX_VAR|#Matrix_VAR\nMATRIX_FQDN='$MATRIX_FQDN'\nMATRIX_ELEMENT_FQDN='$MATRIX_ELEMENT_FQDN'\nMATRIX_ELEMENT_VERSION='$MATRIX_ELEMENT_VERSION'\nMATRIX_JITSI_FQDN='$MATRIX_JITSI_FQDN'|" /root/matrix.sh
|
|
||||||
pct push $LXC_NBR /root/matrix.sh /root/matrix.sh
|
|
||||||
echo "Install Matrix Chatserver!"
|
|
||||||
lxc-attach -n$LXC_NBR bash matrix.sh
|
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
quit)
|
quit)
|
||||||
break
|
echo "Script aborted by user interaction."
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid option!"
|
echo "Invalid option! Exiting..."
|
||||||
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
lxc-start $LXC_NBR;
|
||||||
|
sleep 5;
|
||||||
|
# Set the root password and key
|
||||||
|
echo -e "$LXC_PWD\n$LXC_PWD" | lxc-attach -n$LXC_NBR passwd;
|
||||||
|
lxc-attach -n$LXC_NBR mkdir /root/.ssh;
|
||||||
|
echo -e "$LXC_AUTHORIZED_KEY" | lxc-attach -n$LXC_NBR tee /root/.ssh/authorized_keys;
|
||||||
|
# usually not needed after adding authorized_keys:
|
||||||
|
# lxc-attach -n$LXC_NBR systemctl restart ssh.service
|
||||||
|
pct push $LXC_NBR ./zamba.conf /root/zamba.conf
|
||||||
|
pct push $LXC_NBR ./$opt.sh /root/$opt.sh
|
||||||
|
echo "Install '$opt'!"
|
||||||
|
lxc-attach -n$LXC_NBR bash /root/$opt.sh
|
Loading…
Reference in New Issue
Block a user