chicco:software:mount
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente | ||
| chicco:software:mount [2019/04/11 18:25] – admwiki | chicco:software:mount [2020/09/16 20:37] (versione attuale) – modifica esterna 127.0.0.1 | ||
|---|---|---|---|
| Linea 1: | Linea 1: | ||
| + | ====== Mount ====== | ||
| + | Reload fstab | ||
| + | |||
| + | '' | ||
| + | |||
| + | ===== Creare link al nome device ===== | ||
| + | |||
| + | Aggiungere script e dare permessi di esecuzione | ||
| + | |||
| + | / | ||
| + | |||
| + | '' | ||
| + | |||
| + | File: | ||
| + | <sxh bash> | ||
| + | #!/bin/sh | ||
| + | set -e | ||
| + | |||
| + | # Exit if device or mountpoint is empty. | ||
| + | test -z " | ||
| + | |||
| + | # get volume label name | ||
| + | label=`blkid -s LABEL -o value $UM_DEVICE` | ||
| + | |||
| + | # Ricrea sempre il link: potrebbe puntare a altro [/ | ||
| + | ln -sf " | ||
| + | |||
| + | exit 0 | ||
| + | </ | ||
| + | |||
| + | Lo script legge in nome del **volume** dei device montato. | ||
| + | |||
| + | E crea un link in / | ||
| + | |||
| + | ===== Permessi a tutti sulle mount ===== | ||
| + | |||
| + | File:/ | ||
| + | <sxh bash> | ||
| + | # 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: | ||
| + | # removable storage devices. | ||
| + | MOUNTPOINTS="/ | ||
| + | / | ||
| + | |||
| + | # Filesystem types: removable storage devices are only mounted if they | ||
| + | # contain a filesystem type which is in this list. | ||
| + | FILESYSTEMS=" | ||
| + | |||
| + | MOUNTOPTIONS=" | ||
| + | |||
| + | # umask 022 gives 755 permissions to the whole disk | ||
| + | # ------------------------------------------------- | ||
| + | FS_MOUNTOPTIONS=" | ||
| + | | ||
| + | |||
| + | VERBOSE=no | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Utilizzo dei link (1) ==== | ||
| + | |||
| + | Il nome del volume utilizzato sui device e' __WWWMEDIA150__ / __WWWMEDIA930__ | ||
| + | |||
| + | Indipendentemente dal mountpoint /// | ||
| + | |||
| + | / | ||
| + | |||
| + | / | ||
| + | |||
| + | ==== Utilizzo dei link (2) ==== | ||
| + | |||
| + | L' | ||
| + | |||
| + | * Nome utente **utenteFTP** | ||
| + | * Nome gruppo **utenteFTP** | ||
| + | |||
| + | Con questi permessi puo accedere solo alla cartella ''/ | ||
| + | |||
| + | ''/ | ||
| + | |||
| + | '' | ||
| + | |||
| + | '' | ||
| + | |||
| + | 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:/ | ||
| + | <sxh php; highlight: [59-66]> | ||
| + | # | ||
| + | <?php | ||
| + | GLOBAL $sep, $pathLog, $fileLog; | ||
| + | $sep = " | ||
| + | |||
| + | // -------------------- | ||
| + | // Path del file di log | ||
| + | // Nome del file di log | ||
| + | // -------------------- | ||
| + | $pathLog = "/ | ||
| + | $fileLog = " | ||
| + | |||
| + | // -------------- | ||
| + | // Inizio log | ||
| + | // -------------- | ||
| + | prnTitle(" | ||
| + | |||
| + | // --------------- | ||
| + | // Primo controllo | ||
| + | // --------------- | ||
| + | // ---------------------------- | ||
| + | // Path del link al disco USB | ||
| + | // Il link da verificare/ | ||
| + | // ---------------------------- | ||
| + | $pathHD | ||
| + | $pathTarget = "/ | ||
| + | checkFolderFTP_1($pathHD, | ||
| + | |||
| + | // --- | ||
| + | $pathHD | ||
| + | $pathTarget = "/ | ||
| + | checkFolderFTP_1($pathHD, | ||
| + | |||
| + | // -------------- | ||
| + | // Chiusura log | ||
| + | // -------------- | ||
| + | prnTitle(" | ||
| + | |||
| + | die; | ||
| + | // ############################################################################# | ||
| + | // Sotto solo funzioni | ||
| + | // ############################################################################# | ||
| + | // CheckFolderFTP_1 | ||
| + | // Se e' presente disco USB con etichetta WWWMEDIA150 viene creato il link | ||
| + | // / | ||
| + | // Questa funzione crea un loop link con [mount --bind] alla home di [utenteFTP] | ||
| + | // [utenteFTP] e' l' | ||
| + | // param@pathHD | ||
| + | // param@pathTarget - Il link da verificare/ | ||
| + | // ----------------------------------------------------------------------------- | ||
| + | function checkFolderFTP_1($pathHD, | ||
| + | prnMessage(__FUNCTION__." | ||
| + | |||
| + | // -------------------------- | ||
| + | // Path del link al disco USB | ||
| + | // -------------------------- | ||
| + | $fileChk = " | ||
| + | |||
| + | // ----------------------------------- | ||
| + | // Comando eseguito (comando di mount) | ||
| + | // ----------------------------------- | ||
| + | $cmd = "mount --bind"; | ||
| + | $cmd .= " "; | ||
| + | $cmd .= $pathHD; | ||
| + | $cmd .= " "; | ||
| + | $cmd .= $pathTarget; | ||
| + | |||
| + | // ----------------- | ||
| + | // Path di partenza | ||
| + | // ----------------- | ||
| + | $is_lnkHD = is_dir($pathHD); | ||
| + | if ( $is_lnkHD ) { | ||
| + | prnMessage(" | ||
| + | } else { | ||
| + | prnMessage(" | ||
| + | } | ||
| + | |||
| + | // --------------------- | ||
| + | // File di controllo | ||
| + | // Nel folder dipartenza | ||
| + | // --------------------- | ||
| + | $is_fChk = file_exists($pathHD."/" | ||
| + | if ( $is_fChk ) { | ||
| + | prnMessage(" | ||
| + | } else { | ||
| + | prnMessage(" | ||
| + | } | ||
| + | // ----------------- | ||
| + | // Path di arrivo | ||
| + | // ----------------- | ||
| + | $is_target = is_dir($pathTarget); | ||
| + | if ( $is_target ) { | ||
| + | prnMessage(" | ||
| + | } else { | ||
| + | prnMessage(" | ||
| + | } | ||
| + | |||
| + | // --------------------- | ||
| + | // File di controllo | ||
| + | // Nel folder di arrivo | ||
| + | // --------------------- | ||
| + | $target_file = file_exists($pathTarget."/" | ||
| + | if ( $target_file ) { | ||
| + | prnMessage(" | ||
| + | } else { | ||
| + | prnMessage(" | ||
| + | } | ||
| + | |||
| + | // --------------------------------------- | ||
| + | // Esiste il folder e il file di controllo | ||
| + | // --------------------------------------- | ||
| + | if ( $is_lnkHD && $is_fChk ) { | ||
| + | // --------------------------------------- | ||
| + | // Non esiste il link | ||
| + | // Non esite il file di controllo nel link | ||
| + | // --------------------------------------- | ||
| + | if ( !$is_target || !$target_file ) { | ||
| + | prnMessage(" | ||
| + | |||
| + | prnMessage(" | ||
| + | $risu = Array(); | ||
| + | |||
| + | // ----------------- | ||
| + | // Eseguo il comando | ||
| + | // ----------------- | ||
| + | exec($cmd, | ||
| + | |||
| + | |||
| + | // ----------------- | ||
| + | // Log del risultato | ||
| + | // ----------------- | ||
| + | for ($i=0; $i< | ||
| + | prnMessage(str_pad($i, | ||
| + | } | ||
| + | |||
| + | // ----------------------------------- | ||
| + | // Verifico se il MOUNT e' andato bene | ||
| + | // ----------------------------------- | ||
| + | prnMessage(" | ||
| + | |||
| + | // ----------------- | ||
| + | // Path di arrivo | ||
| + | // ----------------- | ||
| + | $is_target = is_dir($pathTarget); | ||
| + | if ( $is_target ) { | ||
| + | prnMessage(" | ||
| + | } else { | ||
| + | prnMessage(" | ||
| + | } | ||
| + | // --------------------- | ||
| + | // File di controllo | ||
| + | // Nel folder di arrivo | ||
| + | // --------------------- | ||
| + | $target_file = is_file($pathTarget."/" | ||
| + | if ( $target_file ) { | ||
| + | prnMessage(" | ||
| + | } else { | ||
| + | prnMessage(" | ||
| + | } | ||
| + | // ------------------------ | ||
| + | // I permessi alla cartella | ||
| + | // ------------------------ | ||
| + | if ( $is_target && $target_file ) { | ||
| + | $cmd = "chmod 777 " | ||
| + | prnMessage(" | ||
| + | $risu = Array(); | ||
| + | |||
| + | // ----------------- | ||
| + | // Eseguo il comando | ||
| + | // ----------------- | ||
| + | exec($cmd, | ||
| + | |||
| + | // ----------------- | ||
| + | // Log del risultato | ||
| + | // ----------------- | ||
| + | |||
| + | for ($i=0; $i< | ||
| + | prnMessage(str_pad($i, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | } else { | ||
| + | if ( $is_target && $target_file ) { | ||
| + | prnMessage(" | ||
| + | } | ||
| + | } | ||
| + | |||
| + | prnMessage(__FUNCTION__." | ||
| + | } // -------------------< | ||
| + | |||
| + | // PrnMessage | ||
| + | // ----------------------------------------------------------------------------- | ||
| + | function prnMessage($testo) { | ||
| + | GLOBAL $sep; | ||
| + | |||
| + | $msg = ""; | ||
| + | $msg .= getAdesso(); | ||
| + | $msg .= " " | ||
| + | $msg .= $sep; | ||
| + | |||
| + | writeLog($msg); | ||
| + | echo $msg; | ||
| + | } // -------------------< | ||
| + | |||
| + | // PrnTitle | ||
| + | // ----------------------------------------------------------------------------- | ||
| + | function prnTitle($testo) { | ||
| + | GLOBAL $sep; | ||
| + | |||
| + | $title = " | ||
| + | $msg = ""; | ||
| + | $msg .= str_repeat(" | ||
| + | $msg .= getAdesso().$sep; | ||
| + | $msg .= $title.$sep; | ||
| + | $msg .= str_repeat(" | ||
| + | |||
| + | writeLog($msg); | ||
| + | echo $msg; | ||
| + | } // -------------------< | ||
| + | |||
| + | // GetAdesso | ||
| + | // ----------------------------------------------------------------------------- | ||
| + | function getAdesso() { | ||
| + | |||
| + | $ms = " | ||
| + | // giorno-mese-anno ora: | ||
| + | date(" | ||
| + | date(" | ||
| + | date(" | ||
| + | date(" | ||
| + | date(" | ||
| + | date(" | ||
| + | " | ||
| + | |||
| + | return $ms; | ||
| + | } // ------------------< | ||
| + | |||
| + | // GetOggi | ||
| + | // ----------------------------------------------------------------------------- | ||
| + | function getOggi() { | ||
| + | |||
| + | // giorno-mese-anno ora: | ||
| + | $ms = date(" | ||
| + | date(" | ||
| + | date(" | ||
| + | |||
| + | return $ms; | ||
| + | } // ------------------< | ||
| + | |||
| + | // WriteLog | ||
| + | // ----------------------------------------------------------------------------- | ||
| + | function writeLog($msg) { | ||
| + | GLOBAL $sep, $pathLog, $fileLog; | ||
| + | |||
| + | $filename = $pathLog.$fileLog; | ||
| + | $mode = " | ||
| + | if ( $handle = fopen($filename, | ||
| + | $acapo= ""; | ||
| + | // --------------------------------- | ||
| + | // Se non ho un [a capo] lo aggiungo | ||
| + | // --------------------------------- | ||
| + | $pos = strpos($msg," | ||
| + | if ($pos === false) { | ||
| + | $acapo = $sep; | ||
| + | } | ||
| + | |||
| + | fwrite($handle, | ||
| + | } | ||
| + | |||
| + | } // -------------------< | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Se se tutto va bene viene fatta la **mount** i percorsi __puntano ai device esterni e sono scrivibili__ | ||
| + | |||
| + | ''/ | ||
| + | |||
| + | '' | ||
| + | |||
| + | '' | ||
