better quotes

This commit is contained in:
Jérémy Lecour 2020-04-19 10:05:20 +02:00 committed by Jérémy Lecour
parent 478703d96e
commit 1846be4e45
4 changed files with 10 additions and 10 deletions

View file

@ -21,7 +21,7 @@ if [ -b "${BACKUP_DISK}" ]; then
cryptsetup isLuks "${BACKUP_DISK}"
if [ "$?" -eq 0 ]; then
if [ ! -b '/dev/mapper/backup' ]; then
echo "Luks disk ${BACKUP_DISK} is not mounted !\n"
echo "Luks disk \`${BACKUP_DISK}' is not mounted !\n"
echo "cryptsetup luksOpen ${BACKUP_DISK} backup"
exit 2
fi
@ -31,7 +31,7 @@ if [ -b "${BACKUP_DISK}" ]; then
# Verify that it's mounted and writable
findmnt --source ${BACKUP_DISK} -O rw > /dev/null
if [ "$?" -ne 0 ]; then
echo "Backup disk ${BACKUP_DISK} is not mounted (or read-only) !\n"
echo "Backup disk \`${BACKUP_DISK}' is not mounted (or read-only) !\n"
echo "mount ${BACKUP_DISK} /backup"
exit 2
fi

View file

@ -31,18 +31,18 @@ else
new_ips="0.0.0.0/0"
else
existing_ips=$("${LIBDIR}/bkctld-ip" "${jail_name}")
new_ips=$(echo "${existing_ips}" "${ip}" | xargs -n1 | grep -v "0.0.0.0/0" | sort | uniq)
new_ips=$(echo ${existing_ips} ${ip} | xargs -n1 | grep -v "0.0.0.0/0" | sort | uniq)
fi
allow_users="AllowUsers"
for ip in ${new_ips}; do
allow_users="${allow_users} root@${ip}"
for new_ip in ${new_ips}; do
allow_users="${allow_users} root@${new_ip}"
done
if grep -q -E "^AllowUsers" "${jail_sshd_config}"; then
sed -i "s~^AllowUsers .*~${allow_users}~" "${jail_sshd_config}"
else
error "${jail_name}: No 'AllowUsers' directive found in '${jail_sshd_config}'"
error "${jail_name}: No \`AllowUsers' directive found in \`${jail_sshd_config}'"
fi
notice "${jail_name}: IP whitelist updated to ${ip}"
notice "${jail_name}: IP whitelist updated with \`${ip}'"
"${LIBDIR}/bkctld-reload" "${jail_name}"
"${LIBDIR}/bkctld-firewall" "${jail_name}"
fi

View file

@ -22,8 +22,8 @@ if [ -z "${keyfile}" ]; then
cat "${jail_path}/${AUTHORIZED_KEYS}"
fi
else
test -r "${keyfile}" || error "${jail_name}: SSH key '${keyfile}' is missing or is not readable."
test -r "${keyfile}" || error "${jail_name}: SSH key \`${keyfile}' is missing or is not readable."
cat "${keyfile}" > "${jail_path}/${AUTHORIZED_KEYS}"
chmod 600 "${jail_path}/${AUTHORIZED_KEYS}"
notice "${jail_name}: SSH key has been updated with ${keyfile}"
notice "${jail_name}: SSH key has been updated with \`${keyfile}'"
fi

View file

@ -29,7 +29,7 @@ else
fi
sed -i "s/^Port .*/Port ${port}/" "${jail_sshd_config}"
notice "${jail_name}: port has been updated to ${port}"
notice "${jail_name}: port has been updated to \`${port}'"
"${LIBDIR}/bkctld-reload" "${jail_name}"
"${LIBDIR}/bkctld-firewall" "${jail_name}"