it-artikel:linux:mv-iso2vmwarestorage.sh-verschiebt-automatisch-cd-image-dateien-sofern-vorhanden-an-einen-festen-ort-im-vmware-storage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

it-artikel:linux:mv-iso2vmwarestorage.sh-verschiebt-automatisch-cd-image-dateien-sofern-vorhanden-an-einen-festen-ort-im-vmware-storage [2022-08-31 12:30] – created - external edit 127.0.0.1it-artikel:linux:mv-iso2vmwarestorage.sh-verschiebt-automatisch-cd-image-dateien-sofern-vorhanden-an-einen-festen-ort-im-vmware-storage [2023-01-21 14:45] (current) – removed axel.werner.1973@gmail.com
Line 1: Line 1:
-====== mv-iso2vmwarestorage.sh - Verschiebt automatisch CD-Image-Dateien (sofern vorhanden) an einen festen Ort im VMWARE Storage ====== 
  
-Ein Administrator will es so einfach und bequem wie irgend möglich haben. Wenn man z.B. öffters unter VMWARE Server neue Betriebsysteme und Boot-CDs ausprobieren möchte und man diese gerne direkt als ISO Image nutzt, möchte ich diese ISO Images ungern jedes mal per FTP oder SCP umständlich hochladen und  anschließend auch noch die Filesystem Rechte anpassen müssen wenns auch bequemer mit SAMBA geht. In meinem Fall haben alle Benutzerkonten Homedirectories welche per Default freigegeben sind. d.h. diese Shares sind bereits vorhanden und können als normaler Benutzer genutzt werden.  
- 
-Dieses Script (über /etc/crontab) regelmäßig aufgerufen, geht nun hin und untersucht einen speziellen Ordner eines speziellen vordefinierten Benutzers und schaut dort nach ob ein neues ISO File zum verschieben vorhanden ist. Falls ein ISO File gefunden wird, wird zuvor noch überprüft ob dieses File auch bereits "unangetastet" d.h. nicht durch andere Programme geöffnet ist (z.B. durch einen noch andauernden samba upload). Danach wird es in das vorgegebene Zielverzeichniss verschoben, die FS Rechte werden angepasst und das wars. 
- 
-So kann ich als normaler Benutzer mir bequem ISO Files an einen Ort verschieben lassen an welchem eigentlich nur ROOT zugriff hat.  
- 
- --- //[[mail@awerner.myhome-server.de|Axel Werner]] 2009-08-22 13:58// 
- 
-===== /etc/crontab ===== 
-<code> 
-... 
-# m h dom mon dow user command 
-* * * * * root /sbin/mv-iso2vmwarestorage.sh /home/awerner/Desktop/ToVMWAREwithLove/ /vmware/ISOs/ 
-... 
-</code> 
- 
- 
-===== /sbin/mv-iso2vmwarestorage.sh ===== 
-<code> 
-#!/bin/sh 
-########################### 
-# Script to move ISO Files from one location to another if file is untouched 
-# this script is supposed to be used with cron every minute 
-# 
-# It Requires: fuser and binutils 
-# 
-# 
-# Version 1.02// 2008-12-27 by Axel Werner [mail@awerner.myhome-server.de] 
-# 
-#Changes/Updates: 
-#2008-12-23 v1.01 removed a lot of verbose output so cron wont send mails every time. 
-#2008-12-27 v1.02 fix: script cant handle files with whitespace in it. 
-# 
-# 
-VERSION="$0 - Version 1.02\n\n" 
- 
-if [ $# != 2 ]; then 
- echo $VERSION 
- echo "\nUsage: $0 <SOURCE PATH> <DESTINATION Path>\n" 
- echo "<SOURCE PATH> is the Path to a directory that contains ISO CD/DVD Images that are" 
- echo "supposed to be moved to the <DESTINATION PATH> directory." 
- echo "\n\nExample: $0 /home/user/Desktop/ToVMWAREwithLove /HDC6/vmware" 
- echo "\n\nREQUIREMENTS: This Script requires the \'fuser\' tool to be installed." 
- exit 127 
-fi 
- 
-SOURCE="${1%/}" 
-DEST="${2%/}" 
- 
-#echo "$0: SOURCE Directory is set to \"$SOURCE\"" 
-#echo "$0: DESTINATION Directory is set to \"$DEST\"" 
- 
- 
-if [ ! -d $DEST ]; then 
- echo $VERSION 
- echo "$0: Destination Directory \"$DEST\" not found." 
- exit 127 
-fi 
- 
-if [ ! -d $SOURCE ]; then 
- echo $VERSION 
- echo "$0: Source Directory \"$SOURCE\" not found. Creating Source Directory for you..." 
- mkdir -vp $SOURCE 
- chmod ugo+rwx $SOURCE 
- echo "$0: Exiting now, since there is no more work to do for me." 
- exit 127 
-fi 
- 
-for ISOFILE in $SOURCE/*.[iI][sS][oO] ; do 
- [ -f "$ISOFILE" ] || continue 
- echo $VERSION 
- echo "$0: Found ISO File \"$ISOFILE\"." 
- echo "$0: Testing if File is untouched yet...(safe to move?)" 
- INUSE=`fuser $ISOFILE 2>/dev/null` 
- if [ "$INUSE" = "" ]; then 
- echo "$0: Safe to Move - Moving ISO File to Destination..." 
- mv -vf "${ISOFILE}" -t "$DEST" 
- else 
- echo "$0: Seems the file is still used by another process. skipping file." 
- fi 
-done 
- 
-#echo "$0: All done..." 
-exit 0 
- 
- 
-</code> 
- 
- 
-{{tag>bash shell linux scripting vmware server 2.0.1 iso cd dvd samba fuse automation}} 
it-artikel/linux/mv-iso2vmwarestorage.sh-verschiebt-automatisch-cd-image-dateien-sofern-vorhanden-an-einen-festen-ort-im-vmware-storage.1661949019.txt.gz · Last modified: 2022-08-31 12:30 by 127.0.0.1