Article 6MMSH I want check every minute with ping to u/mount folders on my system

I want check every minute with ping to u/mount folders on my system

by
inukaze
from LinuxQuestions.org on (#6MMSH)
Hi there

* i want make a i Daemon i to check every minute with i ping i command if the variables return 0 or 1

If 0 umount mount points
If 1 check if is already mounted and do nothing, if not mount then mount.

By the moment

Code:#Monturas CIFS :
# Para permitir eliminar archivos necesitas especificar file_mode=0777,dir_mode=0777,gid=1000,uid=1000 , el (g,u)id=1000 es del usuario guest #Porteus

Geremia=$(ping -c 1 192.168.1.10 | sed -n '5p' | cut -c 24-33)
Edna=$(ping -c 1 192.168.1.11 | sed -n '5p' | cut -c 24-33)

# Parece que tendre que darle permisos usando "sudo" desde el archivo "/etc/sudoers" para des/montar
# Especificamente esas rutas.

if [ "$Geremia" == "0 received" ]; then
sudo umount /cifs/Geremia/Inukaze
sudo umount /cifs/Geremia/Inukaze-en-Familia
sudo umount /cifs/Geremia/Temporal
sudo umount /cifs/Geremia/Josmar
fi

if [ "$Geremia" == "1 received" ]; then
#Primero crear carpetas para los puntos de montaje
mkdir -p "/cifs/Geremia/Temporal"
mkdir -p "/cifs/Geremia/Inukaze"
mkdir -p "/cifs/Geremia/Inukaze-en-Familia"
mkdir -p "/cifs/Geremia/Josmar"

$(sudo mount -t cifs //192.168.1.10/Inukaze /cifs/Geremia/Inukaze -o vers=1.0,username=user,password=user,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL) &
$(sudo mount -t cifs //192.168.1.10/Inukaze-en-Familia /cifs/Geremia/Inukaze-en-Familia -o vers=1.0,username=user,password=user,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL) &
$(sudo mount -t cifs //192.168.1.10/Temporal /cifs/Geremia/Temporal -o vers=1.0,username=user,password=user,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL) &
$(sudo mount -t cifs //192.168.1.10/Josmar /cifs/Geremia/Josmar -o vers=1.0,username=user,password=user,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL) &
fi

if [ "$Edna" == "0 received" ]; then
sudo umount /cifs/Edna/SSD-Gaby
fi

if [ "$Edna" == "1 received" ]; then
#Primero crear carpetas para los puntos de montaje
#sudo mkdir -p "/cifs/Edna/SSD-Gaby"

$(sudo mount -t cifs //192.168.1.11/SSD-Gaby /cifs/Edna/SSD-Gaby -o username=user,password=user,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL) &
fi* How put this on rc.local, because i try to use :
watch -n 60 Geremia=$(ping -c 1 192.168.1.10 | sed -n '5p' | cut -c 24-33) &
watch -n 61 Edna=$(ping -c 1 192.168.1.11 | sed -n '5p' | cut -c 24-33) &

The second command finish the first "watch" command. but i need check that
i try with crontab -e , but is doing nothing.

i already try to put on sudoers :
Code:inukaze Slack64 = NOPASSWD: /usr/bin/mount, /usr/bin/umount, /usr/bin/ifconfig, /usr/bin/mkdir, /bin/mkdir, /sbin/mount, /sbin/umountbut the mount and umount command just can be use by root user, and does not matter is on sudoers file mkdir -p /cifs/<some> every time ask for password.
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments