Add shell scripts for use by nextgen generic driver
Change-Id: I96c10740f299ddc4bccdd7f538cf1417c8a09ea2
This commit is contained in:
parent
0aa0235af2
commit
ec4efbe1bb
13
server-files/usr/bin/manila-cifs-create
Executable file
13
server-files/usr/bin/manila-cifs-create
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh -e
|
||||
# manila-cifs-create <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
MNT_PATH=/shares/$NUM
|
||||
SHARE=share_$NUM
|
||||
net conf addshare $SHARE $MNT_PATH writeable=y guest_ok=y
|
||||
net conf setparm $SHARE browseable yes
|
||||
net conf setparm $SHARE "create mask" 0755
|
||||
net conf setparm $SHARE "directory mask" 0755
|
||||
|
||||
echo $SHARE
|
7
server-files/usr/bin/manila-cifs-delete
Executable file
7
server-files/usr/bin/manila-cifs-delete
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh -e
|
||||
# manila-cifs-delete <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
SHARE=share_$NUM
|
||||
net conf delshare $SHARE
|
16
server-files/usr/bin/manila-cifs-resume
Executable file
16
server-files/usr/bin/manila-cifs-resume
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh -e
|
||||
# manila-cifs-resume <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
MNT_PATH=/shares/$NUM
|
||||
SHARE=share_$NUM
|
||||
net conf addshare $SHARE $MNT_PATH writeable=y guest_ok=y
|
||||
PARMS_FILE=/metadata/$NUM/offline.parms
|
||||
cat $PARMS_FILE | while read line
|
||||
do
|
||||
PARAM=$(echo $line | sed 's/\([^=]*\)=.*/\1/' | awk '{$1=$1;print}')
|
||||
VALUE=$(echo $line | sed 's/.*=\([^=]*\)/\1/' | awk '{$1=$1;print}')
|
||||
net conf setparm $SHARE "$PARAM" "$VALUE"
|
||||
done
|
||||
rm $PARMS_FILE
|
8
server-files/usr/bin/manila-cifs-suspend
Executable file
8
server-files/usr/bin/manila-cifs-suspend
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh -e
|
||||
# manila-cifs-suspend <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
SHARE=share_$NUM
|
||||
net conf showshare $SHARE | sed '/^\[/d' > /metadata/$NUM/offline.parms
|
||||
net conf delshare $SHARE
|
14
server-files/usr/bin/manila-cifs-update
Executable file
14
server-files/usr/bin/manila-cifs-update
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh -e
|
||||
# manila-cifs-update <cookie> <parms-file>
|
||||
|
||||
NUM=$1
|
||||
PARMS_FILE=$2
|
||||
|
||||
SHARE=share_$NUM
|
||||
cat $PARMS_FILE | while read line
|
||||
do
|
||||
PARAM=$(echo $line | sed 's/\([^=]*\)=.*/\1/' | awk '{$1=$1;print}')
|
||||
VALUE=$(echo $line | sed 's/.*=\([^=]*\)/\1/' | awk '{$1=$1;print}')
|
||||
net conf setparm $SHARE "$PARAM" "$VALUE"
|
||||
done
|
||||
rm $PARMS_FILE
|
7
server-files/usr/bin/manila-init
Executable file
7
server-files/usr/bin/manila-init
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh -e
|
||||
# manila-init
|
||||
|
||||
if ! pdbedit -L | grep root
|
||||
then
|
||||
printf "root\nroot\n" | smbpasswd -a -s root
|
||||
fi
|
11
server-files/usr/bin/manila-mkfs
Executable file
11
server-files/usr/bin/manila-mkfs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh -e
|
||||
# manila-mkfs <device-path>
|
||||
|
||||
DEVICE=$1
|
||||
|
||||
while [ ! -b $DEVICE ]
|
||||
do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
mkfs.ext2 $DEVICE > /dev/null
|
32
server-files/usr/bin/manila-mount
Executable file
32
server-files/usr/bin/manila-mount
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh -e
|
||||
# manila-mount <device-path> <share-uuid>
|
||||
|
||||
DEVICE=$1
|
||||
UUID=$2
|
||||
|
||||
tune2fs -U $UUID $DEVICE > /dev/null
|
||||
mkdir -p /shares
|
||||
chmod 775 /shares
|
||||
|
||||
while true
|
||||
do
|
||||
last=$(cd /shares ; ls | sort -n | tail -n 1)
|
||||
NUM=$((last+1))
|
||||
MNT_PATH=/shares/$NUM
|
||||
if mkdir $MNT_PATH
|
||||
then
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
|
||||
chmod 000 $MNT_PATH
|
||||
|
||||
mkdir -p /metadata/$NUM
|
||||
echo $UUID > /metadata/$NUM/UUID
|
||||
|
||||
echo UUID=$UUID $MNT_PATH ext2 rw 0 2 >> /etc/fstab
|
||||
mount -a
|
||||
chmod 775 $MNT_PATH
|
||||
echo $NUM
|
11
server-files/usr/bin/manila-nfs-create
Executable file
11
server-files/usr/bin/manila-nfs-create
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh -e
|
||||
# manila-nfs-create <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
mkdir -p /etc/exports.d
|
||||
EXPORTS_FILE=/etc/exports.d/$NUM.exports
|
||||
rm -f $EXPORTS_FILE
|
||||
touch $EXPORTS_FILE
|
||||
|
||||
echo /shares/$NUM
|
7
server-files/usr/bin/manila-nfs-delete
Executable file
7
server-files/usr/bin/manila-nfs-delete
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh -e
|
||||
# manila-nfs-delete <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
rm -f /etc/exports.d/$NUM.exports
|
||||
exportfs -r
|
7
server-files/usr/bin/manila-nfs-resume
Executable file
7
server-files/usr/bin/manila-nfs-resume
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh -e
|
||||
# manila-nfs-resume <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
mv /metadata/$NUM/offline.exports /etc/exports.d/$NUM.exports
|
||||
exportfs -r
|
7
server-files/usr/bin/manila-nfs-suspend
Executable file
7
server-files/usr/bin/manila-nfs-suspend
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh -e
|
||||
# manila-nfs-suspend <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
mv /etc/exports.d/$NUM.exports /metadata/$NUM/offline.exports
|
||||
exportfs -r
|
9
server-files/usr/bin/manila-nfs-update
Executable file
9
server-files/usr/bin/manila-nfs-update
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh -e
|
||||
# manila-nfs-update <cookie> <exports-file>
|
||||
|
||||
NUM=$1
|
||||
EXPORTS_FILE=$2
|
||||
|
||||
EXPORTS_FILE2=/etc/exports.d/$NUM.exports
|
||||
mv -f $EXPORTS_FILE $EXPORTS_FILE2
|
||||
exportfs -r
|
13
server-files/usr/bin/manila-post-extend
Executable file
13
server-files/usr/bin/manila-post-extend
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh -e
|
||||
# manila-post-extend <cookie> <device-path>
|
||||
|
||||
NUM=$1
|
||||
DEVICE=$2
|
||||
|
||||
e2fsck -pf $DEVICE
|
||||
resize2fs $DEVICE
|
||||
|
||||
UUID=$(cat /metadata/$NUM/UUID)
|
||||
MNT_PATH=/shares/$NUM
|
||||
echo UUID=$UUID $MNT_PATH ext2 rw 0 2 >> /etc/fstab
|
||||
mount -a
|
10
server-files/usr/bin/manila-pre-extend
Executable file
10
server-files/usr/bin/manila-pre-extend
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh -e
|
||||
# manila-pre-extend <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
UUID=$(cat /metadata/$NUM/UUID)
|
||||
sed "/$UUID/d" -i /etc/fstab
|
||||
|
||||
MNT_PATH=/shares/$NUM
|
||||
umount $MNT_PATH
|
15
server-files/usr/bin/manila-shrink
Executable file
15
server-files/usr/bin/manila-shrink
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh -e
|
||||
# manila-shrink <cookie> <device> <size-in-gb>
|
||||
|
||||
NUM=$1
|
||||
DEVICE=$2
|
||||
SIZE_GB=$3
|
||||
|
||||
UUID=$(cat /metadata/$NUM/UUID)
|
||||
sed "/$UUID/d" -i /etc/fstab
|
||||
MNT_PATH=/shares/$NUM
|
||||
umount $MNT_PATH
|
||||
e2fsck -pf $DEVICE
|
||||
resize2fs $DEVICE ${SIZE_GB}G
|
||||
echo UUID=$UUID $MNT_PATH ext2 rw 0 2 >> /etc/fstab
|
||||
mount -a
|
10
server-files/usr/bin/manila-unmount
Executable file
10
server-files/usr/bin/manila-unmount
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh -e
|
||||
# manila-unmount <cookie>
|
||||
|
||||
NUM=$1
|
||||
|
||||
UUID=$(cat /metadata/$NUM/UUID)
|
||||
MNT_PATH=$(grep $UUID /etc/fstab | awk '{print $2}')
|
||||
sed /$UUID/d -i /etc/fstab
|
||||
umount $MNT_PATH
|
||||
rmdir $MNT_PATH
|
Loading…
x
Reference in New Issue
Block a user