optimisation and correction
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
# higher priority.
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export VER_conf_ceph="1.0.0"
|
||||
export VER_conf_ceph="1.0.1"
|
||||
export DEP_conf_ceph=""
|
||||
|
||||
conf_ceph()
|
||||
@@ -31,16 +31,12 @@ conf_ceph()
|
||||
# Determine the type of installation
|
||||
if [[ $SYS_ARCH == "x86_64" || $SYS_ARCH == "i386" ]]; then
|
||||
export CEPH_STATUS=ceph
|
||||
elif [[ -n $SMBSRV ]]; then
|
||||
export CEPH_STATUS=smb
|
||||
elif [[ -n $NFSSRV ]]; then
|
||||
export CEPH_STATUS=nfs
|
||||
else
|
||||
if [[ -n $SMBSRV ]]; then
|
||||
export CEPH_STATUS=smb
|
||||
else
|
||||
if [[ -n $NFSSRV ]]; then
|
||||
export CEPH_STATUS=nfs
|
||||
else
|
||||
export CEPH_STATUS=none
|
||||
fi
|
||||
fi
|
||||
export CEPH_STATUS=none
|
||||
fi
|
||||
|
||||
if [[ $CEPH_STATUS == ceph ]]; then
|
||||
@@ -48,16 +44,18 @@ conf_ceph()
|
||||
pkginst ceph-common
|
||||
|
||||
# hosts files required for Ceph bootstrap when DNS not yet started
|
||||
if [[ -z $(grep "# Ceph" /etc/hosts) ]]; then
|
||||
if ! grep -q "^# Ceph" /etc/hosts; then
|
||||
prnt I "Adding server list to /etc/hosts"
|
||||
backup_dist /etc/hosts
|
||||
tag_file /etc/hosts
|
||||
echo >> /etc/hosts
|
||||
echo "# Ceph servers:" >> /etc/hosts
|
||||
for srv in $CEPH_SRV_NAMES; do
|
||||
local line="$(eval echo \$CEPHIP_$srv) $srv.$REALM $srv"
|
||||
local line
|
||||
line="$(eval echo \$CEPHIP_$srv) $srv.$REALM $srv"
|
||||
prnt m " - Adding line $line to /etc/hosts"
|
||||
echo "$line" >> /etc/hosts
|
||||
unset line
|
||||
done
|
||||
else
|
||||
prnt W "Ceph servers already in /etc/hosts, nothing to do"
|
||||
@@ -67,18 +65,19 @@ conf_ceph()
|
||||
prnt I "Adding ceph entries to /etc/fstab"
|
||||
tag_file /etc/fstab
|
||||
echo >> /etc/fstab
|
||||
local srvlist=$(echo $CEPH_SRV_NAMES | sed "s/ /,/g")
|
||||
local secret=$(fetch_secret "$CEPH_SECRET")
|
||||
if [[ -z $(grep $srvlist /etc/fstab) ]]; then
|
||||
local srvlist=${CEPH_SRV_NAMES/ /,}
|
||||
local secret
|
||||
secret=$(fetch_secret "$CEPH_SECRET")
|
||||
if ! grep -q "$srvlist" /etc/fstab; then
|
||||
echo "# Ceph :" >> /etc/fstab
|
||||
for mnt in $CEPH_MOUNTS; do
|
||||
mkdir -pv $mnt
|
||||
mkdir -pv "$mnt"
|
||||
echo "$srvlist:/ $(eval echo \$CEPH_MP_$mnt) ceph defaults,_netdev,name=admin,secret=$secret,id=$mnt 0 0" >> /etc/fstab
|
||||
done
|
||||
else
|
||||
prnt W "Ceph entry already in /etc/fstab, nothing to do"
|
||||
fi
|
||||
unset srvlist
|
||||
unset srvlist secret
|
||||
success=yes
|
||||
elif [[ $CEPH_STATUS == smb ]]; then
|
||||
pkginst smbclient
|
||||
@@ -87,7 +86,7 @@ conf_ceph()
|
||||
prnt I "Adding Samba entries to /etc/fstab"
|
||||
echo >> /etc/fstab
|
||||
tag_file /etc/fstab
|
||||
if [[ -z $(grep $SMBSRV /etc/fstab) ]]; then
|
||||
if ! grep -q "$SMBSRV" /etc/fstab; then
|
||||
echo "# Samba:" >> /etc/fstab
|
||||
for mnt in $CEPH_MOUNTS; do
|
||||
echo "//$SMBSRV/$mnt $(eval echo \$CEPH_MP_$mnt) cifs defaults,_netdev,username=root,password= 0 0" >> /etc/fstab
|
||||
@@ -98,7 +97,7 @@ conf_ceph()
|
||||
success=yes
|
||||
elif [[ $CEPH_STATUS == nfs ]]; then
|
||||
tag_file /etc/fstab
|
||||
: # To be implemented
|
||||
# To be implemented
|
||||
elif [[ $CEPH_STATUS == none ]]; then
|
||||
prnt W "No alternative set for unsuported hardware, nothing will be done."
|
||||
return 0
|
||||
@@ -107,9 +106,9 @@ conf_ceph()
|
||||
return 1
|
||||
fi
|
||||
if [[ $success == yes ]]; then
|
||||
# TODO: Create some mount binds for convenience
|
||||
# Create some mount binds for convenience
|
||||
# TODO: That part should be a different module with own configuration
|
||||
if [[ -z $(grep "^/srv/ceph/share" /etc/fstab) ]]; then
|
||||
if grep -q "^/srv/ceph/share" /etc/fstab; then
|
||||
echo "/srv/ceph/share /share none defaults,_netdev,bind 0 0" >> /etc/fstab
|
||||
if [[ $SHARED_HOME == 1 ]]; then
|
||||
echo "/srv/ceph/share/home /home none defaults,_netdev,bind 0 0" >> /etc/fstab
|
||||
@@ -123,8 +122,9 @@ conf_ceph()
|
||||
# Mount Ceph volumes if required
|
||||
prnt I "Mounting ceph volumes"
|
||||
for mnt in $CEPH_MOUNTS; do
|
||||
if [[ -z $(mount | grep "on $(eval echo "\$CEPH_MP_mnt)")" ]]; then
|
||||
mount -v $(eval echo "\$CEPH_MP_mnt)")
|
||||
if ! mountpoint -q "$(eval echo \$CEPH_MP_$mnt)"; then
|
||||
mount -v "$(eval echo \$CEPH_MP_$mnt)" ||
|
||||
prnt W "Error while mounting CEPH filesystem (check CEPH logs), ignoring"
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -145,7 +145,7 @@ precheck_conf_ceph()
|
||||
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 I "If you don't want to put a CEPH secret var in configuration file,"
|
||||
prnt m "you need to export it temporarily in your environment, using the"
|
||||
prnt m "\"CEPH_SECRET\" variable."
|
||||
die 181
|
||||
@@ -159,7 +159,7 @@ precheck_conf_ceph()
|
||||
die 182
|
||||
fi
|
||||
else
|
||||
prnt W "System incompatible with ceph, falling back to samba..."
|
||||
prnt W "System incompatible with ceph, falling back to Samba or NFS..."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user