Blame tests/p_samba/samba_share_test.sh

Athmane Madjoudj 7a6852
#!/bin/sh
Athmane Madjoudj 7a6852
# Author: Athmane Madjoudj <athmanem@gmail.com>
Athmane Madjoudj 7a6852
40b4c8
if [ "$CONTAINERTEST" -eq "1" ]; then
40b4c8
    t_Log "Running in container -> SKIP"
40b4c8
    exit 0
40b4c8
fi
40b4c8
243363
t_Log "Running $0 - Samba share test."
Athmane Madjoudj 7a6852
Athmane Madjoudj 7a6852
cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
Athmane Madjoudj 7a6852
cat > /etc/samba/smb.conf <
Athmane Madjoudj 7a6852
[global] 
Athmane Madjoudj 7a6852
workgroup = wrkgrp 
Athmane Madjoudj 7a6852
netbios name = smbsrv 
c7583c
security = user
c7583c
map to guest = Bad User
Athmane Madjoudj 7a6852
Athmane Madjoudj 7a6852
[testshare]
Athmane Madjoudj 7a6852
comment = Test share
Athmane Madjoudj 7a6852
path = /srv/smb
Athmane Madjoudj 7a6852
read only = yes
Athmane Madjoudj 7a6852
guest only = yes
Athmane Madjoudj 7a6852
EOF
Athmane Madjoudj 7a6852
Athmane Madjoudj 7a6852
# Reload the config
Athmane Madjoudj 7a6852
service smb restart
Athmane Madjoudj 66dad5
sleep 2
Athmane Madjoudj 7a6852
Athmane Madjoudj 7a6852
mkdir -p /srv/smb
Athmane Madjoudj 7a6852
echo "SMB test file" > /srv/smb/test.txt
Athmane Madjoudj 7a6852
mkdir /mnt/smb
Athmane Madjoudj 7a6852
Athmane Madjoudj 7a6852
# Fix SELinux context
Athmane Madjoudj 7a6852
chcon -R -t samba_share_t /srv/smb
Athmane Madjoudj 7a6852
Athmane Madjoudj 7a6852
# Mount the share
Athmane Madjoudj 7a6852
mount -t cifs -o guest,ro //127.0.0.1/testshare /mnt/smb
Athmane Madjoudj 7a6852
sleep 1
Athmane Madjoudj 7a6852
Athmane Madjoudj 7a6852
# Test 
Athmane Madjoudj 7a6852
cat /mnt/smb/test.txt | grep 'SMB test file' > /dev/null 2>&1
Athmane Madjoudj 7a6852
Athmane Madjoudj 478755
ret_val=$?
Athmane Madjoudj 478755
 
Athmane Madjoudj 478755
# Clean up
Athmane Madjoudj 478755
umount /mnt/smb
Athmane Madjoudj 478755
/bin/rm -fr /mnt/smb
Athmane Madjoudj 478755
 
Athmane Madjoudj 478755
t_CheckExitStatus $ret_val  
Athmane Madjoudj 478755