Mount/umount cifs

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
willithepuppy
Posts: 31
Joined: Sat 10 Mar 2018, 19:57

Mount/umount cifs

#1 Post by willithepuppy »

Oh my, the forum runs like a snail today

Unfortunately I am an absolute noob in Puppy script.
I have written two scripts. They will connect and unconnect my external hard drive.
For security, the script should unmount the disk if it is already mounted and then reconnect.

First script look like this

#/bin/bash
#if already mounted unmount
umount -a -t cifs -l
sleep 0.3
#reconnect
mount.cifs //192.168.1.107/HDD1 /root/Server -o username="root",password=""
sleep 0.3
rox /root/Server/BT/0_Filme

The second script is

#!/bin/bash
umount -a -t cifs -l

Everything works wonderfully. But of course I get in the first script (mount) an error message if the disk is not mounted yet.

I think the command should look something like this

#/bin/bash
#if already mounted unmount
If mounted
umount -a -t cifs -l
sleep 0.3
else

#connect/reconnect
mount.cifs //192.168.1.107/HDD1 /root/Server -o username="root",password=""
sleep 0.3
rox /root/Server/BT/0_Filme
endif

but this is not sciptlike Puppy.

How is it correct?

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#2 Post by don570 »

I believe your question is related to checking if a share is mounted.

Normally you can do this by typing 'df' in terminal but you want to
do it automatically with a script.

You should read this page to find how to automatically find the name of a share

http://www.murga-linux.com/puppy/viewtopic.php?t=112744

I put the final code in my fatdog_connect.sh script in
raspberry pi2 software.
http://murga-linux.com/puppy/viewtopic.php?t=106573
_____________________________________________

jafadmin
Posts: 1249
Joined: Thu 19 Mar 2009, 15:10

#3 Post by jafadmin »

Code: Select all

#!/bin/bash 

mntPt="root/Server"

IsMounted=$(mount | grep $mntPt)  # check for our mount point ..

if [ ! -z "$IsMounted" ] # String is not blank, so ..

	then echo "$mntPt exists"

  else  # then it is blank

	echo "No $mntPt"
fi 

willithepuppy
Posts: 31
Joined: Sat 10 Mar 2018, 19:57

#4 Post by willithepuppy »

Thanks for your replies. But I had to learn more of the syntax of bash commands.

A useful site I've found here

https://ss64.com/bash/

The Rest is try and error. As I see, it is similar to Basic.

And the brain is also used again. That's the most important thing.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#5 Post by don570 »

If you're new to bash programming then try
Advanced Bash guide
http://murga-linux.com/puppy/viewtopic.php?t=80501
_________________________________________

willithepuppy
Posts: 31
Joined: Sat 10 Mar 2018, 19:57

#6 Post by willithepuppy »

:D :D :D Many thanks.

Post Reply