create-lx-container.sh: Add support for 'Ubuntu' guest system.
This commit is contained in:
parent
1ad01fb5fe
commit
4beab46951
@ -364,6 +364,7 @@ while ! $(is_valid_ipv4 $IPV4_ADDRESS_1); do
|
|||||||
done
|
done
|
||||||
_octets=( ${IPV4_ADDRESS_1//\./ } )
|
_octets=( ${IPV4_ADDRESS_1//\./ } )
|
||||||
DEFAULT_IPV4_GATEWAY_1="${_octets[0]}.${_octets[1]}.${_octets[2]}.1"
|
DEFAULT_IPV4_GATEWAY_1="${_octets[0]}.${_octets[1]}.${_octets[2]}.1"
|
||||||
|
DEFAULT_IPV4_NAME_SERVER_1="${_octets[0]}.${_octets[1]}.${_octets[2]}.1"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[32m--\033[m"
|
echo -e "\033[32m--\033[m"
|
||||||
@ -412,14 +413,15 @@ IPV4_PREFIX_1="$(netmask2cidr $IPV4_NETMASK_1)"
|
|||||||
IPV6_PREFIX_1=$DEFAULT_IPV6_PREFIX
|
IPV6_PREFIX_1=$DEFAULT_IPV6_PREFIX
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
echo -e "\033[32m--\033[m"
|
echo ""
|
||||||
echo ""
|
echo -e "\033[32m--\033[m"
|
||||||
echononl "\033[1mDo you want to apply a second IPv4 Address?\033[m [yes/no]: "
|
echo ""
|
||||||
read OK
|
echononl "\033[1mDo you want to apply a second IPv4 Address?\033[m [yes/no]: "
|
||||||
[[ "$(trim ${OK,,})" = "yes" ]] && _second_ipv4=true || _second_ipv4=false
|
read OK
|
||||||
|
[[ "$(trim ${OK,,})" = "yes" ]] && _second_ipv4=true || _second_ipv4=false
|
||||||
|
|
||||||
if $_second_ipv4 ; then
|
if $_second_ipv4 ; then
|
||||||
|
|
||||||
_last_octet=${MAC_ADDRESS_1: -2}
|
_last_octet=${MAC_ADDRESS_1: -2}
|
||||||
_new_last_octet="$(printf "%X\n" $((0x$_last_octet + 1)))"
|
_new_last_octet="$(printf "%X\n" $((0x$_last_octet + 1)))"
|
||||||
@ -500,7 +502,7 @@ if $_second_ipv4 ; then
|
|||||||
echo -e "\033[32m--\033[m"
|
echo -e "\033[32m--\033[m"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
echo " # Insert Netmask for the first IPv4 Address."
|
echo " # Insert Netmask for the second IPv4 Address."
|
||||||
echo " #"
|
echo " #"
|
||||||
echo " # Type <return> to accept the default one"
|
echo " # Type <return> to accept the default one"
|
||||||
echo ""
|
echo ""
|
||||||
@ -519,7 +521,53 @@ if $_second_ipv4 ; then
|
|||||||
done
|
done
|
||||||
IPV4_PREFIX_2="$(netmask2cidr $IPV4_NETMASK_2)"
|
IPV4_PREFIX_2="$(netmask2cidr $IPV4_NETMASK_2)"
|
||||||
IPV6_PREFIX_2=$DEFAULT_IPV6_PREFIX
|
IPV6_PREFIX_2=$DEFAULT_IPV6_PREFIX
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
else # if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo " # Insert Nameserver for the first IPv4 Address."
|
||||||
|
echo " #"
|
||||||
|
echo " # Type <return> to accept the default one"
|
||||||
|
echo ""
|
||||||
|
echononl "\033[1mNameserver (IPv4 Address) [$DEFAULT_IPV4_NAME_SERVER_1]:\033[m "
|
||||||
|
read IPV4_NAME_SERVER_1
|
||||||
|
|
||||||
|
while ! $(is_valid_ipv4 $IPV4_NAME_SERVER_1) ; do
|
||||||
|
if [[ -z "$(trim $IPV4_NAME_SERVER_1)" ]]; then
|
||||||
|
IPV4_NAME_SERVER_1="$DEFAULT_IPV4_NAME_SERVER_1"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "'$IPV4_NAME_SERVER_1' is not a valid IPv4 address. Try again.."
|
||||||
|
fi
|
||||||
|
echononl "\033[1mNameserver (IPv4 Address) [$DEFAULT_IPV4_NAME_SERVER_1]:\033[m "
|
||||||
|
read IPV4_NAME_SERVER_1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
echo " # Insert Search Domain for the new LX Containers."
|
||||||
|
echo " #"
|
||||||
|
echo -e " # Type \033[33mNone\033[m if no search domain should be assigned"
|
||||||
|
echo " #"
|
||||||
|
echo ""
|
||||||
|
echononl "\033[1mSearch Domain:\033[m "
|
||||||
|
read SEARCH_DOMAIN
|
||||||
|
|
||||||
|
while [[ -z "$(trim $SEARCH_DOMAIN)" ]]; do
|
||||||
|
warn "Parameter is needed. Try again.."
|
||||||
|
echononl "\033[1mSEARCH_DOMAIN:\033[m "
|
||||||
|
read SEARCH_DOMAIN
|
||||||
|
done
|
||||||
|
if [[ "${SEARCH_DOMAIN,,}" = 'none' ]] ; then
|
||||||
|
IPV6_ADDRESS_1=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi # if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[32m--\033[m"
|
echo -e "\033[32m--\033[m"
|
||||||
@ -749,8 +797,28 @@ msg="Create Lx Container '$LXC_NAME' .."
|
|||||||
length_msg=${#msg}
|
length_msg=${#msg}
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
lxc-create -n $LXC_NAME -t $LXC_DIST -P "$(dirname "$LXC_CONTAINER_DIR")" -- \
|
if [[ "$LXC_DIST" = "ubuntu" ]] ; then
|
||||||
|
lxc-create -n $LXC_NAME -t download -P "$(dirname "$LXC_CONTAINER_DIR")" -- \
|
||||||
|
-d $LXC_DIST --release $LXC_RELEASE --arch amd64 > /dev/null 2> $err_msg
|
||||||
|
elif [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
lxc-create -n $LXC_NAME -t $LXC_DIST -P "$(dirname "$LXC_CONTAINER_DIR")" -- \
|
||||||
--release $LXC_RELEASE --arch amd64 > /dev/null 2> $err_msg
|
--release $LXC_RELEASE --arch amd64 > /dev/null 2> $err_msg
|
||||||
|
else
|
||||||
|
msg_failed="Creation of Lx Container '$LXC_NAME' failed!"
|
||||||
|
length_msg_failed=${#msg_failed}
|
||||||
|
blank_signs=""
|
||||||
|
if [[ $length_msg -gt $length_msg_failed ]]; then
|
||||||
|
number_blank_sign=$(expr $length_msg - $length_msg_failed)
|
||||||
|
index_i=0
|
||||||
|
while [[ $index_i -lt $number_blank_sign ]] ; do
|
||||||
|
blank_signs="$blank_signs "
|
||||||
|
(( index_i++ ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
|
echo ""
|
||||||
|
fatal "Linux distribution \033[1m${LXC_DIST}\033[m is NOT supported!"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
msg_ok="Lx Container 'LXC_NAME' created."
|
msg_ok="Lx Container 'LXC_NAME' created."
|
||||||
@ -831,15 +899,16 @@ if [[ "$(dirname "$LXC_CONTAINER_DIR")" != "$LXC_ROOT_DIR" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# - Create an empty fstab '${LXC_CONTAINER_DIR}/fstab'
|
if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
# -
|
# - Create an empty fstab '${LXC_CONTAINER_DIR}/fstab'
|
||||||
msg="Create an empty file '${LXC_CONTAINER_DIR}/fstab' .."
|
# -
|
||||||
length_msg=${#msg}
|
msg="Create an empty file '${LXC_CONTAINER_DIR}/fstab' .."
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
length_msg=${#msg}
|
||||||
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
touch ${LXC_CONTAINER_DIR}/fstab > /dev/null 2>$err_msg
|
touch ${LXC_CONTAINER_DIR}/fstab > /dev/null 2>$err_msg
|
||||||
|
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
msg_ok="Empty file '${LXC_CONTAINER_DIR}' created."
|
msg_ok="Empty file '${LXC_CONTAINER_DIR}' created."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -852,7 +921,7 @@ if [[ $? -eq 0 ]] ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
else
|
else
|
||||||
msg_failed="Creation of (empty) file '${LXC_CONTAINER_DIR}/fstab' failed!"
|
msg_failed="Creation of (empty) file '${LXC_CONTAINER_DIR}/fstab' failed!"
|
||||||
length_msg_failed=${#msg_failed}
|
length_msg_failed=${#msg_failed}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -866,6 +935,7 @@ else
|
|||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - Backup original configuration file
|
# - Backup original configuration file
|
||||||
@ -905,13 +975,16 @@ else
|
|||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - Create the Container configuration file
|
|
||||||
# -
|
|
||||||
msg="Create Container Configuration '${LXC_CONTAINER_DIR}/config (LXC Version $LXC_VERSION)' .."
|
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
|
||||||
|
|
||||||
_failed=false
|
|
||||||
if [[ $LXC_MAJOR_VERSION -lt 3 ]]; then
|
if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
# - Create the Container configuration file
|
||||||
|
# -
|
||||||
|
msg="Create Container Configuration '${LXC_CONTAINER_DIR}/config (LXC Version $LXC_VERSION)' .."
|
||||||
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
|
_failed=false
|
||||||
|
if [[ $LXC_MAJOR_VERSION -lt 3 ]]; then
|
||||||
cat << EOF > ${LXC_CONTAINER_DIR}/config 2> $err_msg
|
cat << EOF > ${LXC_CONTAINER_DIR}/config 2> $err_msg
|
||||||
lxc.rootfs = ${LXC_CONTAINER_DIR}/rootfs
|
lxc.rootfs = ${LXC_CONTAINER_DIR}/rootfs
|
||||||
|
|
||||||
@ -984,9 +1057,7 @@ EOF
|
|||||||
_failed=true
|
_failed=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cat << EOF > ${LXC_CONTAINER_DIR}/config 2> $err_msg
|
cat << EOF > ${LXC_CONTAINER_DIR}/config 2> $err_msg
|
||||||
lxc.rootfs.path = ${LXC_CONTAINER_DIR}/rootfs
|
lxc.rootfs.path = ${LXC_CONTAINER_DIR}/rootfs
|
||||||
@ -1060,10 +1131,10 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ $LXC_MAJOR_VERSION -lt 3 ]]; then
|
if [[ $LXC_MAJOR_VERSION -lt 3 ]]; then
|
||||||
cat << EOF >> ${LXC_CONTAINER_DIR}/config 2>> $err_msg
|
cat << EOF >> ${LXC_CONTAINER_DIR}/config 2>> $err_msg
|
||||||
|
|
||||||
# Mount iso file inside LX Container
|
# Mount iso file inside LX Container
|
||||||
@ -1084,7 +1155,7 @@ EOF
|
|||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
_failed=true
|
_failed=true
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
cat << EOF >> ${LXC_CONTAINER_DIR}/config 2>> $err_msg
|
cat << EOF >> ${LXC_CONTAINER_DIR}/config 2>> $err_msg
|
||||||
|
|
||||||
# Mount iso file inside LX Container
|
# Mount iso file inside LX Container
|
||||||
@ -1150,9 +1221,9 @@ EOF
|
|||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
_failed=true
|
_failed=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $_failed ; then
|
if $_failed ; then
|
||||||
msg_failed="Creation of '${LXC_CONTAINER_DIR}/config' failed!"
|
msg_failed="Creation of '${LXC_CONTAINER_DIR}/config' failed!"
|
||||||
length_msg_failed=${#msg_failed}
|
length_msg_failed=${#msg_failed}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1166,7 +1237,7 @@ if $_failed ; then
|
|||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
else
|
else
|
||||||
msg_ok="Container Configuration '${LXC_CONTAINER_DIR}/config' created."
|
msg_ok="Container Configuration '${LXC_CONTAINER_DIR}/config' created."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1179,6 +1250,167 @@ else
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
|
fi
|
||||||
|
else # if [[ "$LXC_DIST" = "debian" ]];
|
||||||
|
|
||||||
|
msg="Adjust Container configuration file '${LXC_CONTAINER_DIR}/config' .."
|
||||||
|
length_msg=${#msg}
|
||||||
|
_failed=false
|
||||||
|
|
||||||
|
echo -en "\033[1G \033[1;30m[ \033[5m\033[1m...\033[m ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
|
sed -i '/\s*lxc.net.0.type\s*=/d' ${LXC_CONTAINER_DIR}/config > /dev/null 2>$err_msg
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> ${LXC_CONTAINER_DIR}/config 2>>$err_msg
|
||||||
|
### Device 1
|
||||||
|
lxc.net.0.type = veth
|
||||||
|
lxc.net.0.flags = up
|
||||||
|
lxc.net.0.link = br0
|
||||||
|
lxc.net.0.name = eth0
|
||||||
|
lxc.net.0.hwaddr = $MAC_ADDRESS_1
|
||||||
|
EOF
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$IPV4_ADDRESS_2" ]]; then
|
||||||
|
cat << EOF >> ${LXC_CONTAINER_DIR}/config 2>> $err_msg
|
||||||
|
|
||||||
|
### Device 2
|
||||||
|
lxc.net.1.type = veth
|
||||||
|
lxc.net.1.flags = up
|
||||||
|
lxc.net.1.link = br0
|
||||||
|
lxc.net.1.name = eth1
|
||||||
|
lxc.net.1.hwaddr = $MAC_ADDRESS_2
|
||||||
|
EOF
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
_failed=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $LXC_MAJOR_VERSION -lt 3 ]]; then
|
||||||
|
cat << EOF >> ${LXC_CONTAINER_DIR}/config 2>> $err_msg
|
||||||
|
|
||||||
|
# Mount iso file inside LX Container
|
||||||
|
#lxc.aa_profile = unconfined
|
||||||
|
#lxc.cgroup.devices.allow = b 7:* rwm
|
||||||
|
#lxc.cgroup.devices.allow = c 10:237 rwm
|
||||||
|
|
||||||
|
|
||||||
|
# Autostart
|
||||||
|
lxc.start.auto = 1
|
||||||
|
lxc.start.delay = 5
|
||||||
|
lxc.start.order = 100
|
||||||
|
|
||||||
|
# Limt memory to 1GB less than full Memory of the server
|
||||||
|
# -
|
||||||
|
lxc.cgroup.memory.limit_in_bytes = $(( $(free -b | grep -oP '\d+' | head -n 1)-1000000000 ))
|
||||||
|
EOF
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
cat << EOF >> ${LXC_CONTAINER_DIR}/config 2>> $err_msg
|
||||||
|
|
||||||
|
# Mount iso file inside LX Container
|
||||||
|
#lxc.apparmor.profile = unconfined
|
||||||
|
#lxc.cgroup.devices.allow = b 7:* rwm
|
||||||
|
#lxc.cgroup.devices.allow = c 10:237 rwm
|
||||||
|
|
||||||
|
|
||||||
|
# Specify the apparmor profile under which the container should be run.
|
||||||
|
#
|
||||||
|
# To specify that the container should be unconfined, use
|
||||||
|
# lxc.apparmor.profile = unconfined
|
||||||
|
#
|
||||||
|
# If the apparmor profile should remain unchanged (i.e. if you are nesting
|
||||||
|
# containers and are already confined), then use
|
||||||
|
# lxc.apparmor.profile = unchanged
|
||||||
|
#
|
||||||
|
# If you instruct LXC to generate the apparmor profile, then use
|
||||||
|
# lxc.apparmor.profile = generated
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MariaDB (and maybe others) does not start
|
||||||
|
# =========================================
|
||||||
|
#
|
||||||
|
# see also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=920643
|
||||||
|
#
|
||||||
|
# AppArmor support in Debian has increased, thus preventing some systemd
|
||||||
|
# isolation features to work in LXC 3.0.X. Debian has backported some
|
||||||
|
# patches from LXC 3.1 that, along with some configurations in a
|
||||||
|
# container, will allow systemd isolation features to work.
|
||||||
|
#
|
||||||
|
# This may entirely be a an apparmor/systemd issue and nothing to do
|
||||||
|
# with mariadb.
|
||||||
|
#
|
||||||
|
# A workaround is to remove the the following lines from
|
||||||
|
# systemd service file:
|
||||||
|
# ProtectSystem=full
|
||||||
|
# PrivateDevices=true
|
||||||
|
# ProtectHome=true
|
||||||
|
#
|
||||||
|
# Another workarround is to diasble apparmor here:
|
||||||
|
# lxc.apparmor.profile = unconfined
|
||||||
|
#
|
||||||
|
# Note:
|
||||||
|
# The following commands solved this problem too, but have other
|
||||||
|
# problems (e.g. errors installing/updating debian packages).
|
||||||
|
# So DO NOT USE:
|
||||||
|
# lxc.apparmor.profile = generated
|
||||||
|
# lxc.apparmor.allow_nesting = 1
|
||||||
|
#
|
||||||
|
#lxc.apparmor.profile = unconfined
|
||||||
|
|
||||||
|
|
||||||
|
# Autostart
|
||||||
|
lxc.start.auto = 1
|
||||||
|
lxc.start.delay = 5
|
||||||
|
lxc.start.order = 100
|
||||||
|
|
||||||
|
# Limt memory to 1GB less than full Memory of the server
|
||||||
|
# -
|
||||||
|
lxc.cgroup.memory.limit_in_bytes = $(( $(free -b | grep -oP '\d+' | head -n 1)-1000000000 ))
|
||||||
|
EOF
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
_failed=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $_failed ; then
|
||||||
|
msg_failed="Adjusting '${LXC_CONTAINER_DIR}/config' failed!"
|
||||||
|
length_msg_failed=${#msg_failed}
|
||||||
|
blank_signs=""
|
||||||
|
if [[ $length_msg -gt $length_msg_failed ]]; then
|
||||||
|
number_blank_sign=$(expr $length_msg - $length_msg_failed)
|
||||||
|
index_i=0
|
||||||
|
while [[ $index_i -lt $number_blank_sign ]] ; do
|
||||||
|
blank_signs="$blank_signs "
|
||||||
|
(( index_i++ ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
|
error "$(cat $err_msg)"
|
||||||
|
else
|
||||||
|
msg_ok="Container Configuration '${LXC_CONTAINER_DIR}/config' adjusted."
|
||||||
|
length_msg_ok=${#msg_ok}
|
||||||
|
blank_signs=""
|
||||||
|
if [[ $length_msg -gt $length_msg_ok ]]; then
|
||||||
|
number_blank_sign=$(expr $length_msg - $length_msg_ok)
|
||||||
|
index_i=0
|
||||||
|
while [[ $index_i -lt $number_blank_sign ]] ; do
|
||||||
|
blank_signs="$blank_signs "
|
||||||
|
(( index_i++ ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -1192,16 +1424,17 @@ echo ""
|
|||||||
echo -e " \033[37m\033[1mAdjust network configuration inside the new LX Container ..\033[m"
|
echo -e " \033[37m\033[1mAdjust network configuration inside the new LX Container ..\033[m"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
|
||||||
# - Backup file '/etc/network/interfaces' inside the Container
|
# - Backup file '/etc/network/interfaces' inside the Container
|
||||||
# -
|
# -
|
||||||
msg="Backup file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces' .."
|
msg="Backup file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces' .."
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
cp ${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces \
|
cp ${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces \
|
||||||
${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces.ORIG
|
${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces.ORIG
|
||||||
|
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
msg_ok="File '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces.ORIG' saved."
|
msg_ok="File '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces.ORIG' saved."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1214,7 +1447,7 @@ if [[ $? -eq 0 ]] ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
else
|
else
|
||||||
msg_failed="Could not backup file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces'!"
|
msg_failed="Could not backup file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces'!"
|
||||||
length_msg_failed=${#msg_failed}
|
length_msg_failed=${#msg_failed}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1228,16 +1461,16 @@ else
|
|||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# - Create Containers network configuration
|
# - Create Containers network configuration
|
||||||
# -
|
# -
|
||||||
msg="Create a new file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces' .."
|
msg="Create a new file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces' .."
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
_failed=false
|
_failed=false
|
||||||
if [[ -z "$IPV4_ADDRESS_2" ]] ; then
|
if [[ -z "$IPV4_ADDRESS_2" ]] ; then
|
||||||
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces
|
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces
|
||||||
|
|
||||||
#-----------------------------
|
#-----------------------------
|
||||||
@ -1259,7 +1492,7 @@ EOF
|
|||||||
_failed=true
|
_failed=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces 2> $err_msg
|
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces 2> $err_msg
|
||||||
|
|
||||||
#-----------------------------
|
#-----------------------------
|
||||||
@ -1291,9 +1524,9 @@ EOF
|
|||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
_failed=true
|
_failed=true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $_failed ; then
|
if $_failed ; then
|
||||||
msg_failed="Failed to create file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces'!"
|
msg_failed="Failed to create file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces'!"
|
||||||
length_msg_failed=${#msg_failed}
|
length_msg_failed=${#msg_failed}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1307,7 +1540,7 @@ if $_failed ; then
|
|||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
else
|
else
|
||||||
msg_ok="New file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces' created."
|
msg_ok="New file '${LXC_CONTAINER_DIR}/rootfs/etc/network/interfaces' created."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1320,6 +1553,101 @@ else
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
else # if [[ "$LXC_DIST" = "debian" ]];
|
||||||
|
|
||||||
|
msg="Backup file '${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml"
|
||||||
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
|
cp ${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml \
|
||||||
|
${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml.ORIG
|
||||||
|
|
||||||
|
if [[ $? -eq 0 ]] ; then
|
||||||
|
msg_ok="File '${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml.ORIG' saved."
|
||||||
|
length_msg_ok=${#msg_ok}
|
||||||
|
blank_signs=""
|
||||||
|
if [[ $length_msg -gt $length_msg_ok ]]; then
|
||||||
|
number_blank_sign=$(expr $length_msg - $length_msg_ok)
|
||||||
|
index_i=0
|
||||||
|
while [[ $index_i -lt $number_blank_sign ]] ; do
|
||||||
|
blank_signs="$blank_signs "
|
||||||
|
(( index_i++ ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
|
else
|
||||||
|
msg_failed="Could not backup file '${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml'!"
|
||||||
|
length_msg_failed=${#msg_failed}
|
||||||
|
blank_signs=""
|
||||||
|
if [[ $length_msg -gt $length_msg_failed ]]; then
|
||||||
|
number_blank_sign=$(expr $length_msg - $length_msg_failed)
|
||||||
|
index_i=0
|
||||||
|
while [[ $index_i -lt $number_blank_sign ]] ; do
|
||||||
|
blank_signs="$blank_signs "
|
||||||
|
(( index_i++ ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
|
error "$(cat $err_msg)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# - Create Containers network configuration
|
||||||
|
# -
|
||||||
|
msg="Create a new file '${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml' .."
|
||||||
|
echo -en "\033[1G \033[1;30m[ \033[5m\033[1m...\033[m ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
|
_failed=false
|
||||||
|
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml
|
||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
renderer: networkd
|
||||||
|
ethernets:
|
||||||
|
eth0:
|
||||||
|
dhcp4: no
|
||||||
|
addresses:
|
||||||
|
- ${IPV4_ADDRESS_1}/24
|
||||||
|
gateway4: ${IPV4_GATEWAY_1}
|
||||||
|
nameservers:
|
||||||
|
addresses:
|
||||||
|
- ${IPV4_NAME_SERVER_1}
|
||||||
|
search:
|
||||||
|
- ${SEARCH_DOMAIN}
|
||||||
|
|
||||||
|
EOF
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $_failed ; then
|
||||||
|
msg_failed="Failed to create file '${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml'!"
|
||||||
|
length_msg_failed=${#msg_failed}
|
||||||
|
blank_signs=""
|
||||||
|
if [[ $length_msg -gt $length_msg_failed ]]; then
|
||||||
|
number_blank_sign=$(expr $length_msg - $length_msg_failed)
|
||||||
|
index_i=0
|
||||||
|
while [[ $index_i -lt $number_blank_sign ]] ; do
|
||||||
|
blank_signs="$blank_signs "
|
||||||
|
(( index_i++ ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
|
error "$(cat $err_msg)"
|
||||||
|
else
|
||||||
|
msg_ok="New file '${LXC_CONTAINER_DIR}/rootfs/etc/netplan/10-lxc.yaml' created."
|
||||||
|
length_msg_ok=${#msg_ok}
|
||||||
|
blank_signs=""
|
||||||
|
if [[ $length_msg -gt $length_msg_ok ]]; then
|
||||||
|
number_blank_sign=$(expr $length_msg - $length_msg_ok)
|
||||||
|
index_i=0
|
||||||
|
while [[ $index_i -lt $number_blank_sign ]] ; do
|
||||||
|
blank_signs="$blank_signs "
|
||||||
|
(( index_i++ ))
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -1372,7 +1700,10 @@ fi
|
|||||||
# - Create new 'sources.list'-file.
|
# - Create new 'sources.list'-file.
|
||||||
# -
|
# -
|
||||||
msg="Create file '${LXC_CONTAINER_DIR}/rootfs/etc/apt/sources.list' .."
|
msg="Create file '${LXC_CONTAINER_DIR}/rootfs/etc/apt/sources.list' .."
|
||||||
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/apt/sources.list 2> $err_msg
|
|
||||||
|
if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
|
||||||
|
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/apt/sources.list 2> $err_msg
|
||||||
|
|
||||||
deb http://ftp.de.debian.org/debian/ $LXC_RELEASE main non-free contrib
|
deb http://ftp.de.debian.org/debian/ $LXC_RELEASE main non-free contrib
|
||||||
deb-src http://ftp.de.debian.org/debian/ $LXC_RELEASE main non-free contrib
|
deb-src http://ftp.de.debian.org/debian/ $LXC_RELEASE main non-free contrib
|
||||||
@ -1390,6 +1721,22 @@ deb-src http://ftp.de.debian.org/debian/ $LXC_RELEASE-backports main contrib non
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
cat << EOF > ${LXC_CONTAINER_DIR}/rootfs/etc/apt/sources.list 2> $err_msg
|
||||||
|
# Generated by distrobuilder
|
||||||
|
deb http://archive.ubuntu.com/ubuntu $LXC_RELEASE main restricted universe multiverse
|
||||||
|
deb http://archive.ubuntu.com/ubuntu $LXC_RELEASE-updates main restricted universe multiverse
|
||||||
|
deb http://security.ubuntu.com/ubuntu $LXC_RELEASE-security main restricted universe multiverse
|
||||||
|
|
||||||
|
deb http://de.archive.ubuntu.com/ubuntu/ $LXC_RELEASE-backports main restricted universe multiverse
|
||||||
|
deb http://archive.canonical.com/ubuntu $LXC_RELEASE partner
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
msg_ok="New file '${LXC_CONTAINER_DIR}/rootfs/etc/apt/sources.list' created."
|
msg_ok="New file '${LXC_CONTAINER_DIR}/rootfs/etc/apt/sources.list' created."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
@ -1608,13 +1955,14 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
|
||||||
# - Install 'figlet' from debian package system
|
# - Install 'figlet' from debian package system
|
||||||
# -
|
# -
|
||||||
echo ""
|
echo ""
|
||||||
_pkg="figlet"
|
_pkg="figlet"
|
||||||
msg="Install '$_pkg' from debian package system .."
|
msg="Install '$_pkg' from debian package system .."
|
||||||
if ! $(aptitude search "$_pkg" | grep " $_pkg " | grep -e "^i" > /dev/null 2>&1) ; then
|
if ! $(aptitude search "$_pkg" | grep " $_pkg " | grep -e "^i" > /dev/null 2>&1) ; then
|
||||||
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -y install $_pkg > /dev/null 2> "$err_msg"
|
DEBIAN_FRONTEND=noninteractive apt-get -y install $_pkg > /dev/null 2> "$err_msg"
|
||||||
|
|
||||||
@ -1646,20 +1994,20 @@ if ! $(aptitude search "$_pkg" | grep " $_pkg " | grep -e "^i" > /dev/null 2>&1)
|
|||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "\033[1G [ \033[30m\033[1mskip\033[m ] $msg"
|
echo -e "\033[1G [ \033[30m\033[1mskip\033[m ] $msg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# - Backup Containers file '/etc/motd'
|
# - Backup Containers file '/etc/motd'
|
||||||
# -
|
# -
|
||||||
echo ""
|
echo ""
|
||||||
msg="Backup file '${LXC_CONTAINER_DIR}/rootfs/etc/motd' .."
|
msg="Backup file '${LXC_CONTAINER_DIR}/rootfs/etc/motd' .."
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
mv "${LXC_CONTAINER_DIR}/rootfs/etc/motd" "${LXC_CONTAINER_DIR}/rootfs/etc/motd.ORIG" > $err_msg 2>&1
|
mv "${LXC_CONTAINER_DIR}/rootfs/etc/motd" "${LXC_CONTAINER_DIR}/rootfs/etc/motd.ORIG" > $err_msg 2>&1
|
||||||
|
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
msg_ok="File '${LXC_CONTAINER_DIR}/rootfs/etc/motd.ORIG' saved."
|
msg_ok="File '${LXC_CONTAINER_DIR}/rootfs/etc/motd.ORIG' saved."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1672,7 +2020,7 @@ if [[ $? -eq 0 ]] ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
else
|
else
|
||||||
msg_failed="Could not backup file '${LXC_CONTAINER_DIR}/rootfs/etc/motd'!"
|
msg_failed="Could not backup file '${LXC_CONTAINER_DIR}/rootfs/etc/motd'!"
|
||||||
length_msg_failed=${#msg_failed}
|
length_msg_failed=${#msg_failed}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1686,17 +2034,17 @@ else
|
|||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - Create new containers file '/etc/motd'
|
# - Create new containers file '/etc/motd'
|
||||||
# -
|
# -
|
||||||
|
|
||||||
msg="Create a new file '${LXC_CONTAINER_DIR}/rootfs/etc/motd' .."
|
msg="Create a new file '${LXC_CONTAINER_DIR}/rootfs/etc/motd' .."
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
figlet $HOSTNAME > "${LXC_CONTAINER_DIR}/rootfs/etc/motd"
|
figlet $HOSTNAME > "${LXC_CONTAINER_DIR}/rootfs/etc/motd"
|
||||||
|
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
msg_ok="New file '${LXC_CONTAINER_DIR}/rootfs/etc/motd' created."
|
msg_ok="New file '${LXC_CONTAINER_DIR}/rootfs/etc/motd' created."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1709,7 +2057,7 @@ if [[ $? -eq 0 ]] ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
else
|
else
|
||||||
msg_failed="Failed to create file '${LXC_CONTAINER_DIR}/rootfs/etc/motd'!"
|
msg_failed="Failed to create file '${LXC_CONTAINER_DIR}/rootfs/etc/motd'!"
|
||||||
length_msg_failed=${#msg_failed}
|
length_msg_failed=${#msg_failed}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1723,19 +2071,22 @@ else
|
|||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi # if [[ "$LXC_DIST" = "debian" ]]
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$LXC_DIST" = "debian" ]]; then
|
||||||
|
|
||||||
# - Backup Containers file '/etc/ssh/sshd_config'
|
# - Backup Containers file '/etc/ssh/sshd_config'
|
||||||
# -
|
# -
|
||||||
echo ""
|
echo ""
|
||||||
msg="Backup file '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config' .."
|
msg="Backup file '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config' .."
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
mv "${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config" "${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config.ORIG" > $err_msg 2>&1
|
mv "${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config" "${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config.ORIG" > $err_msg 2>&1
|
||||||
|
|
||||||
if [[ $? -eq 0 ]] ; then
|
if [[ $? -eq 0 ]] ; then
|
||||||
msg_ok="File '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config.ORIG' saved."
|
msg_ok="File '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config.ORIG' saved."
|
||||||
length_msg_ok=${#msg_ok}
|
length_msg_ok=${#msg_ok}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1748,7 +2099,7 @@ if [[ $? -eq 0 ]] ; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
echo -e "\033[1G [ \033[32m\033[1mok\033[m ] ${msg_ok}${blank_signs}"
|
||||||
else
|
else
|
||||||
msg_failed="Could not backup file '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config'!"
|
msg_failed="Could not backup file '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config'!"
|
||||||
length_msg_failed=${#msg_failed}
|
length_msg_failed=${#msg_failed}
|
||||||
blank_signs=""
|
blank_signs=""
|
||||||
@ -1762,15 +2113,15 @@ else
|
|||||||
fi
|
fi
|
||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# - Create new containers file '/etc/ssh/sshd_config'
|
# - Create new containers file '/etc/ssh/sshd_config'
|
||||||
# -
|
# -
|
||||||
|
|
||||||
msg="Create a new file '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config' .."
|
msg="Create a new file '${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config' .."
|
||||||
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
echo -en "\033[1G \033[1;30m[ ... ] \033[32m$msg\033[m"
|
||||||
|
|
||||||
if [[ -f "${working_dir}/supported-files/sshd_config" ]]; then
|
if [[ -f "${working_dir}/supported-files/sshd_config" ]]; then
|
||||||
cp -a "${working_dir}/supported-files/sshd_config" \
|
cp -a "${working_dir}/supported-files/sshd_config" \
|
||||||
"${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config" 2>$err_msg
|
"${LXC_CONTAINER_DIR}/rootfs/etc/ssh/sshd_config" 2>$err_msg
|
||||||
|
|
||||||
@ -1802,9 +2153,11 @@ if [[ -f "${working_dir}/supported-files/sshd_config" ]]; then
|
|||||||
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
echo -e "\033[1G [ \033[31m\033[1mfailed\033[m ] ${msg_failed}${blank_signs}"
|
||||||
error "$(cat $err_msg)"
|
error "$(cat $err_msg)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "\033[1G [ \033[30m\033[1mskip\033[m ] $msg"
|
echo -e "\033[1G [ \033[30m\033[1mskip\033[m ] $msg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi # if [[ "$LXC_DIST" = "debian" ]]
|
||||||
|
|
||||||
|
|
||||||
# - Backup Containers file '/root/.bashrc'
|
# - Backup Containers file '/root/.bashrc'
|
||||||
@ -2313,10 +2666,23 @@ fi
|
|||||||
echo ""
|
echo ""
|
||||||
info " Direct access to the new container with command:
|
info " Direct access to the new container with command:
|
||||||
\033[1mlxc-attach -n $LXC_NAME\033[m"
|
\033[1mlxc-attach -n $LXC_NAME\033[m"
|
||||||
|
|
||||||
|
if [[ "$LXC_DIST" = "ubuntu" ]]; then
|
||||||
|
info " This is a really minimal Ubuntu installation. Inside the Container, first install and
|
||||||
|
configure locales, also openssh is not yet installed:
|
||||||
|
\033[1mapt update
|
||||||
|
apt dist-upgrade
|
||||||
|
apt install locales
|
||||||
|
dpkg-reconfigure locales
|
||||||
|
apt install openssh-server\033[m"
|
||||||
|
fi
|
||||||
info " Inside the new Contaimer, run the following commands to create/adjust users:
|
info " Inside the new Contaimer, run the following commands to create/adjust users:
|
||||||
\033[1madd_new_user.sh root
|
\033[1madd_new_user.sh root
|
||||||
add_new_user.sh chris
|
add_new_user.sh chris
|
||||||
add_new_user.sh sysadm
|
add_new_user.sh sysadm
|
||||||
add_new_user.sh back\033[m"
|
add_new_user.sh back\033[m"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
|
echo ""
|
||||||
clean_up 0
|
clean_up 0
|
||||||
|
Loading…
Reference in New Issue
Block a user