install.sh: Don't allow installation of systemd-resolved on non-lxc targets

Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com>
This commit is contained in:
Tobias Knöppler 2024-03-30 19:02:02 +01:00
parent 32df0e0f1b
commit 15980fe5d1
No known key found for this signature in database
GPG Key ID: 3510056072886A8F
3 changed files with 42 additions and 23 deletions

View File

@ -13,17 +13,17 @@ install()
{
set -x
apt-get update
mkdir -p /etc/systemd/resolved.conf.d
cat <<EOF > /etc/systemd/resolved.conf.d/nostublistener.conf
[Resolve]
DNSStubListener=no
EOF
[[ "$INIT_SYSTEM" != "systemd" ]] || systemctl restart systemd-resolved
apt-get install --no-install-recommends -y dnsmasq
rc=0
service dnsmasq status > /dev/null 2>&1 || rc=$?
[[ $rc -eq 3 ]] && ! [[ "$INIT_SYSTEM" =~ ^("chroot"|"unknown")$ ]] && {
echo "Applying workaround for dnsmasq bug (compare issue #1446)"
mkdir -p /etc/systemd/resolved.conf.d
cat <<EOF > /etc/systemd/resolved.conf.d/nostublistener.conf
[Resolve]
DNSStubListener=no
EOF
[[ "$INIT_SYSTEM" != "systemd" ]] || systemctl restart systemd-resolved
service systemd-resolved stop || true
service dnsmasq start
service dnsmasq status

View File

@ -28,19 +28,22 @@ export PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}"
type mysqld &>/dev/null && echo ">>> WARNING: existing mysqld configuration will be changed <<<"
type mysqld &>/dev/null && mysql -e 'use nextcloud' &>/dev/null && { echo "The 'nextcloud' database already exists. Aborting"; exit 1; }
if ! is_lxc && [[ -d "/run/systemd/system" ]] && ! type systemd-resolve &>/dev/null
then
echo "systemd-resolved not found! Please install first with apt-get install systemd-resolve"
exit 1
fi
#if ! is_lxc && [[ -d "/run/systemd/system" ]] && ! type systemd-resolve &>/dev/null
#then
# echo "systemd-resolved not found! You should probably install it yourself (with apt-get install systemd-resolved) and make sure it's working. Alternatively, NextcloudPi can try to install it for you (EXPERIMENTAL, THIS CAN BREAK YOUR NETWORK CONNECTIVITY!)"
# if [[ "$DEBIAN_FRONTEND" == "noninteractive" ]]
# then
# echo "Would you like NCP to attempt installing systemd-resolved? [y/N] y"
# echo "(Automatic choice because of DEBIAN_FRONTEND=noninteractive)"
# else
# read -r choice "Would you like NCP to attempt installing systemd-resolved? [y/N] "
# [[ "${choice,,}" == "y" ]] || exit 0
# fi
#fi
# get dependencies
apt-get update
apt-get install --no-install-recommends -y git ca-certificates sudo lsb-release wget systemd-resolved
if [[ -d "/run/systemd/system" ]]
then
systemctl enable --now systemd-resolved
fi
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y git ca-certificates sudo lsb-release wget jq
# get install code
if [[ "${CODE_DIR}" == "" ]]; then
@ -73,6 +76,22 @@ cp etc/ncp.cfg /usr/local/etc/
cp -r etc/ncp-templates /usr/local/etc/
install_app lamp.sh
if [[ -d "/run/systemd/system" ]] && is_lxc
then
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y systemd-resolved
systemctl enable systemd-resolved
# host nextcloudpi.com 2>/dev/null || {
# echo "Attempt to temporarily fix DNS after installation of systemd-resolved (You will need to fix it permanently after reboot!)..."
# sleep 5
# echo "nameserver 9.9.9.9" >> /etc/resolv.conf.head
# systemctl restart systemd-resolved
# while read -r line
# do
# if="${line%%)*}"; if="${if##.*\(}"
# resolvectl dns "$if" 9.9.9.9;
# done <<<"$(resolvectl dns | grep '^Link')"
# }
fi
install_app bin/ncp/CONFIG/nc-nextcloud.sh
run_app_unsafe bin/ncp/CONFIG/nc-nextcloud.sh
rm /usr/local/etc/ncp-config.d/nc-nextcloud.cfg # armbian overlay is ro

14
lamp.sh
View File

@ -37,13 +37,13 @@ install()
apache2ctl -V || true
# Create systemd users to keep uids persistent between containers
id -u systemd-resolve || {
addgroup --quiet --system systemd-journal
adduser --quiet -u 180 --system --group --no-create-home --home /run/systemd \
--gecos "systemd Network Management" systemd-network
adduser --quiet -u 181 --system --group --no-create-home --home /run/systemd \
--gecos "systemd Resolver" systemd-resolve
}
# id -u systemd-resolve || {
# addgroup --quiet --system systemd-journal
# adduser --quiet -u 180 --system --group --no-create-home --home /run/systemd \
# --gecos "systemd Network Management" systemd-network
# adduser --quiet -u 181 --system --group --no-create-home --home /run/systemd \
# --gecos "systemd Resolver" systemd-resolve
# }
install_with_shadow_workaround --no-install-recommends systemd
$APTINSTALL -t $RELEASE php${PHPVER} php${PHPVER}-curl php${PHPVER}-gd php${PHPVER}-fpm php${PHPVER}-cli php${PHPVER}-opcache \
php${PHPVER}-mbstring php${PHPVER}-xml php${PHPVER}-zip php${PHPVER}-fileinfo php${PHPVER}-ldap \