Skip to content

Commit

Permalink
Correct k8s script error
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanHai authored and ilixiaocui committed Dec 4, 2020
1 parent 2404e5f commit b7f7188
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
11 changes: 10 additions & 1 deletion k8s/nbd/nbd-package/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ set -e

chmod +x /usr/bin/mount_curve_clouddisk.sh

# default confpath
confPath=/etc/nbd/k8s_curve.conf

filename=$HOSTNAME"_curvefile"
sed -i "s/filename=curvefile/filename=$filename/g" /etc/nbd/k8s_curve.conf

if [ ! -f ${confPath} ]
then
echo "ERROR: not found configuration file, confPath is ${confPath}!"
exit
fi
sed -i "s/filename=curvefile/filename=$filename/g" $confPath

systemctl daemon-reload
systemctl enable create_curve_volume.service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,25 @@ function run() {
if [ "$hasmount" ]
then
sudo umount $nbddevice
hasmount=$(df -T | grep ${nbddevice})
if [ "$hasmount" ]
then
echo "ERROR: umount nbddevice failed!"
else
echo "umount nbddevice success"
fi
fi

if [ "$nbddevice" ]
then
sudo curve-nbd unmap $nbddevice
nbddevice=$(sudo curve-nbd list-mapped | grep ${filename} | cut -d " " -f 3)
if [ "$nbddevice" ]
then
echo "ERROR: unmap nbddevice failed!"
else
echo "unmap nbddevice success"
fi
fi

if [ "$curvevolume" ]
Expand All @@ -48,7 +62,13 @@ function run() {
case $input in
[yY][eE][sS]|[yY])
sudo curve delete --filename /$filename --user $user
echo "Delete curvevolume done"
curvevolume=$(sudo curve_ops_tool list --fileName=/ | grep ${filename})
if [ "$curvevolume" ]
then
echo "ERROR: delete curve volume failed!"
else
echo "delete curve volume success"
fi
;;
[nN][oO]|[nN])
exit 1
Expand All @@ -65,7 +85,6 @@ function run() {
function getOptions() {
filename=`cat ${confPath} | grep -v '#' | grep filename= | awk -F "=" '{print $2}'`
user=`cat ${confPath} | grep -v '#' | grep user= | awk -F "=" '{print $2}'`
mountpoint=`cat ${confPath} | grep -v '#' | grep mountpoint= | awk -F "=" '{print $2}'`
}

count=1
Expand Down Expand Up @@ -104,10 +123,6 @@ else
user="$2"
shift 2
;;
--mountpoint)
mountpoint="$2"
shift 2
;;
*)
usage
exit
Expand Down

0 comments on commit b7f7188

Please sign in to comment.