LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-08-2024, 10:01 PM   #16
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 289

Original Poster
Rep: Reputation: 26

Quote:
Originally Posted by michaelk View Post
sshfs is a fuse filesystem that uses the ssh/sftp subsystem. You can mount it manually, from a bash login script, autofs or even just fstab.

https://wiki.archlinux.org/title/SSHFS

You are not configuring autofs correctly. Your using different configuration files and I believe you need to use the absolute path to the share name in your auto.misc file.

/- /etc/auto.mount
versus
/etc/auto.misc

https://wiki.archlinux.org/title/autofs

Well right now my confs file content the follow :

in "/etc/auto.master", at the end of file i replace the line "#/- /etc/auto.mount" with :
Quote:
/cifs /etc/auto.cifs --timeout=60
cat /etc/auto.cifs
Quote:
Inukaze --fstype=cifs,vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL ://192.168.1.10/Inukaze
Inukaze-en-Familia --fstype=cifs,vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL ://192.168.1.10/Inukaze-en-Familia
Temporal --fstype=cifs,vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL ://192.168.1.10/Temporal
Josmar --fstype=cifs,vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL ://192.168.1.10/Josmar
SSD-Gaby --fstype=cifs,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL ://192.168.1.11/SSD-Gaby
Code:
/etc/rc.d/rc.autofs stop
Quote:
Stopping automount: done.
Code:
automount -f -v --debug
Quote:
Starting automounter version 5.1.8, master map auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
lookup_read_master: lookup(file): read entry /misc
lookup_read_master: lookup(file): read entry /net
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /cifs
master_do_mount: mounting /misc
automount_path_to_fifo: fifo name /run/autofs.fifo-misc
lookup_nss_read_map: reading map file /etc/auto.misc
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
mounted indirect on /misc with timeout 300, freq 75 seconds
st_ready: st_ready(): state = 0 path /misc
master_do_mount: mounting /net
automount_path_to_fifo: fifo name /run/autofs.fifo-net
lookup_nss_read_map: reading map hosts (null)
do_init: parse(sun): init gathered global options: (null)
lookup_read_map: lookup(hosts): read hosts map
lookup_read_map: lookup(hosts): map not browsable, update existing host entries only
mounted indirect on /net with timeout 300, freq 75 seconds
st_ready: st_ready(): state = 0 path /net
master_do_mount: mounting /cifs
automount_path_to_fifo: fifo name /run/autofs.fifo-cifs
lookup_nss_read_map: reading map file /etc/auto.cifs
do_init: parse(sun): init gathered global options: (null)
mounted indirect on /cifs with timeout 60, freq 15 seconds
st_ready: st_ready(): state = 0 path /cifs
Ok reading that output i see
Quote:
master_do_mount: mounting /cifs
automount_path_to_fifo: fifo name /run/autofs.fifo-cifs
lookup_nss_read_map: reading map file /etc/auto.cifs
do_init: parse(sun): init gathered global options: (null)
mounted indirect on /cifs with timeout 60, freq 15 seconds
st_ready: st_ready(): state = 0 path /cifs
Well i need search where i set the global options and why the state = 0, the folders are not mounted on /cifs, still empty folder.
 
Old 05-08-2024, 11:40 PM   #17
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 289

Original Poster
Rep: Reputation: 26
This method i cannot get it work -> https://gist.github.com/rbb/59c57d82...673afc86c84c33

nothing looks works with autofs cifs

/etc/auto.cifs
Quote:
#!/bin/bash
# $Id$
# This file must be executable to work! chmod 755!
key="$1"
# Note: create a cred file for each windows/Samba-Server in your network
# which requires password authentification. The file should contain
# exactly two lines:
# username=user
# password=*****
# Please don't use blank spaces to separate the equal sign from the
# user account name or password.
credfile="/etc/auto.smb.$key"
# Note: Use cifs instead of smbfs:
#mountopts="-fstype=cifs,file_mode=0644,dir_mode=0755,uid=user,gid=users"
mountopts="-fstype=cifs,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL"
smbclientopts=""
for P in /bin /sbin /usr/bin /usr/sbin
do
if [ -x $P/smbclient ]
then
SMBCLIENT=$P/smbclient
break
fi
done
[ -x $SMBCLIENT ] || exit 1
if [ -e "$credfile" ]
then
mountopts=$mountopts",credentials=$credfile"
smbclientopts="-A "$credfile
else
smbclientopts="-N"
fi
$SMBCLIENT $smbclientopts -gL $key 2>/dev/null \
| awk -v key="$key" -v opts="$mountopts" -F'|' -- '
BEGIN { ORS=""; first=1 }
/Disk/ { if (first) { print opts; first=0 };
gsub(/ /, "\\ ", $2);
sub(/\$/, "\\$", $2);
print " \\\n\t /" $2, "://" key "/" $2 }
END { if (!first) print "\n"; else exit 1 }
'
Code:
chmod 755 /etc/auto.cifs
/etc/auto.master
Quote:
#!/bin/bash
# $Id$
# This file must be executable to work! chmod 755!
key="$1"
# Note: create a cred file for each windows/Samba-Server in your network
# which requires password authentification. The file should contain
# exactly two lines:
# username=user
# password=*****
# Please don't use blank spaces to separate the equal sign from the
# user account name or password.
credfile="/etc/auto.smb.$key"
# Note: Use cifs instead of smbfs:
#mountopts="-fstype=cifs,file_mode=0644,dir_mode=0755,uid=user,gid=users"
mountopts="-fstype=cifs,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL"
smbclientopts=""
for P in /bin /sbin /usr/bin /usr/sbin
do
if [ -x $P/smbclient ]
then
SMBCLIENT=$P/smbclient
break
fi
done
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
#ACTIVO#/misc /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
# "nosuid" and "nodev" options unless the "suid" and "dev"
# options are explicitly given.
#
#ACTIVO#/net -hosts
#
# Include /etc/auto.master.d/*.autofs
# To add an extra map using this mechanism you will need to add
# two configuration items - one /etc/auto.master.d/extra.autofs file
# (using the same line format as the auto.master file)
# and a separate mount map (e.g. /etc/auto.extra or an auto.extra NIS map)
# that is referred to by the extra.autofs file.
#
+dir:/etc/auto.master.d
#
# If you have fedfs set up and the related binaries, either
# built as part of autofs or installed from another package,
# uncomment this line to use the fedfs program map to access
# your fedfs mounts.
#/nfs4 /usr/sbin/fedfs-map-nfs4 nobind
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master

#CIFS :
#/cifs /etc/auto.cifs
#/cifs /etc/auto.cifs --timeout=60
/- /etc/auto.cifs /cifs
/etc/auto.cifs-shares
Quote:
/cifs/Edna/SSD-Gaby 192.168.1.11:/SSD-Gaby
/cifs/Geremia/Inukaze -vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Inukaze
/cifs/Geremia/Temporal -vers=1.0 ://192.168.1.10/Temporal
Code:
automount -f -v --debug
Quote:
Starting automounter version 5.1.8, master map auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /-
master_do_mount: mounting /-
automount_path_to_fifo: fifo name /run/autofs.fifo--
lookup_nss_read_map: reading map file /etc/auto.cifs
Starting automounter version 5.1.8, master map auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /-
/
master_do_mount: mounting /-
automount_path_to_fifo: fifo name /run/autofs.fifo--
lookup_nss_read_map: reading map file /etc/auto.cifs
do_init: parse(sun): init gathered global options: cifs
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
st_ready: st_ready(): state = 0 path /-
Starting automounter version 5.1.8, master map auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /-
/
#!/bin/bash
# $Id$
# This file must be executable to work! chmod 755!
key="$1"
# Note: create a cred file for each windows/Samba-Server in your network
# which requires password authentification. The file should contain
# exactly two lines:
# username=user
# password=*****
# Please don't use blank spaces to separate the equal sign from the
# user account name or password.
credfile="/etc/auto.smb.$key"
# Note: Use cifs instead of smbfs:
#mountopts="-fstype=cifs,file_mode=0644,dir_mode=0755,uid=user,gid=users"
mountopts="-fstype=cifs,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL"
smbclientopts=""
for P in /bin /sbin /usr/bin /usr/sbin
do
if [ -x $P/smbclient ]
then
SMBCLIENT=$P/smbclient
break
fi
done
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
#ACTIVO#/misc /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
# "nosuid" and "nodev" options unless the "suid" and "dev"
# options are explicitly given.
#
#ACTIVO#/net -hosts
#
# Include /etc/auto.master.d/*.autofs
# To add an extra map using this mechanism you will need to add
# two configuration items - one /etc/auto.master.d/extra.autofs file
# (using the same line format as the auto.master file)
# and a separate mount map (e.g. /etc/auto.extra or an auto.extra NIS map)
# that is referred to by the extra.autofs file.
#
+dir:/etc/auto.master.d
#
# If you have fedfs set up and the related binaries, either
# built as part of autofs or installed from another package,
# uncomment this line to use the fedfs program map to access
# your fedfs mounts.
#/nfs4 /usr/sbin/fedfs-map-nfs4 nobind
#
# Include central master map if it can be found using
# nsswitch sources.
#
Starting automounter version 5.1.8, master map auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /-
/
master_do_mount: mounting /-
automount_path_to_fifo: fifo name /run/autofs.fifo--
lookup_nss_read_map: reading map file /etc/auto.cifs
do_init: parse(sun): init gathered global options: cifs
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
st_ready: st_ready(): state = 0 path /-
Code:
ls -als -R /cifs/
Quote:
/cifs/:
total 16
4 drwxr-xr-x 4 inukaze users 4096 may 8 23:57 ./
4 drwxr-xr-x 24 root root 4096 may 8 23:03 ../
4 drwxr-xr-x 3 root root 4096 may 8 23:57 Edna/
4 drwxr-xr-x 4 root root 4096 may 8 23:58 Geremia/

/cifs/Edna:
total 12
4 drwxr-xr-x 3 root root 4096 may 8 23:57 ./
4 drwxr-xr-x 4 inukaze users 4096 may 8 23:57 ../
4 drwxr-xr-x 2 root root 4096 may 8 23:57 SSD-Gaby/

/cifs/Edna/SSD-Gaby:
total 8
4 drwxr-xr-x 2 root root 4096 may 8 23:57 ./
4 drwxr-xr-x 3 root root 4096 may 8 23:57 ../

/cifs/Geremia:
total 16
4 drwxr-xr-x 4 root root 4096 may 8 23:58 ./
4 drwxr-xr-x 4 inukaze users 4096 may 8 23:57 ../
4 drwxr-xr-x 2 root root 4096 may 8 23:57 Inukaze/
4 drwxr-xr-x 2 root root 4096 may 8 23:58 Temporal/

/cifs/Geremia/Inukaze:
total 8
4 drwxr-xr-x 2 root root 4096 may 8 23:57 ./
4 drwxr-xr-x 4 root root 4096 may 8 23:58 ../

/cifs/Geremia/Temporal:
total 8
4 drwxr-xr-x 2 root root 4096 may 8 23:58 ./
4 drwxr-xr-x 4 root root 4096 may 8 23:58 ../
i think is better remove autofs, looks like really does not work, because i try like

manual explain -> https://linux.die.net/man/8/autofs
manual explain -> https://linux.die.net/man/5/autofs
manual explain -> https://linux.die.net/man/8/automount
archwiki explain -> https://wiki.archlinux.org/title/autofs
gentoo book explain -> https://wiki.gentoo.org/wiki/AutoFS#....2Fautofs.conf
github tutorial -> https://gist.github.com/rbb/59c57d82...673afc86c84c33
linux mint forum -> https://forums.linuxmint.com/viewtopic.php?t=252261

on each try, the mount points ever are empty.


The latest thing i try was :
/etc/auto.cifs content :
Quote:
/cifs/Edna/SSD-Gaby -fstype=cifs,credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.11:/SSD-Gaby
/cifs/Geremia/Inukaze -fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Inukaze
/cifs/Geremia/Temporal -fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Temporal
Code:
reset ; automount -f -v --debug
Quote:
Starting automounter version 5.1.8, master map auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
lookup_read_master: lookup(file): read entry /misc
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /-
/
master_do_mount: mounting /misc
automount_path_to_fifo: fifo name /run/autofs.fifo-misc
lookup_nss_read_map: reading map file /etc/auto.misc
do_init: parse(sun): init gathered global options: (null)
spawn_mount: mtab link detected, passing -n to mount
spawn_umount: mtab link detected, passing -n to mount
mounted indirect on /misc with timeout 300, freq 75 seconds
st_ready: st_ready(): state = 0 path /misc
master_do_mount: mounting /-
automount_path_to_fifo: fifo name /run/autofs.fifo--
lookup_nss_read_map: reading map file /etc/auto.cifs
do_init: parse(sun): init gathered global options: cifs
mounted direct on /cifs/Geremia/Inukaze with timeout 300, freq 75 seconds
do_mount_autofs_direct: mounted trigger /cifs/Geremia/Inukaze
mounted direct on /cifs/Geremia/Temporal with timeout 300, freq 75 seconds
do_mount_autofs_direct: mounted trigger /cifs/Geremia/Temporal
mounted direct on /cifs/Edna/SSD-Gaby with timeout 300, freq 75 seconds
do_mount_autofs_direct: mounted trigger /cifs/Edna/SSD-Gaby
st_ready: st_ready(): state = 0 path /-
when i use on another tab the follow command :
Code:
chmod 777 -R /cifs ; chown inukaze:users -R /cifs ; ls -als -R /cifs/
ls -als -R /cifs/ output :
Quote:
/cifs/:
total 16
4 drwxrwxrwx 4 inukaze users 4096 may 9 00:48 ./
4 drwxr-xr-x 25 root root 4096 may 9 00:59 ../
4 drwxrwxrwx 3 inukaze users 4096 may 9 00:53 Edna/
4 drwxrwxrwx 4 inukaze users 4096 may 9 00:53 Geremia/

/cifs/Edna:
total 8
4 drwxrwxrwx 3 inukaze users 4096 may 9 00:53 ./
4 drwxrwxrwx 4 inukaze users 4096 may 9 00:48 ../
0 drwxr-xr-x 2 root root 0 may 9 00:59 SSD-Gaby/
ls: no se puede abrir el directorio '/cifs/Edna/SSD-Gaby': No existe el fichero o el directorio

/cifs/Geremia:
total 8
4 drwxrwxrwx 4 inukaze users 4096 may 9 00:53 ./
4 drwxrwxrwx 4 inukaze users 4096 may 9 00:48 ../
0 drwxr-xr-x 2 root root 0 may 9 00:59 Inukaze/
0 drwxr-xr-x 2 root root 0 may 9 00:59 Temporal/
ls: no se puede abrir el directorio '/cifs/Geremia/Inukaze': No existe el fichero o el directorio
ls: no se puede abrir el directorio '/cifs/Geremia/Temporal': No existe el fichero o el directorio
automount -f -v --debug add the follow lines to output :
Quote:
handle_packet: type = 5
handle_packet_missing_direct: token 266, name /cifs/Edna/SSD-Gaby, request pid 6969
attempting to mount entry /cifs/Edna/SSD-Gaby
lookup_mount: lookup(file): looking up /cifs/Edna/SSD-Gaby
lookup_mount: lookup(file): /cifs/Edna/SSD-Gaby -> -fstype=cifs,credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.11:/SSD-Gaby
parse_mount: parse(sun): expanded entry: -fstype=cifs,credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.11:/SSD-Gaby
parse_mount: parse(sun): gathered options: fstype=cifs,credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL
parse_mount: parse(sun): dequote("192.168.1.11:/SSD-Gaby") -> 192.168.1.11:/SSD-Gaby
parse_mount: parse(sun): core of entry: options=fstype=cifs,credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL , loc=192.168.1.11:/SSD-Gaby
sun_mount: parse(sun): mounting root /cifs/Edna/SSD-Gaby, mountpoint /cifs/Edna/SSD-Gaby, what 192.168.1.11:/SSD-Gaby, fstype cifs, options credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL
do_mount: 192.168.1.11:/SSD-Gaby /cifs/Edna/SSD-Gaby type cifs options credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL using module generic
mount_mount: mount(generic): calling mkdir_path /cifs/Edna/SSD-Gaby
mount(generic): calling mount -t cifs -o credentials=/home/inukaze/.smb-credenciales,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.11:/SSD-Gaby /cifs/Edna/SSD-Gaby
spawn_mount: mtab link detected, passing -n to mount
>> mount.cifs: bad UNC (192.168.1.11:/SSD-Gaby)
mount(generic): failed to mount 192.168.1.11:/SSD-Gaby (type cifs) on /cifs/Edna/SSD-Gaby
dev_ioctl_send_fail: token = 266
failed to mount /cifs/Edna/SSD-Gaby
handle_packet: type = 5
handle_packet_missing_direct: token 267, name /cifs/Geremia/Inukaze, request pid 6969
attempting to mount entry /cifs/Geremia/Inukaze
lookup_mount: lookup(file): looking up /cifs/Geremia/Inukaze
lookup_mount: lookup(file): /cifs/Geremia/Inukaze -> -fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Inukaze
parse_mount: parse(sun): expanded entry: -fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Inukaze
parse_mount: parse(sun): gathered options: fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL
parse_mount: parse(sun): dequote("192.168.1.10:/Inukaze") -> 192.168.1.10:/Inukaze
parse_mount: parse(sun): core of entry: options=fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL, loc=192.168.1.10:/Inukaze
sun_mount: parse(sun): mounting root /cifs/Geremia/Inukaze, mountpoint /cifs/Geremia/Inukaze, what 192.168.1.10:/Inukaze, fstype cifs, options -vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL
do_mount: 192.168.1.10:/Inukaze /cifs/Geremia/Inukaze type cifs options -vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL using module generic
mount_mount: mount(generic): calling mkdir_path /cifs/Geremia/Inukaze
mount(generic): calling mount -t cifs -o -vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Inukaze /cifs/Geremia/Inukaze
spawn_mount: mtab link detected, passing -n to mount
>> mount.cifs: bad UNC (192.168.1.10:/Inukaze)
mount(generic): failed to mount 192.168.1.10:/Inukaze (type cifs) on /cifs/Geremia/Inukaze
dev_ioctl_send_fail: token = 267
failed to mount /cifs/Geremia/Inukaze
handle_packet: type = 5
handle_packet_missing_direct: token 268, name /cifs/Geremia/Temporal, request pid 6969
attempting to mount entry /cifs/Geremia/Temporal
lookup_mount: lookup(file): looking up /cifs/Geremia/Temporal
lookup_mount: lookup(file): /cifs/Geremia/Temporal -> -fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Temporal
parse_mount: parse(sun): expanded entry: -fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Temporal
parse_mount: parse(sun): gathered options: fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL
parse_mount: parse(sun): dequote("192.168.1.10:/Temporal") -> 192.168.1.10:/Temporal
parse_mount: parse(sun): core of entry: options=fstype=cifs,-vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL, loc=192.168.1.10:/Temporal
sun_mount: parse(sun): mounting root /cifs/Geremia/Temporal, mountpoint /cifs/Geremia/Temporal, what 192.168.1.10:/Temporal, fstype cifs, options -vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL
do_mount: 192.168.1.10:/Temporal /cifs/Geremia/Temporal type cifs options -vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL using module generic
mount_mount: mount(generic): calling mkdir_path /cifs/Geremia/Temporal
mount(generic): calling mount -t cifs -o -vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,domain=REDLOCAL 192.168.1.10:/Temporal /cifs/Geremia/Temporal
spawn_mount: mtab link detected, passing -n to mount
>> mount.cifs: bad UNC (192.168.1.10:/Temporal)
mount(generic): failed to mount 192.168.1.10:/Temporal (type cifs) on /cifs/Geremia/Temporal
dev_ioctl_send_fail: token = 268
failed to mount /cifs/Geremia/Temporal
The mount points inside /cifs still empty.

Last edited by inukaze; 05-09-2024 at 12:08 AM.
 
Old 05-09-2024, 03:14 AM   #18
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,852

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Quote:
Originally Posted by pan64 View Post
What the heck is
Code:
$(sudo mount -t cifs .....) &
???
Quote:
Originally Posted by inukaze View Post
Manual mount of cifs type filesystem
No, it would be
Code:
sudo mount -t cifs .....
The questionable part is
Code:
$(...)
It would take the output of the command in parentheses and try to run it. You can't see the difference because by chance your sudo/mount command doesn't output anything to stdout to be run. Let's try another command, 'echo -n l; echo s' outputs 'ls'. Guess what this command does:
Code:
$(echo -n l; echo s)
It runs command 'ls'.

Maybe you have copied the line from somewhere not realizing that the dollar sign in the beginning is the bash command prompt, not to be included in the line in a script. Without the dollar sign
Code:
(commands ...) &
would be ok to run commands in a backgrounded subshell and the dollar sign in front was an accidentally copied command prompt?
 
Old 05-09-2024, 04:50 AM   #19
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 990

Rep: Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674Reputation: 674
Quote:
Originally Posted by inukaze View Post
The mount points inside /cifs still empty.
I haven't used CIFS with automount myself, only NFS. However, during the years there have been different default behavior for automounted NFS directories.

Earlier years, directories where not shown with ls until mounted and they were not mounted until entered.
Later years directories listed in automount maps has been shown before entered, I don't think that I have changed any setting to accomplish that.

Then there is the /net directory which is kind of special, example:

Code:
nazgul:/tmp> /usr/sbin/showmount -e balrog
Export list for balrog:
/mnt/hd *
nazgul:/tmp> ls /net
sauron/
nazgul:/tmp> ls /net/balrog
mnt/
nazgul:/tmp> ls /net
balrog/  sauron/
nazgul:/tmp>
The /net directory can mount any NFS server in the network, but it doesn't automatically portscan every server in the network, it will only mount servers when asked to.

However, looking at /etc/auto.net you can see that it does only support NFS servers, not CIFS servers.

regards Henrik

Last edited by henca; 05-09-2024 at 04:58 AM.
 
Old 05-09-2024, 08:58 AM   #20
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,762

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
I setup an autofs samba share on my debian box versus slack but it should work the same.

auto.master
Quote:
/- auto.test
auto.test
Quote:
/cifs/test1 -fstype=cifs,username=username,password=password,uid=1000,gid=1000 ://192.168.0.10/share_name
The correct syntax is -fstype= not --fstype=

Note that /cifs/test1 is the absolute path to the share and created with the correct permissions.

Last edited by michaelk; 05-09-2024 at 08:59 AM.
 
Old 05-09-2024, 10:05 AM   #21
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,762

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
With this method:
auto.master
Quote:
/cifs /etc/auto.test1 --timeout=60 --browse
auto.test1
Quote:
test2 -fstype=cifs,username=[username],password=[password],uid=1000,gid=1000 ://192.168.0.10/share_name
The directory test2 (/cifs/test2) is automatically created by autofs.
 
Old 05-09-2024, 02:55 PM   #22
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 289

Original Poster
Rep: Reputation: 26
Ok based on the files of the comment :

Quote:
Originally Posted by rizitis View Post
I believe you need something like these:

Add this in rc.local:
Code:
if [ -x /etc/rc.d/rc.pingtomount ]; then
    /etc/rc.d/rc.pingtomount start
fi
I left sudo in script but dont think you need sudo when you start from rc.local the daemon but you know better... visudo:
Code:
inukaze ALL=(ALL) NOPASSWD: /bin/mount, /bin/umount
modify attachments for your needs and place them to the right place.
One attachment is the script and the other rc.pingmount for /etc/rc.d/

i have write the file /etc/rc.d/rc.cifshare with the follow content :

Code:
#!/bin/sh

cifs_start() {

while :
do

Geremia=$(ping -4 -c 1 192.168.1.10 | grep -oP '\d+ received' | cut -d' ' -f1)
Edna=$(ping -4 -c 1 192.168.1.11 | grep -oP '\d+ received' | cut -d' ' -f1)

    if [[ "$Edna" == "1" ]]; then
            PC="Edna"
            IP="192.168.1.11"

            Carpeta="SSD-Gaby"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi
    fi

    if [[ "$Edna" == "0" ]]; then
            PC="Edna"
            IP="192.168.1.11"

            Carpeta="SSD-Gaby"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi
    fi

    if [[ "$Geremia" == "1" ]]; then
            PC="Geremia"
            IP="192.168.1.10"

            Carpeta="Inukaze-en-Familia"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

            Carpeta="Josmar"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

            Carpeta="Inukaze"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

            Carpeta="Temporal"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

    fi

    if [[ "$Geremia" == "0" ]]; then
            PC="Geremia"
            IP="192.168.1.10"

            Carpeta="Inukaze-en-Familia"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi

            Carpeta="Josmar"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi

            Carpeta="Inukaze"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi

            Carpeta="Temporal"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi
    fi

    sleep 60

done
}

cifs_stop() {

Geremia=$(ping -4 -c 1 192.168.1.10 | grep -oP '\d+ received' | cut -d' ' -f1)
Edna=$(ping -4 -c 1 192.168.1.11 | grep -oP '\d+ received' | cut -d' ' -f1)
PC="Edna"
IP="192.168.1.11"

Carpeta="SSD-Gaby"
Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
       umount -f -l "/cifs/$PC/$Carpeta"
fi

PC="Geremia"
IP="192.168.1.10"

Carpeta="Inukaze-en-Familia"
Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
umount -f -l "/cifs/$PC/$Carpeta"
fi

Carpeta="Josmar"
Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
umount -f -l "/cifs/$PC/$Carpeta"
fi

Carpeta="Inukaze"
Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
umount -f -l "/cifs/$PC/$Carpeta"
fi

Carpeta="Temporal"
Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
umount -f -l "/cifs/$PC/$Carpeta"
fi

}

case "$1" in
  start)
    cifs_start &
    ;;
  stop)
    cifs_stop &
    ;;
  *)
    echo "Usage: $0 start|stop"
    exit 1
    ;;
esac

exit 0
Code:
chmod 755 /etc/rc.d/rc.cifshare
Well that solve the thing with start [note stop does not fine XD], is not the most optimized method but works XD
i still i don't think how i can just use "status" for check if this script is running or not.

Last edited by inukaze; 05-09-2024 at 03:00 PM.
 
Old 05-09-2024, 03:34 PM   #23
rizitis
Member
 
Registered: Mar 2009
Location: Greece,Crete
Distribution: Slackware64-current, Slint
Posts: 676
Blog Entries: 1

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
if you prefer all in one...
try start script:
Code:
PID_FILE="/run/rc_cifshare.pid"

cifs_start() {
  if [ -f "$PID_FILE" ]; then
    PID=$(cat "$PID_FILE")
    if ps -p "$PID" > /dev/null; then
      echo "Service is already runing with PID $PID"
      return
    else
# Clean up invalid PID file
      rm -f "$PID_FILE"  
    fi
  fi
# Store the current process ID
  echo $$ > "$PID_FILE"  
  (
    while :
#continue...your script
and finish like this:
Code:
cifs_stop() {
  if [ -f "$PID_FILE" ]; then
    PID=$(cat "$PID_FILE")
    if ps -p "$PID" > /dev/null; then
      kill $PID  
    fi
    rm -f "$PID_FILE"  
  else
    echo "Service is not running"
  fi
}


case "$1" in
  start)
    cifs_start  
    ;;
  stop)
    cifs_stop  
    ;;
  status)
    if [ -f "$PID_FILE" ]; then
      PID=$(cat "$PID_FILE")
      if ps -p "$PID" > /dev/null; then
        echo "Service is running with PID $PID"
      else
        echo "Service is not running, but PID file exists"
        rm -f "$PID_FILE"  
      fi
    else
      echo "Service is not running"
    fi
    ;;
  *)
    echo "Usage: $0 start|stop|status"
    exit 1
    ;;
esac

exit 0
might works...
 
Old 05-09-2024, 03:50 PM   #24
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,762

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Your using /bin/sh i.e posix shell which means that [[ ]] is not valid syntax. The script should not work as posted.

If cifs_start is truly running as an infinite loop then cifs_stop may work but then the shares will just be mounted again or tested again at the next minute. Typically a startup script does not run as a loop.
 
1 members found this post helpful.
Old 05-09-2024, 03:53 PM   #25
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 289

Original Poster
Rep: Reputation: 26
Quote:
Originally Posted by Petri Kaukasoina View Post
No, it would be
Code:
sudo mount -t cifs .....
The questionable part is
Code:
$(...)
It would take the output of the command in parentheses and try to run it. You can't see the difference because by chance your sudo/mount command doesn't output anything to stdout to be run. Let's try another command, 'echo -n l; echo s' outputs 'ls'. Guess what this command does:
Code:
$(echo -n l; echo s)
It runs command 'ls'.

the "$(command1 ; command2) &" part is some i determinate by the hard way, making scripts ever works on every version of bash on any posix operating system compatible to make ever works. becuase with "command1 ; command2 &" on some versions of apple mac os x, just run one command or none and does not matter if "&" is at the end, the script stuck on there.

Maybe you have copied the line from somewhere not realizing that the dollar sign in the beginning is the bash command prompt, not to be included in the line in a script. Without the dollar sign
Code:
(commands ...) &
would be ok to run commands in a backgrounded subshell and the dollar sign in front was an accidentally copied command prompt?
no i never had copiad the line from somewhere, that is something i determinate by a lot of mistake making a script work under any bash version on GNU/Linux, GNU/Mach, GNU/Hurd, GNU/kFreeBSD, Apple Mac OS X, FreeBSD, GhostBSD, PCBSD.
because exist a common strict form of write code in bash works on any version, but that are not explained anywhere, because the syntax can works under GNU/Linux not necesary works under Apple Mac OS X, or in a Linux without GNU Operating System.

when you write " $() " is just for the command(s) not get out that controlled limit, on some operating system when you not specify a limit, can start a mess like write an infinity log inside /spool and you get a file with 1TB size in just 1 minute, because the command does not have nothing to limit it, for experiencies like that i had start write $(command1 ; command2) because with this the weird things does not happend, on GNU/Linux does have diferences if you write $(command1 ; command2) or"command1 ; command2) but on anothers so, yes.

Last edited by inukaze; 05-09-2024 at 04:01 PM.
 
Old 05-09-2024, 03:57 PM   #26
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 289

Original Poster
Rep: Reputation: 26
Quote:
Originally Posted by rizitis View Post
if you prefer all in one...
try start script:
Code:
PID_FILE="/run/rc_cifshare.pid"

cifs_start() {
  if [ -f "$PID_FILE" ]; then
    PID=$(cat "$PID_FILE")
    if ps -p "$PID" > /dev/null; then
      echo "Service is already runing with PID $PID"
      return
    else
# Clean up invalid PID file
      rm -f "$PID_FILE"  
    fi
  fi
# Store the current process ID
  echo $$ > "$PID_FILE"  
  (
    while :
#continue...your script
and finish like this:
Code:
cifs_stop() {
  if [ -f "$PID_FILE" ]; then
    PID=$(cat "$PID_FILE")
    if ps -p "$PID" > /dev/null; then
      kill $PID  
    fi
    rm -f "$PID_FILE"  
  else
    echo "Service is not running"
  fi
}


case "$1" in
  start)
    cifs_start  
    ;;
  stop)
    cifs_stop  
    ;;
  status)
    if [ -f "$PID_FILE" ]; then
      PID=$(cat "$PID_FILE")
      if ps -p "$PID" > /dev/null; then
        echo "Service is running with PID $PID"
      else
        echo "Service is not running, but PID file exists"
        rm -f "$PID_FILE"  
      fi
    else
      echo "Service is not running"
    fi
    ;;
  *)
    echo "Usage: $0 start|stop|status"
    exit 1
    ;;
esac

exit 0
might works...
i dont understand in where i should add the parts you had write. i am thing on the stop maybe i should use "break" or something.

Last edited by inukaze; 05-09-2024 at 03:59 PM.
 
Old 05-09-2024, 07:20 PM   #27
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 289

Original Poster
Rep: Reputation: 26
Well i have some issues to resolve

* my stop is not working i expect, the infinite loop still working

* for reasons i dont understand the mount /cifs/Geremia/Inukaze is the unique is not umounted.

* which should a better idea :
a) all in one file /etc/rc.d/rc.cifshare [ this does not work during boot ]
b) two files, /etc/rc.d/rc.cifshare just for act like daemon/service and the script with infine loop and the non-working stop statament XD.

Code:
#!/bin/sh

PID_FILE="/run/rc_cifshare.pid"
unset cifs_stop
unset cifs_start

cifs_stop() {
IP="192.168.1.10" ; PC="Geremia"

Carpeta="Inukaze" ; Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1) ; if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then umount -f -l "/cifs/$PC/$Carpeta"; fi
Carpeta="Inukaze-en-Familia" ; Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1) ; if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then umount -f -l "/cifs/$PC/$Carpeta"; fi
Carpeta="Josmar" ; Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1) ; if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then umount -f -l "/cifs/$PC/$Carpeta"; fi
Carpeta="Temporal" ; Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1) ; if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then umount -f -l "/cifs/$PC/$Carpeta"; fi

IP="192.168.1.11" ; PC="Edna"
Carpeta="SSD-Gaby"  ; Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1) ; if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then umount -f -l "/cifs/$PC/$Carpeta"; fi

  if [ -f "$PID_FILE" ]; then
    PID=$(cat "$PID_FILE")
    if ps -p "$PID" > /dev/null; then
    kill -s KILL "$PID"
    fi
    rm -f "$PID_FILE"
  else
    echo "Service is not running"
  fi
}

cifs_start() {

  if [ -f "$PID_FILE" ]; then
    PID=$(cat "$PID_FILE")
    if ps -p "$PID" > /dev/null; then
      echo "Service is already runing with PID $PID"
      return
    else
# Clean up invalid PID file
      rm -f "$PID_FILE"
    fi
  fi
# Store the current process ID
  echo $$ > "$PID_FILE"
  (

while :
do

    Entrada=$(echo "$1" | tr -s  '[:upper:]'  '[:lower:]')
    if [[ "$Entrada" == "stop" ]]
    then
        cifs_stop
        break
    fi

Geremia=$(ping -4 -c 1 192.168.1.10 | grep -oP '\d+ received' | cut -d' ' -f1)
Edna=$(ping -4 -c 1 192.168.1.11 | grep -oP '\d+ received' | cut -d' ' -f1)

    if [[ "$Edna" == "1" ]]; then
            PC="Edna"
            IP="192.168.1.11"

            Carpeta="SSD-Gaby"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi
    fi

    if [[ "$Edna" == "0" ]]; then
            PC="Edna"
            IP="192.168.1.11"

            Carpeta="SSD-Gaby"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi
    fi

    if [[ "$Geremia" == "1" ]]; then
            PC="Geremia"
            IP="192.168.1.10"

            Carpeta="Inukaze"
            #Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1 | sed 's/-en-Familia//g')
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1 | tail -n 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

            Carpeta="Inukaze-en-Familia"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

            Carpeta="Josmar"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

            Carpeta="Temporal"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [ -z "$Montura" ]; then
                mkdir -p "/cifs/$PC/$Carpeta"
                mount -t cifs "//$IP/$Carpeta" "/cifs/$PC/$Carpeta" -o "vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL"
            fi

    fi

    if [[ "$Geremia" == "0" ]]; then
            PC="Geremia"
            IP="192.168.1.10"

            Carpeta="Inukaze"
            #Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1 | sed 's/-en-Familia//g')
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1 | tail -n 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi

            # Force Manual Mount :
            # mount -t cifs //192.168.1.10/Inukaze /cifs/Geremia/Inukaze -o vers=1.0,credentials=/home/inukaze/.smb-credenciales,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=REDLOCAL

            Carpeta="Inukaze-en-Familia"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)
            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi

            Carpeta="Josmar"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi

            Carpeta="Temporal"
            Montura=$(findmnt | grep "//$IP/$Carpeta" | awk '{print $1,$2}' | cut -b 7- | cut -d " " -f 1)

            if [[ "$Montura" == "/cifs/$PC/$Carpeta" ]]; then
                umount -f -l "/cifs/$PC/$Carpeta"
            fi
    fi

    sleep 60

done
)
}

case "$1" in
  start)
    cifs_start
    ;;
  stop)
    cifs_stop
    ;;
  status)
    if [ -f "$PID_FILE" ]; then
      PID=$(cat "$PID_FILE")
      if ps -p "$PID" > /dev/null; then
        echo "Service is running with PID $PID"
      else
        echo "Service is not running, but PID file exists"
        rm -f "$PID_FILE"
      fi
    else
      echo "Service is not running"
    fi
    ;;
  *)
    echo "Usage: $0 start|stop|status"
    exit 1
    ;;
esac

exit 0

Last edited by inukaze; 05-09-2024 at 08:52 PM.
 
Old 05-09-2024, 09:36 PM   #28
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,762

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
I don't know how the script is working correctly as posted earlier your syntax is wrong. Basically all the if then statements like:
Quote:
if [[ "$Edna" == "1" ]]; then
should be
Quote:
if [ "$Edna" = "1" ]; then

Last edited by michaelk; 05-10-2024 at 04:17 PM.
 
1 members found this post helpful.
Old 05-10-2024, 02:49 AM   #29
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,981

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
yes, shellcheck reports this posix syntax issue (In POSIX sh, [[ ]] is undefined.) and other problems too.
Actually ( ) means a new process (subshell) and your while loop is running inside it. kill -s kill will terminate $pid, but not the subshell (as far as I see). By the way, would be better to use sigterm instead of sigkill. Anyway, you need to optimize this script by using functions instead of repeating the same line(s) again and again. Also would be better to format it (use for example shfmt) to make it more readable.
 
1 members found this post helpful.
Old 05-10-2024, 08:36 AM   #30
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,762

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
If you put cifs_start in the background it is going to have a different pid from the script itself which could be the reason your cifs_stop function code in #27 isn't working.
Code:
start)
cifs_start &
echo $! > "$PID_FILE"
;;
Even though you are running cifs_stop in post #27 it will not stop the start loop unless you kill that running process.

You maybe able to simply your stop script with just the following. I assume no other cifs shares are mounted.
Code:
umount -f -l -a -t cifs
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting crontab to ping gateway every minute moses0404 Linux - Newbie 10 02-25-2013 09:29 AM
[SOLVED] Configured Cron job executed every hour is instead executed every minute for 10m markings Linux - Software 4 05-13-2012 05:43 PM
I cannot ping with command 'ping IP' address but can ping with 'ping IP -I eth0' sanketmlad Linux - Networking 2 07-15-2011 05:32 AM
crontab: minute hour or hour minute anon091 Linux - Newbie 2 11-04-2009 03:09 PM
want to run program every minute, crontab???? poj Linux - General 4 09-19-2005 04:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration