conf_ceph.sh: made it more secure with required tests

This commit is contained in:
levasseur
2022-02-21 16:17:27 +01:00
parent 7f2f30844a
commit 6803cccf70

View File

@@ -27,6 +27,11 @@ conf_ceph()
local success=undef
local fstabchanged=false
if [[ $SYS_ARCH == "x86_64" || $SYS_ARCH == "i386" ]]; then
export CEPH_STATUS=ceph
else
export CEPH_STATUS=smb
fi
if [[ $CEPH_STATUS == ceph ]]; then
# Install ceph package
pkginst ceph-common
@@ -107,10 +112,29 @@ precheck_conf_ceph()
{
if [[ $SYS_ARCH == "x86_64" || $SYS_ARCH == "i386" ]]; then
prnt I "Installing ceph client package..."
CEPH_STATUS=ceph
if [[ -n $CEPH_SRV_NAMES ]]; then
prnt I "We will use the following CEPH servers:"
for srv in $CEPH_SRV_NAMES; do
if [[ -z "$(eval echo \$CEPHIP_$srv)" ]]; then
prnt E "The IP for CEPH server \"$srv\" is not declared."
die 180
else
prnt m " * $srv with IP $(eval echo \$CEPHIP_$srv)"
fi
done
if [[ -z $CEPH_SECRET ]]; then
prnt E "CEPH secret key is not declared, can't continue!"
prnt I "If you don't want to put tour CEPH secret in configuration file,"
prnt m "you need to export it temporarily in your environment, using the"
prnt m "\"CEPH_SECRET\" variable."
exit 181
fi
else
prnt E "No CEPH server declared!"
die 182
fi
else
prnt W "System incompatible with ceph, falling back to samba..."
CEPH_STATUS=smb
fi
}