====== Mount ====== Reload fstab ''mount -a'' ===== Creare link al nome device ===== Aggiungere script e dare permessi di esecuzione /etc/usbmount/mount.d/**01_create_label_symlink** ''chmod +x /etc/usbmount/mount.d/01_create_label_symlink'' File:01_create_label_symlink #!/bin/sh set -e # Exit if device or mountpoint is empty. test -z "$UM_DEVICE" && test -z "$UM_MOUNTPOINT" && exit 0 # get volume label name label=`blkid -s LABEL -o value $UM_DEVICE` # Ricrea sempre il link: potrebbe puntare a altro [/media/usb0][/media/usb1]... ln -sf "$UM_MOUNTPOINT" "/var/run/usbmount/$label" exit 0 Lo script legge in nome del **volume** dei device montato. E crea un link in /var/run/usbmount/NomeDelVolume ===== Permessi a tutti sulle mount ===== File:/etc/usbmount/usbmount.conf # Configuration file for the usbmount package, which mounts removable # storage devices when they are plugged in and unmounts them when they # are removed. # Change to zero to disable usbmount ENABLED=1 # Mountpoints: These directories are eligible as mointpoints for # removable storage devices. MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3 /media/usb4 /media/usb5 /media/usb6 /media/usb7" # Filesystem types: removable storage devices are only mounted if they # contain a filesystem type which is in this list. FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus" MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime" # umask 022 gives 755 permissions to the whole disk # ------------------------------------------------- FS_MOUNTOPTIONS="-fstype=vfat,gid=www-data,uid=www-data,umask=022,sync \ -fstype=ntfs,gid=www-data,uid=www-data,umask=022,sync" VERBOSE=no ==== Utilizzo dei link (1) ==== Il nome del volume utilizzato sui device e' __WWWMEDIA150__ / __WWWMEDIA930__ Indipendentemente dal mountpoint ///media/usb**0**// ///media/usb**1**// ... in /var/www/html ci sono link simbolici che puntano ai link creati col nome volume: /var/www/html/__usbwww150__ -> /var/run/usbmount/__WWWMEDIA150__ /var/www/html/__usbwww930__ -> /var/run/usbmount/__WWWMEDIA930__ ==== Utilizzo dei link (2) ==== L'utente specifico per connettersi (da fuori) in FTP/SFTP ha la particolarita' di non avere alcun permesso sulla propria /home e di non appartenere ad altri gruppi che non al suo. * Nome utente **utenteFTP** * Nome gruppo **utenteFTP** Con questi permessi puo accedere solo alla cartella ''/home/utenteFTP/ftp'' in qui ci sono due cartella (saranno il mount point) dei dischi USB ''/home/utenteFTP/ftp'' ''dr..r..r.. 2 root utenteFTP 4096 Apr 15 12:21 ftpStoreData150'' ''dr..r..r.. 2 root utenteFTP 4096 Apr 15 12:21 ftpStoreData930'' I permessi sono 444 cosi' se i dischi USB non sono montati non dovresti riuscire a scriverci sopra (eviti di scrivere sulla SD del server) e la lasci vuota __condizione essenziale per usarli come mount point__. Uno script verifica la presenza dei dischi USB (del loro mount) e crea un **loop mount** nella home di **utenteFTP** Vedi file:/var/batch/chkMountDir.sh #!/usr/bin/php ---------------------------------------- // PrnMessage ================================================================= // ----------------------------------------------------------------------------- function prnMessage($testo) { GLOBAL $sep; $msg = ""; $msg .= getAdesso(); $msg .= " ".$testo; $msg .= $sep; writeLog($msg); echo $msg; } // ---------------------------------------------------------------- // PrnTitle =================================================================== // ----------------------------------------------------------------------------- function prnTitle($testo) { GLOBAL $sep; $title = "[".__FILE__."] ".$testo; $msg = ""; $msg .= str_repeat("-", strlen($title)).$sep; $msg .= getAdesso().$sep; $msg .= $title.$sep; $msg .= str_repeat("-", strlen($title)).$sep; writeLog($msg); echo $msg; } // ----------------------------------------------------------------- // GetAdesso ================================================================== // ----------------------------------------------------------------------------- function getAdesso() { $ms = "[". // giorno-mese-anno ora:minuti:secondi date("d")."-". date("m")."-". date("Y")." ". date("H").":". date("i").":". date("s"). "]"; return $ms; } // ---------------------------------------------------------------- // GetOggi ==================================================================== // ----------------------------------------------------------------------------- function getOggi() { // giorno-mese-anno ora:minuti:secondi $ms = date("Y")."-". date("m")."-". date("d").""; return $ms; } // ------------------------------------------------------------------ // WriteLog =================================================================== // ----------------------------------------------------------------------------- function writeLog($msg) { GLOBAL $sep, $pathLog, $fileLog; $filename = $pathLog.$fileLog; $mode = "a"; if ( $handle = fopen($filename,$mode) ) { $acapo= ""; // --------------------------------- // Se non ho un [a capo] lo aggiungo // --------------------------------- $pos = strpos($msg,"\n",1); if ($pos === false) { $acapo = $sep; } fwrite($handle,$msg.$acapo); } } // ----------------------------------------------------------------- ?> Se se tutto va bene viene fatta la **mount** i percorsi __puntano ai device esterni e sono scrivibili__ ''/home/utenteFTP/ftp'' ''drwxrwxrwx 2 utenteFTP utenteFTP 4096 Apr 11 12:21 ftpStoreData150'' ''drwxrwxrwx 2 utenteFTP utenteFTP 4096 Apr 11 12:21 ftpStoreData930''