forked from neil/lxc-templates
Merge pull request #33 from TanyaEleventhGoddess/master
Fix indentation and correct issues with suite mismatch
This commit is contained in:
commit
f841a6f7f1
@ -67,6 +67,16 @@ find_interpreter()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
release_info() {
|
||||||
|
if wget "${1}/dists/${release}/Release" -O /dev/null --quiet 2> /dev/null; then
|
||||||
|
local release_file=$(wget "${1}/dists/${release}/Release" -O - --quiet 2> /dev/null)
|
||||||
|
distro_suite=${release_file#*Suite: }
|
||||||
|
distro_suite=${distro_suite%%$'\n'*}
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
configure_debian()
|
configure_debian()
|
||||||
{
|
{
|
||||||
rootfs=$1
|
rootfs=$1
|
||||||
@ -237,14 +247,26 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apt_update_packages(){
|
||||||
|
local apt_update_args="update"
|
||||||
|
local lpath="${rootfs}/var/lib/apt/lists/$(echo "$MIRROR" | sed 's#.*://##;s#/#_#g')_dists_${release}_Release"
|
||||||
|
if [ -f "$lpath" ] && [ ! -z "$distro_suite" ]; then
|
||||||
|
local lsuite=$(cat "$lpath" | grep 'Suite:')
|
||||||
|
[ "${lsuite#Suite: }" != "$distro_suite" ] && apt_update_args="--allow-releaseinfo-change $apt_update_args"
|
||||||
|
fi
|
||||||
|
chroot "${rootfs}" apt-get $apt_update_args
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
install_packages()
|
install_packages()
|
||||||
{
|
{
|
||||||
local rootfs="$1"; shift
|
local rootfs="$1"; shift
|
||||||
local packages="$*"
|
local packages="$*"
|
||||||
|
|
||||||
chroot "${rootfs}" apt-get update
|
if [ -n "${packages}" ] && apt_update_packages; then
|
||||||
if [ -n "${packages}" ]; then
|
|
||||||
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
||||||
|
elif [ -n "${packages}" ]; then
|
||||||
|
echo "Apt update failed, not downloading packages"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,12 +366,14 @@ download_debian()
|
|||||||
$init,\
|
$init,\
|
||||||
ifupdown,\
|
ifupdown,\
|
||||||
locales,\
|
locales,\
|
||||||
|
ca-certificates,\
|
||||||
dialog,\
|
dialog,\
|
||||||
isc-dhcp-client,\
|
isc-dhcp-client,\
|
||||||
netbase,\
|
netbase,\
|
||||||
net-tools,\
|
net-tools,\
|
||||||
$iproute,\
|
$iproute,\
|
||||||
openssh-server
|
openssh-server,\
|
||||||
|
apt-transport-https
|
||||||
|
|
||||||
cache=$1
|
cache=$1
|
||||||
arch=$2
|
arch=$2
|
||||||
@ -811,10 +835,12 @@ fi
|
|||||||
release=${release:-stable}
|
release=${release:-stable}
|
||||||
permanent_releases=('stable' 'testing' 'sid' 'unstable')
|
permanent_releases=('stable' 'testing' 'sid' 'unstable')
|
||||||
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
||||||
if ! wget "${MIRROR}/dists/${release}/Release" -O /dev/null 2> /dev/null; then
|
if ! release_info "${MIRROR}"; then
|
||||||
echo "Invalid release ${release} (not found in mirror)"
|
echo "Invalid release ${release} (not found in mirror)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
release_info "${MIRROR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# detect rootfs
|
# detect rootfs
|
||||||
|
@ -67,6 +67,16 @@ find_interpreter()
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
release_info() {
|
||||||
|
if wget "${1}/dists/${release}/Release" -O /dev/null --quiet 2> /dev/null; then
|
||||||
|
local release_file=$(wget "${1}/dists/${release}/Release" -O - --quiet 2> /dev/null)
|
||||||
|
distro_suite=${release_file#*Suite: }
|
||||||
|
distro_suite=${distro_suite%%$'\n'*}
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
configure_devuan()
|
configure_devuan()
|
||||||
{
|
{
|
||||||
rootfs=$1
|
rootfs=$1
|
||||||
@ -240,14 +250,26 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apt_update_packages(){
|
||||||
|
local apt_update_args="update"
|
||||||
|
local lpath="${rootfs}/var/lib/apt/lists/$(echo "$MIRROR" | sed 's#.*://##;s#/#_#g')_dists_${release}_Release"
|
||||||
|
if [ -f "$lpath" ] && [ ! -z "$distro_suite" ]; then
|
||||||
|
local lsuite=$(cat "$lpath" | grep 'Suite:')
|
||||||
|
[ "${lsuite#Suite: }" != "$distro_suite" ] && apt_update_args="--allow-releaseinfo-change $apt_update_args"
|
||||||
|
fi
|
||||||
|
chroot "${rootfs}" apt-get $apt_update_args
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
install_packages()
|
install_packages()
|
||||||
{
|
{
|
||||||
local rootfs="$1"; shift
|
local rootfs="$1"; shift
|
||||||
local packages="$*"
|
local packages="$*"
|
||||||
|
|
||||||
chroot "${rootfs}" apt-get update
|
if [ -n "${packages}" ] && apt_update_packages; then
|
||||||
if [ -n "${packages}" ]; then
|
|
||||||
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
chroot "${rootfs}" apt-get install --force-yes -y --no-install-recommends ${packages}
|
||||||
|
elif [ -n "${packages}" ]; then
|
||||||
|
echo "Apt update failed, not downloading packages"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,12 +320,14 @@ download_devuan()
|
|||||||
init,\
|
init,\
|
||||||
ifupdown,\
|
ifupdown,\
|
||||||
locales,\
|
locales,\
|
||||||
|
ca-certificates,\
|
||||||
dialog,\
|
dialog,\
|
||||||
isc-dhcp-client,\
|
isc-dhcp-client,\
|
||||||
netbase,\
|
netbase,\
|
||||||
net-tools,\
|
net-tools,\
|
||||||
iproute2,\
|
iproute2,\
|
||||||
openssh-server
|
openssh-server,\
|
||||||
|
apt-transport-https
|
||||||
|
|
||||||
cache=$1
|
cache=$1
|
||||||
arch=$2
|
arch=$2
|
||||||
@ -755,12 +779,14 @@ if [ -n "$authkey" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
release=${release:-stable}
|
release=${release:-stable}
|
||||||
permanent_releases=('stable' 'testing' 'ceres' 'unstable')
|
permanent_releases=('stable' 'testing' 'sid' 'unstable')
|
||||||
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
if [[ ! "${permanent_releases[*]}" =~ (^|[^[:alpha:]])$release([^[:alpha:]]|$) ]]; then
|
||||||
if ! wget "${MIRROR}/dists/${release}/Release" -O /dev/null 2> /dev/null; then
|
if ! release_info "${MIRROR}"; then
|
||||||
echo "Invalid release ${release} (not found in mirror)"
|
echo "Invalid release ${release} (not found in mirror)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
release_info "${MIRROR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# detect rootfs
|
# detect rootfs
|
||||||
|
@ -326,13 +326,15 @@ download_kali()
|
|||||||
$init,\
|
$init,\
|
||||||
ifupdown,\
|
ifupdown,\
|
||||||
locales,\
|
locales,\
|
||||||
|
ca-certificates,\
|
||||||
dialog,\
|
dialog,\
|
||||||
isc-dhcp-client,\
|
isc-dhcp-client,\
|
||||||
netbase,\
|
netbase,\
|
||||||
net-tools,\
|
net-tools,\
|
||||||
$iproute,\
|
$iproute,\
|
||||||
openssh-server,\
|
openssh-server,\
|
||||||
kali-archive-keyring
|
kali-archive-keyring,\
|
||||||
|
apt-transport-https
|
||||||
|
|
||||||
cache=$1
|
cache=$1
|
||||||
arch=$2
|
arch=$2
|
||||||
|
Loading…
Reference in New Issue
Block a user