Unmounting Script

I was wondering if someone could help me create an AppleScript, Automater Action, or Shell Script that I can use to unmount four volumes upon boot.

That will work but then the volumes are all ejected and I can't open Disk Utility and remount them if need be.
I just tried an app called Platypus and created a tiny app with the following entry. I had Login Items open it but it took a little more than 30 seconds to run the wrapped script and then eject all four volumes:
#!/bin/sh
sleep 1
diskutil unmount /Volumes/volume1
diskutil unmount /Volumes/volume2
diskutil unmount /Volumes/volume3
diskutil unmount /Volumes/volume4
exit
any ideas on a better way?

Similar Messages

  • Udisks2, after-unmount script

    Hello,
    I have a problem with my external eSata Harddrive. If I just unmount it using udisks2 (e.g. in Dolphin), it will keep spinning, so I don't really want to turn off its power supply. I looked around a bit and I found that I can turn it off using 'hdparm -Y'. Is it possible to somehow tell udisks, to execute this command after the unmount for this specific device? Is there maybe an Udev rule, that can be used?
    Or is there maybe a completely different way to solve the original problem (i.e. turning off the hard drive after the unmount)?
    Thanks.

    Hi-
    Did you ever get a resolution to this issue? I am seeing the exact same error in IDM 8.0 patch 3
    Error
    com.waveset.util.WavesetException: An error occurred adding user 'testusr15' to resource 'idm_client'. com.waveset.util.WavesetException: Script failed waiting for "$" in response "_,)#+(:" com.waveset.util.WavesetException: Script processor timed out with nothing to read and the following unprocessed text: "_,)#+(:".
    My action script looks like this:
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE Waveset PUBLIC 'waveset.dtd' 'waveset.dtd'>
    <Waveset>
    <ResourceAction name='after-create-nppasswd'>
    <ResTypeAction restype='Solaris'>
    <act>
    #!/bin/sh
    touch /tmp/idmtest
    release=`uname -r`
    if [ $release != "5.10" ]; then
         passwd -l $WSUSER_accountId
         sed "s/$WSUSER_accountId:\*LK\*/$WSUSER_accountId:NP/" /etc/shadow > /etc/shadow.new
         mv /etc/shadow.new /etc/shadow
    else
         passwd -N $WSUSER_accountId
    fi
    exit 0
    </act>
    </ResTypeAction>
    </ResourceAction>
    </Waveset>

  • [SOLVED / Workaround] Hiding a TrueCrypt volume

    I have a TrueCrypt file that contains my personal information. I mount it from the command line when I need it. How can I hide the mounted TrueCrypt volume from appearing in my file manager (PCManFM)?
    I tried creating a udev rule in "/etc/udev/rules.d/99-hide-partitions.rules":
    KERNEL=="dm-[0-9]*", ENV{UDISKS_IGNORE}:="1"
    It had a small effect: the volume still appears in the file manager but it has a different name.
    Here is the output from "udevadm monitor" when I mount the volume:
    KERNEL[720.311712] add /devices/virtual/bdi/0:34 (bdi)
    UDEV [720.329283] add /devices/virtual/bdi/0:34 (bdi)
    KERNEL[720.523306] change /devices/virtual/block/loop0 (block)
    KERNEL[720.525338] change /devices/virtual/block/loop0 (block)
    KERNEL[720.535095] add /devices/virtual/bdi/254:0 (bdi)
    UDEV [720.537028] add /devices/virtual/bdi/254:0 (bdi)
    KERNEL[720.537390] add /devices/virtual/block/dm-0 (block)
    UDEV [720.538406] add /devices/virtual/block/dm-0 (block)
    KERNEL[720.540339] change /devices/virtual/block/dm-0 (block)
    UDEV [720.558886] change /devices/virtual/block/loop0 (block)
    UDEV [720.588484] change /devices/virtual/block/loop0 (block)
    UDEV [720.612304] change /devices/virtual/block/dm-0 (block)
    How can I hide the volume from my file manager? Should I use udev or another method?
    Thank you!
    Last edited by drcouzelis (2014-01-01 00:14:01)

    drcouzelis wrote:and two, if "dm-0" is the udev name of the device I'm trying to hide...
    Yes, as far as I know dm-0 is correct, you can use it like that in a udev rule.
    Did you have a look at '/lib/udev/rules.d' , maybe you need to change "99" in 99-hide-partitions.rules, it needs to have a different number I guess, looking at the files in  '/lib/udev/rules.d'.
    I would call it 15-hide-partitions.rules, really I don't know if it works, but you could try
    I can't check it for you as I don't have a dm device on this machine.
    edit: Ah, so now I see what you mean, although I don't have a solution.
    I checked with Truecrypt volume on USB disk, all other USB's are correctly ignored, also the USB disk with truecrypt vol. on it. When I mount it, it shows up in the list.
    I tried to write a few rules for it, but they all fail, I use a little script to enable/disable it which is working fine for USB.
    I guess you already issued a command like this to find out more about your device:
    #udevadm info -a -p $(udevadm info -q path -n /dev/sd**)
    Because it looks like when you issue the command, dm-0 is not appearing in the list, I only see this with "udevadm monitor" , so I try some more, I think however, we need some help
    edit2: I have been playing around with udev, I just couldn't get it to work ,so I wrote a little script for it, maybe you can use it, with an alias in your zshrc
    It's just a little mount/unmount script, check your major/minor number, and change the mountpoint to yours.
    #!/bin/bash
    if [ "$(mountpoint -d /media/truecrypt1)" = "254:0" ] ; then
    sudo umount /media/truecrypt1
    echo "Device /media/truecrypt1 is unmounted"
    else
    sudo mount /dev/dm-0 /media/truecrypt1
    echo "Device /media/truecrypt1 is mounted"
    fi
    exit 0
    Last edited by qinohe (2013-10-31 12:36:08)

  • [SOLVED] advanced shell script for mount and unmount samba share

    Good morning guys,
    Today I've a very long question....
    Hope in your help....:
    I usually move from different network.
    For one of those I need to mount some share that are under an ActiveDirectory server.
    To do that I use samba.
    Especially I've made and use the below  shell script.
    I know that it's so stupid but I'm a very newbie:
    #!/bin/sh
    echo "This is a custom script for mount my citrix share"
    echo "Please insert user password (must a sudoer user)"
    echo " "
    sudo mount -t cifs -o username='myusername',password='mypassword' //host_ip/TsHome$/myusername /home/myuser/samba_share/TsHOME
    sudo mount -t cifs -o username='myusername',password='mypassword' "//host_ip/direction" /home/myuser/samba_share/direction
    echo " "
    read -p "Press ENTER key to close this terminal"
    exit
    As I say the script work but it's so crude...!
    I want/need to implement it whit the follow addictions:
    1. print a feedback on mount: somenthing like "TsHOME is now mounted" or "unable to mount TsHOME"
    2. check if the share are already mounted: to prevent accidentally multiple mount. If a share is already mounted I want to print something like "TsHOME is already mounted on /home/myuser/samba_share/TsHOME"
    3. ask for share password  (now it's in clear on script) - This is optinal
    4. un-mount the share before reboot or shutdown command. That because I've notice that If i reboot or shutdown without manually un-mount the share the step of unmounting network file system became very slow
    If it's no extremely difficult, can someone help me to write this script?
    I know that man exist but I'm not a programmer and it's so difficult for me approch it.
    Thank you in advance.
    Ale
    Last edited by Alexbit (2010-09-23 21:29:13)

    Thank you very (VERY) much!
    I've follow your information and.. it work!
    If can be usefull to other this is the complete script:
    #!/bin/sh
    echo "This is a custom script for mount citrix share"
    echo "****************************************"
    echo " "
    echo "Please insert domain password:"
    read -s mypassword
    echo " "
    echo "|checking mount state...in share are not mounted mount it!|"
    echo "+-------------------------------------------------------------------------+"
    if grep "TsHome" /etc/mtab &>/dev/null; then
    grep "TsHome" /etc/mtab | awk '{print "TsHome is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" //ipaddress/TsHome$ /home/Samba_share/TsHOME && echo "TsHOME is now mounted" || echo "unable to mount TsHOME"
    fi
    echo " "
    if grep "direction" /etc/mtab &>/dev/null; then
    grep "direction" /etc/mtab | awk '{print "direction is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/direction' /home/Samba_share/direction' && echo "direction pat is now mounted" || echo "unable to mount direction"
    fi
    echo " "
    if grep "Area" /etc/mtab &>/dev/null; then
    grep "Area" /etc/mtab | awk '{print "Area is already mounted on " $2}'
    else
    sudo mount -t cifs -o username='yourusername',password="$mypassword" '//ipaddress/Area' /home/Samba_share/Area && echo "Area is now mounted" || echo "unable to mount Area"
    fi
    echo " "
    echo "All DONE!"
    echo " "
    read -p "Press ENTER key to close this terminal"
    exit
    I don't really well understand what I've to put in rc.local.shutdown....
    I think somethings like:
    #!/bin/bash
    # /etc/rc.local.shutdown: Local shutdown script.
    echo "This is a custom script for UN-mount citrix share"
    echo "********************************************"
    echo " "
    echo "|check mount state: if mount then un-mount!|"
    echo "+-------------------------------------------------------+"
    echo " "
    if grep "TsHome" /etc/mtab &>/dev/null; then
    grep "TsHome" /etc/mtab | awk '{print "TsHome is NOT mounted -> going on..." $2}'
    else
    sudo umount /home/Samba_share/TsHOME && echo "TsHOME is now UN mounted" || echo "unable to UN-mount TsHOME"
    fi
    echo " "
    if grep "direction" /etc/mtab &>/dev/null; then
    grep "direction" /etc/mtab | awk '{print "direction is NOT mounted -> going on.." $2}'
    else
    sudo umount /home/Samba_share/direction && echo "direction is now UN mounted" || echo "unable to UN-mount direction pat"
    fi
    echo " "
    if grep "Area" /etc/mtab &>/dev/null; then
    grep "Area" /etc/mtab | awk '{print "Area is NOT mounted - Finished" $2}'
    else
    sudo umount /home/Samba_share/Area && echo "Area is now UN mounted" || echo "unable to UN-mount Area"
    fi
    echo " "
    echo "going shutdown"
    echo " "
    sleep 5
    I've try but it seems to ignore the IF statement... this is the output when ALL share are UNmounted:
    $ sh /etc/rc.local.shutdown
    This is a custom script for UN-mount citrix share
    |check mount state: if mount then un-mount!|
    +-------------------------------------------------------+
    umount: /home/Samba_share/TsHOME: not mounted
    unable to UN-mount TsHOME
    umount: /home/Samba_share/direction: not mounted
    unable to UN-mount direction
    umount: /home/Samba_share/Area: not mounted
    unable to UN-mount Area
    going shutdown
    Tomorrow I will test again when I'm at office.
    Meanwhile can you check if I made a macroscopic mistakes?
    Thank you again!
    Last edited by Alexbit (2010-09-23 17:34:49)

  • App/Script for Unmounting a Drive?

    Does anyone have of know of a little executable file that you can place in your startup list that when Osx starts up will unmount a disk for you?
    The reason that I ask is that I run OSx off an external RAID via tnunderbolt and do not use my imac internal drive at all. So to save wear and tear on that internal drive I would like to eject it as soon as OSx successfully loads on my RAID.
    If OSx for some reason does not launch on my RAID then the script will never run and the internal imac HD with its OSx on will boot. This is exactly what I want.
    Is there anyway that I can use automator to do this for me?
    Can anyone help?
    Steve

    Here is a better version of my login unmount bash script:
    #!/bin/sh
    #disktool -e disk0s9
    # example of change string.  This is change all.
    # i=${diskName//" "/"\\ "}
    # debug info
    export PS4='+(${BASH_SOURCE}:${LINENO}):'
    set -o xtrace
    ls -l /Volumes
    # list of disks to unmount.
    disks=("classic" "Second 80" "Ext-80" "Macintosh-HD" "Ext 500")
    for diskName in "${disks[@]}"; do
      echo "diskName =${diskName}="
    # sometime it takes Mac OS X awhile to mount the disks.
    # try four time to try to unmount each disk.
        for ((tryCount=0;tryCount<4;tryCount++))
        do
          diskutil unmount "/Volumes/${diskName}" | grep "Volume /Volumes/${diskName} unmounted"
          rc=$?
          echo "rc="$rc
          if [ $rc -eq 0 ]
          then
            echo "unmounted  i=${diskName} tryCount="$tryCount
            break
          fi
          echo "tryCount=${tryCount} when trying to unmount ${diskName}"
          sleep 8
        done
    done

  • Help with automatic unmounting via script

    Sorry, for some reason, this question got posted twice.
    I would like to reroute you to this thread: http://discussions.apple.com/thread.jspa?threadID=1610643&tstart=0
    Could some kind soul please help me a bit with some applescript?
    I would need two things in applescript:
    1. A way to check whether a certain external (firewire) disk is mounted
    (so that I can unount, er, eject it, if it is there)
    2. A way to make an applescript being executed whenever the laptop goes to sleep.
    For the interested reader:
    what I want to do is to write an applescript that would automatically unmount my external backup disk whenever the laptop goes to sleep.
    Oftentimes I forget to do that myself, then, when the computer is asleep and I want to unplug everything to take it home, I remember that I haven't properly ejected the backup disk ...
    Any hints, pointers, tips will be appreciated!
    Best regards,
    Gabriel.
    Message was edited by: GabrielZ

    TeHDoHBoY wrote:
    *sudo rm -rf ~/Library/Caches*
    *sudo ln -s /private/tmp ~/Library/Caches*
    If you have a script using "sudo", it will always prompt for a password. The easy way to call this is put your script in /Library/Resources/Scripts/ (you'll have to create the Resources/Scripts/ path) and follow these steps.
    Step 1.) Edit your script and take out the "sudo" commands, leaving the following:
    rm -rf ~/Library/Caches*
    ln -s /private/tmp ~/Library/Caches*
    Step 2.) Then open up Terminal and execute the following commands:
    chown root:wheel /Library/Resources/Scripts/NameOfYourScript.sh
    chmod 755 /Library/Resources/Scripts/NameOfYourScript.sh
    Now create your login hook to call this script. If I'm correct, the script will run as root and not prompt the student for a password.

  • Script to unmount or eject disk images

    Is there a way to unmount disk images wiuth an automator or applescript? I have such a script to eject all disks, but this won't unmount disk images. I would like something that unmounts everything, except of course the startup disk etc.

    Andrew Gara wrote:
    That works!
    However, I still have the problem that it will only eject 1 of 2 or 2 of 3 or 3 of 4 etc. I always have to run the script again to eject the remaining disk or image.
    It says: Applescript error Finder got an error. Can't get disk 3 (or whatever is remaining.)
    I really appreciate your help btw.
    this of course makes sense because once a disk is ejected it's not counted among the remaining disks. we should start ejecting from the last disk (see the script below). Also, as i found out, Finder's eject command in apple script doesn't unmount internal drives. At least it didn't for me. I' not sure what the story here is.
    One can circumvent this by calling a shell script command.
    Something along the following lines.
    tell application "Finder"
    set nmd to number of disks
    --this ejects externals and disk images
    if nmd > 1 then
    repeat with i from 2 to nmd
    eject disk (nmd - i + 2)
    end repeat
    end if
    --this ejects internals except for the start up
    set nmd to number of disks
    if nmd > 1 then
    repeat with i from 2 to nmd
    do shell script "diskutil unmount /Volumes/\"" & (name of disk (nmd - i + 2)) & "\"> /dev/null &"
    end repeat
    end if
    end tell
    I tested it on my computer and it ejects 10 disks and disk images well so I think it should work ok most of the times but there are probably situations when it will fail. I'm not sufficiently motivated to refine it.

  • Script for unmounting/deframenting exchange 2010 database

    hi all,
    i need a script to unmount exchange 2010 database, defrag it and mount it again.
    thanks for any comment you may add...

    Tried the above commands... works like a charm, but with the following modifications:
    1. Delete trash and recoverable items from all mailboxes, run repeatedly
    The command using is
    Search-Mailbox -Identity "mailbox.name" -SearchDumpsterOnly -DeleteContent
    1A. Determining Free Space in Mailbox Database
    The command using is
    Get-MailboxDatabase -Status | ft name,Availablenewmailboxspace,Databasesize
    2.Calculate the disk space to perform the defrag, the formula is
    (Databasesize-Availablenewmailboxspace)*1.1
    3.Dismount the mailbox database
    In EMS, go to the folder contain the database file then use the command
    Dismount-Database <DatabaseName>
    3A.Copy mailbox database (edb and all related log files) to another location
    In EMS, go to the folder contain the database file then use the command
    4.Defrag the edb file (eseutil will recreate a temp edb and rename to the new edb after successful complete it will delete the old edb file. If anything goes wrong, it will revert back to the old edb as in the /d)
    eseutil /d <file.edb>
    5.Mount again
    Mount-Database <DatabaseName>
    You are advised to purge (step 1) all mailboxes before eseutil or move mailbox, otherwise it will just carry all the sh!t over to the new mailbox anyway. I gave up trying to tally the total mailbox space used, the whitespace avail and the edb file size already.
    For example, not sure why there is such a disparity where by I have 30 2GB mailboxe est. at 60GB used, whitespace after mailbox move/eseutil at 95GB, the edb size is 106GB. This is where my older exchange 2003 edb files wins hands down. Better budget more
    storage for edb files! I am considering whether it's even worth migrating all to exchange 2010 altogether! The edb files are so damn space hungry even with 3 day retention and 6 day delete with 24/7 maintenance ticked. Exchange 2010 edb beast simply cannot
    be tamed.
    Personally I find in EMC to online move mailbox faster and more reliable overnight. Furthermore, you can simply create a new database, sort all mailboxes by database, select all of them, follow the wizard to move them all at once, the system simply queues
    them to move and complete. Overnight moving is the best, all will be done the next day.

  • Script after unmount with autofs

    I have a small embedded home server running arch linux, now it should manage many (~10) external hd's. i mount them with autofs and share the /mnt folder with samba and nfs. after 10 minutes inactivity, i unmount each hard drive. is it possible to start a script when a hard drive unmounts, and to start another script when autofs mounts it again? the script talks to the serial port and a microcontroller turns off each hard drive.

    The AE scripting host only works with AE running. It doesn't even work with just hooking up to ESTK. You realyl need to run the AE process one way or another. Of course scripts can be invoked by triggering teh respective menu commands or providing them as commandline parameters then, but that very much is the long and short of it. Generally one would rather run a plug-in or script panel from within AE and connect to the external processes...
    Mylenium

  • Shell script to mount/unmount Vista laptop samba shares?

    I have a couple Vista laptops in the house that I take to the office regularly, and currently I use Dolphin to browse into the laptop and xfer files back and forth, but I really don't want to use dolphin, I'd rather set up some kind of script/alias that can prompt me to mount and unmount the share instantly in shell, instead. Is this possible or do I just have to do it in fstab and issue mount/unmount commands everytime?
    TIA for any help

    I tested on a USB stick, no probs, I put my USB stick in a slot, waited for it to mount, ran the script using the "unmount first", then ran the "mount" second worked fine after that using the "unmount " part of the script, I found though that if I right clicked "eject" that the script would not mount the volume.
    You could try something as simple as the below maybe.
    tell application "Finder"
    eject "LEXAR MEDIA"
    end tell
    set _VolumeName to "LEXAR MEDIA"
    set deviceName to do shell script "diskutil list | grep \"" & _VolumeName & "\" | awk '{print $6}'"
    --do shell script "diskutil mountDisk /dev/" & deviceName --mount
    do shell script "diskutil unmountDisk /dev/" & deviceName --unmount
    Budgie

  • Script to mount/unmount a USB thumb drive

    I am looking for an applescript to mount or unmount a USB thumb drive.
    I tried:
    tell application "Finder"
    do shell script "diskutil mount /dev/disk1"
    end tell
    This did not work for me

    I tested on a USB stick, no probs, I put my USB stick in a slot, waited for it to mount, ran the script using the "unmount first", then ran the "mount" second worked fine after that using the "unmount " part of the script, I found though that if I right clicked "eject" that the script would not mount the volume.
    You could try something as simple as the below maybe.
    tell application "Finder"
    eject "LEXAR MEDIA"
    end tell
    set _VolumeName to "LEXAR MEDIA"
    set deviceName to do shell script "diskutil list | grep \"" & _VolumeName & "\" | awk '{print $6}'"
    --do shell script "diskutil mountDisk /dev/" & deviceName --mount
    do shell script "diskutil unmountDisk /dev/" & deviceName --unmount
    Budgie

  • How to create a script to unmount a disk not permanently without typing the admin password?

    Hello everybody!
    My problem is the following: I have  a macbook Pro with a Bootcamp partition, which is also virtualized by Virtualbox. I managed to make it work following different online guides that share all the main little side issue: if I don't want to dismount forever your Bootcamp disk from the running OS X, I have to use some "sudo" commands that requires me to type my admin password. In order to do so, I have to open the Terminal, type the string, type the password and then, only then, I can use the virtualized version. Well, since these ones are computer machines, born to work on repetitive and tedious processes, I'd like to automate that.
    I have a little script, which doesn't work, that I'm showing you (Let's say I wrote it to make it clear to you what I would like the machine to do):
    do shell script "sudo chmod 777 /dev/disk0s4"
    tell application "Finder"
        if exists "BOOTCAMP" then
      --Eject BOOTCAMP Volume if Mounted
              do shell script "sudo umount -f /Volumes/BOOTCAMP"
        end if
    end tell
    --Launch Virtual Machine
    do shell script "vboxmanage startvm BtCmp-Win7"
    What I'm now asking you is the following:
    (a) is there a way to make it work without using my admin passaword? (... I really think the answer is no... )
    (b) if the answer to (a) is no: is there a way to make a little window pop up to ask me to write the admin password and make everything work?
    (c) I would like the disk to be remounted automatically once I Quit the VirtualBox application, how could I do that?
    Well, I hope some kind hearted one can help me

    Hello everybody!
    My problem is the following: I have  a macbook Pro with a Bootcamp partition, which is also virtualized by Virtualbox. I managed to make it work following different online guides that share all the main little side issue: if I don't want to dismount forever your Bootcamp disk from the running OS X, I have to use some "sudo" commands that requires me to type my admin password. In order to do so, I have to open the Terminal, type the string, type the password and then, only then, I can use the virtualized version. Well, since these ones are computer machines, born to work on repetitive and tedious processes, I'd like to automate that.
    I have a little script, which doesn't work, that I'm showing you (Let's say I wrote it to make it clear to you what I would like the machine to do):
    do shell script "sudo chmod 777 /dev/disk0s4"
    tell application "Finder"
        if exists "BOOTCAMP" then
      --Eject BOOTCAMP Volume if Mounted
              do shell script "sudo umount -f /Volumes/BOOTCAMP"
        end if
    end tell
    --Launch Virtual Machine
    do shell script "vboxmanage startvm BtCmp-Win7"
    What I'm now asking you is the following:
    (a) is there a way to make it work without using my admin passaword? (... I really think the answer is no... )
    (b) if the answer to (a) is no: is there a way to make a little window pop up to ask me to write the admin password and make everything work?
    (c) I would like the disk to be remounted automatically once I Quit the VirtualBox application, how could I do that?
    Well, I hope some kind hearted one can help me

  • [SOLVED] Bash scripts to mount & unmount optical drive in Worker?

    I'm running XFCE on Arch with the HAL daemon being called in /etc/rc.conf.
    I can access media on my optical drive (DVD's or CD's) through the desktop icon that appears after HAL has recognised the drive, VLC automatically does its thing as does NeroLinux.
    The reason I'm posting is that I found a great DOpus clone yesterday called Worker - http://www.boomerangsworld.de/cms/worker/index?lang=en, which I am in the process of configuring.
    A problem I have is being able to access the optical drive via Worker.
    The way it is on my system, with HAL handling it, the first line (see below) appears after HAL mounts the media, which basically makes the two lines below it useless:
    /media/<title of disk>
    /media/cd
    /media/dvd
    I have tried configuring Worker to use /media/dvd (or cd), to access the optical media, these don't work for the reason stated above, & /dev/sd0 doesn't work either.
    So, do I have to turn off HAL, uncomment the lines in fstab & use mount?
    A little bash script, that would do the job for me would be great, as Worker will accept a script or a command string.
    I am a bash baby, so if someone can see a solution please post it?
    All input welcome.
    Thanks.
    Last edited by handy (2008-11-19 04:11:02)

    Zariel wrote:
    i guess something like this?
    %optical ALL=(ALL) NOPASSWD: ALL
    I found the clues for this in the sudoers manual:
    handy   ALL = NOPASSWD: /sbin/umount /CDROM,\
                    /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
    Which works in so far as now mounting no longer needs the password.
    Which leaves me with the problem of trying to understand how to get Worker to mount the optical drive on command.
    If I enter the bash command in the Terminal as follows:
    mount /mnt/dvd
    the media is mounted, after which I can push the button in Worker, which I have configured with:
    /mnt/dvd
    & the root list of the optical media is displayed in the active panel of Worker.
    I just haven't been able to get Worker to use "mount /mnt/dvd" yet, there will be a way, I wonder how long it will take me to find it? lol
    Last edited by handy (2008-11-19 06:48:09)

  • Minecraft server script (run minecraft server as a daemon in Arch)

    Hey all, I just finished editing and setting up a nice script to run a Minecraft server at boot in Arch. This is based on the original script on the minecraft wiki here. I've edited it to be suitable to place in your /etc/rc.d/ folder with the name "minecraft" (/etc/rc.d/minecraft).
    This requires a user "minecraft" with the home directory /home/minecraft to work by default.
    I decided I wanted to run the server entirely in RAM so I store all my files in /home/minecraft/backup while the server is offline. When it starts up it makes a tmpfs mount at /home/minecraft/minecraft and copies all the files there and runs from there. It makes an hourly backup using /etc/rc.d/backup stored in /home/minecraft/onlinebackup, first erasing the current backup and creating a new one. This is simply to save space. In the event of a crash without proper stopping of the daemon you will have a backup from your previous reboot (or restart of your minecraft server) in /home/minecraft/backup and one from within the previous hour in /home/minecraft/onlinebackup which I figure ought to be enough. You can manually backup at any time by restarting the daemon.
    All paths can be altered. You can run this game under your normal user if you wish, just change the Settings section at the top of the file. RAM amounts may need to be increased for both the server and for the tmpfs, depending on how large your files are (mine are tiny and I have not heard of over 48MB for a game world, but you never know). Just check up on df -h every now and again to make sure your tmpfs has plenty of space, or just increase the allocated maximum size from the start. If you have low RAM you can always change the script to simply not use tmpfs.
    If anyone wants, just ask and I can put up a version without tmpfs (should be easy enough to remove yourself but if you're not sure I'll do it for you)
    All you need to start off with (if starting your server for the first time, using the scrip as is) is the user minecraft created, with the folders backup, onlinebackup and minecraft in the folder /home/minecraft, your minecraft_server.jar file in /home/minecraft/backup and your oninebackup file in /home/minecraft/backup.
    NOTE: onlinebackup file runs from /home/minecraft/minecraft so that if your system crashes, the cron job to run the backups will fail because the link will point to a non-existant file until server is started again.
    You can use these commands to with the server: /etc/rc.d/minecraft {start|stop|restart|update|backup}
    The backup system is designed to wipe all previous sessions' backups upon starting the server, so do not set it to start the server at boot.
    /etc/rc.d/minecraft
    #!/bin/bash
    # /etc/rc.d/minecraft
    . /etc/rc.conf
    . /etc/rc.d/functions
    #Uncomment line below if using Sun JRE
    #. /etc/profile
    #Settings
    SERVICE='minecraft_server.jar'
    USERNAME="minecraft"
    MCPATH='/home/minecraft/minecraft'
    MCOFFLINEPATH='/home/minecraft/backup'
    INVOCATION='java -Xmx768M -Xms768M -jar minecraft_server.jar nogui'
    BACKUPPATH='/home/minecraft/onlinebackup'
    ME=`whoami`
    as_user() {
    if [ "$ME" == "$USERNAME" ] ; then
    bash -c "$1"
    else
    su -c - $USERNAME "$1"
    fi
    mc_start() {
    stat_busy "Starting Minecraft Server"
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "Tried to start but $SERVICE was already running!"
    else
    echo "$SERVICE was not running... starting."
    #Move minecraft from backup folder to ram
    mount -t tmpfs tmpfs -o size=50m $MCPATH
    cp -a $MCOFFLINEPATH/* $MCPATH
    echo "Files moved to RAM."
    cd $MCPATH
    as_user "cd $MCPATH && screen -dmS minecraft $INVOCATION"
    sleep 7
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is now running."
    #Create hourly backups while running
    ln -s $MCPATH/onlinebackup /etc/cron.hourly/minecraftonlinebackup
    echo "Hourly backups initiated."
    else
    echo "Could not start $SERVICE."
    umount $MCPATH
    fi
    fi
    add_daemon minecraft
    stat_done
    mc_saveoff() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running... suspending saves."
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER BACKUP STARTING. Server going readonly...\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-off\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'"
    sync
    sleep 10
    else
    echo "$SERVICE was not running. Not suspending saves."
    fi
    mc_saveon() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running... re-enabling saves."
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-on\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER BACKUP ENDED. Server going read-write...\"\015'"
    else
    echo "$SERVICE was not running. Not resuming saves."
    fi
    mc_stop() {
    stat_busy "Stopping Minecraft Server"
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running... stopping."
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER SHUTTING DOWN IN 10 SECONDS. Saving map...\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'"
    sleep 10
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"stop\"\015'"
    sleep 7
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE could not be shut down... still running."
    else
    echo "$SERVICE is shut down."
    #Stop hourly backups
    rm /etc/cron.hourly/minecraftonlinebackup
    echo "Hourly backup halted."
    #Unmount tmpfs
    cp -a $MCPATH/* $MCOFFLINEPATH
    umount $MCPATH
    echo "Files copied to HDD."
    fi
    else
    echo "$SERVICE was not running."
    fi
    rm_daemon minecraft
    stat_done
    mc_update() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running! Will not start update."
    else
    MC_SERVER_URL=http://minecraft.net/`wget -q -O - http://www.minecraft.net/download.jsp | grep minecraft_server.jar\</a\> | cut -d \" -f 2`
    as_user "cd $MCPATH && wget -q -O $MCPATH/minecraft_server.jar.update $MC_SERVER_URL"
    if [ -f $MCPATH/minecraft_server.jar.update ]
    then
    if `diff $MCPATH/minecraft_server.jar $MCPATH/minecraft_server.jar.update >/dev/null`
    then
    echo "You are already running the latest version of $SERVICE."
    else
    as_user "mv $MCPATH/minecraft_server.jar.update $MCPATH/minecraft_server.jar"
    echo "Minecraft successfully updated."
    fi
    else
    echo "Minecraft update could not be downloaded."
    fi
    fi
    mc_backup() {
    echo "Backing up minecraft world"
    if [ -d $BACKUPPATH/world_`date "+%m.%d.%Y"` ]
    then
    for i in 1 2 3 4 5 6
    do
    if [ -d $BACKUPPATH/world_`date "+%m.%d.%Y"`-$i ]
    then
    continue
    else
    as_user "cd $MCPATH && cp -r world $BACKUPPATH/world_`date "+%m.%d.%Y"`-$i"
    break
    fi
    done
    else
    as_user "cd $MCPATH && cp -r world $BACKUPPATH/world_`date "+%m.%d.%Y"`"
    echo "Backed up world"
    fi
    echo "Backing up the minecraft server executable"
    if [ -f "$BACKUPPATH/minecraft_server_`date "+%m.%d.%Y"`.jar" ]
    then
    for i in 1 2 3 4 5 6
    do
    if [ -f "$BACKUPPATH/minecraft_server_`date "+%m.%d.%Y"`-$i.jar" ]
    then
    continue
    else
    as_user "cd $MCPATH && cp minecraft_server.jar \"$BACKUPPATH/minecraft_server_`date "+%m.%d.%Y"`-$i.jar\""
    break
    fi
    done
    else
    as_user "cd $MCPATH && cp minecraft_server.jar \"$BACKUPPATH/minecraft_server_`date "+%m.%d.%Y"`.jar\""
    fi
    echo "Backup complete"
    #Start-Stop here
    case "$1" in
    start)
    mc_start
    stop)
    mc_stop
    restart)
    mc_stop
    mc_start
    update)
    mc_stop
    mc_backup
    mc_update
    mc_start
    backup)
    mc_saveoff
    mc_backup
    mc_saveon
    status)
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running."
    else
    echo "$SERVICE is not running."
    fi
    echo "Usage: /etc/rc.d/minecraft {start|stop|update|backup|status|restart}"
    exit 1
    esac
    exit 0
    /home/minecraft/backup/onlinebackup
    #!/bin/bash
    # /home/minecraft/backup/onlinebackup
    rm -rf /home/minecraft/onlinebackup/*
    /etc/rc.d/minecraft backup
    UPDATE:
    rationalOgre has created an alternate script with a different backup system, which will keep compressed copies of your world indefinitely, along with a working update function. https://bbs.archlinux.org/viewtopic.php … 97#p944797
    Last edited by PIMPinator (2011-06-08 14:00:54)

    @PIMPinator - Weird. On mine, if I don't source /etc/profile it won't work. No clue what the difference is. I tested it after I got it up and running, removing different elements to see if one or the other was the problem. Without it all in place it just didn't work.
    I made some modifications to your script today. Fixed "update" so it works properly. (You had it running mc_backup after mc_stop, which never worked on my system.) I basically reworked it so it runs the backup, then stops the server and performs the update in the ~/backup directory, then restarts the server. I also completely overhauled the "backup" system. (for this to work you have to comment out the rm -rf ~/onlinebackup/* directive in the onlinebackup script.) Now, it creates 4 rolling backups of the server, in tar.gz format. What this means is that over time, you will accumulate the last 4 backups for each day in your ~/onlinebackup folder. I thought about creating a cleanup function to cull anything over 2 days old but to be honest, even if your world was > 50MB, zipped up it's going to be about ~20mb which means you can have 50 of them and only be taking up a gig of server space. Anyway, here's the code if you are interested.
    #!/bin/bash
    # /etc/init.d/minecraft
    . /etc/rc.conf
    . /etc/rc.d/functions
    #Comment out the following if using OpenJDK
    . /etc/profile
    #Settings
    SERVICE='minecraft_server.jar'
    USERNAME="minecraft"
    MCPATH='/home/minecraft/minecraft'
    MCOFFLINEPATH='/home/minecraft/backup'
    INVOCATION='java -Xmx768M -Xms768M -jar minecraft_server.jar nogui'
    BACKUPPATH='/home/minecraft/onlinebackup'
    ME=`whoami`
    as_user() {
    if [ "$ME" == "$USERNAME" ] ; then
    bash -c "$1"
    else
    su -c - $USERNAME "$1"
    fi
    mc_start() {
    stat_busy "Starting Minecraft Server"
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "Tried to start but $SERVICE was already running!"
    else
    echo "$SERVICE was not running... starting."
    #Move minecraft from backup folder to ram
    mount -t tmpfs tmpfs -o size=50m $MCPATH
    cp -a $MCOFFLINEPATH/* $MCPATH
    echo "Files moved to RAM."
    cd $MCPATH
    as_user "cd $MCPATH && screen -dmS minecraft $INVOCATION"
    sleep 7
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is now running."
    #Create hourly backups while running
    ln -s $MCPATH/onlinebackup /etc/cron.hourly/minecraftonlinebackup
    echo "Hourly backups initiated."
    else
    echo "Could not start $SERVICE."
    umount $MCPATH
    fi
    fi
    add_daemon minecraft
    stat_done
    mc_saveoff() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running... suspending saves."
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER BACKUP STARTING. Server going readonly...\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-off\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'"
    sync
    sleep 10
    else
    echo "$SERVICE was not running. Not suspending saves."
    fi
    mc_saveon() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running... re-enabling saves."
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-on\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER BACKUP ENDED. Server going read-write...\"\015'"
    else
    echo "$SERVICE was not running. Not resuming saves."
    fi
    mc_stop() {
    stat_busy "Stopping Minecraft Server"
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running... stopping."
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER SHUTTING DOWN IN 10 SECONDS. Saving map...\"\015'"
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'"
    sleep 10
    as_user "screen -p 0 -S minecraft -X eval 'stuff \"stop\"\015'"
    sleep 7
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE could not be shut down... still running."
    else
    echo "$SERVICE is shut down."
    #Stop hourly backups
    rm /etc/cron.hourly/minecraftonlinebackup
    echo "Hourly backup halted."
    #Unmount tmpfs
    cp -a $MCPATH/* $MCOFFLINEPATH
    umount $MCPATH
    echo "Files copied to HDD."
    fi
    else
    echo "$SERVICE was not running."
    fi
    rm_daemon minecraft
    stat_done
    mc_update() {
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running! Will not start update."
    else
    MC_SERVER_URL=http://minecraft.net/`wget -q -O - http://www.minecraft.net/download.jsp | grep minecraft_server.jar\</a\> | cut -d \" -f 2`
    as_user "cd $MCOFFLINEPATH && wget -q -O $MCOFFLINEPATH/minecraft_server.jar.update $MC_SERVER_URL"
    if [ -f $MCOFFLINEPATH/minecraft_server.jar.update ]
    then
    if `diff $MCOFFLINEPATH/minecraft_server.jar $MCOFFLINEPATH/minecraft_server.jar.update >/dev/null`
    then
    echo "You are already running the latest version of $SERVICE."
    rm $MCOFFLINEPATH/minecraft_server.jar.update
    else
    as_user "mv $MCOFFLINEPATH/minecraft_server.jar.update $MCOFFLINEPATH/minecraft_server.jar"
    echo "Minecraft successfully updated."
    fi
    else
    echo "Minecraft update could not be downloaded."
    fi
    fi
    mc_backup() {
    echo "Backing up minecraft world"
    local COUNTER=
    if [ -f $BACKUPPATH/co ]
    then
    COUNTER=`cat $BACKUPPATH/co`
    if [ $COUNTER -gt 4 ]
    then
    #Loop back to 1 if greater than the max number of desired saves (4 hardcoded)
    as_user "echo 1 > $BACKUPPATH/co"
    COUNTER=1
    fi
    else
    COUNTER=1
    as_user "echo 1 > $BACKUPPATH/co"
    fi
    if [ -f $BACKUPPATH/world_`date "+%m.%d.%Y"`-$COUNTER.tar.gz ]
    then
    as_user "rm $BACKUPPATH/world_`date "+%m.%d.%Y"`-$COUNTER.tar.gz"
    fi
    as_user "cd $MCPATH && tar -czf $BACKUPPATH/world_`date "+%m.%d.%Y"`-$COUNTER.tar.gz world"
    #now to update the counter
    as_user "echo $(($COUNTER + 1)) > $BACKUPPATH/co"
    echo "Backup complete..."
    #Start-Stop here
    case "$1" in
    start)
    mc_start
    stop)
    mc_stop
    restart)
    mc_stop
    mc_start
    update)
    mc_saveoff
    mc_backup
    mc_saveon
    mc_stop
    mc_update
    mc_start
    backup)
    mc_saveoff
    mc_backup
    mc_saveon
    status)
    if ps ax | grep -v grep | grep -v -i SCREEN | grep $SERVICE > /dev/null
    then
    echo "$SERVICE is running."
    else
    echo "$SERVICE is not running."
    fi
    echo "Usage: /etc/rc.d/minecraft {start|stop|update|backup|status|restart}"
    exit 1
    esac
    exit 0
    I hope you don't mind.
    EDIT: Made a small change later that I came back and put in. If you are currently at the latest release it removes the .update file it created.
    Last edited by rationalOgre (2011-06-07 23:05:58)

  • How can I determine which computer a share is connected to in /Volumes from terminal or a script?

    I run a set of virtual machines via Fusion on an iMac that we run automated tests on for our website.  There is a folder on each VM called /Automation that is shared. 
    I have a python script that runs on the host, that will find an open VM, start it up and then mount the VM's /Automation folder.  So if there is only 1 VM powered on, the folder shows up in /Volumes as /Volumes/Automation.  The  problem is when there are 2 or more VM's powered on, because then the shares start being named /Volumes/Automation-1 and Automation-2 etc.  So my question is, how can I determine which computer each share belongs to from terminal or a script?
    In other words, I'm looking for something like:
    /Volumes/Automation = "FirstVirtualMachineName.local"
    /Volumes/Automation-1 = "SecondVirtualMachineName.local"
    Is there any way to determine which computer a mounted share is connected to?  In the past, I've just unmounted all /Automation folders, and then mounted them in a particular order, but that's unreliable and messy in my opinion.  If anyone knows a better way, please let me know.  Any help is appreciated.
    Thanks,

    Well I think I have a workable solution.  It's not perfect, but I think it will do the trick. I can put a spotlight comment on the folder similar to 'HostName=OSX-Automation-1.local' and can then retrieve that value from our server with the following python snippet:
    import subprocess
    out,err = subprocess.Popen(['osascript','-e','tell application \"Finder\" to get comment of \"Macintosh HD:Volumes:Automation-1\"'],stdout=subprocess.PIPE, stderr=subprocess.PIPE).communciate()
    So I could just loop through each 'Automation*' folder in /Volumes and grab the name from the spotlight attributes on the directories.  I don't think I really need to worry about the comments being overwritten, but I may have one of our launch daemons that run on the VM check that spotlight comment once a minute or something to ensure that the correct value is there.
    If it ends up not working well in practice, I'm going to give your suggestion about a config script a shot.  It would require a little more up front work, but seems as if it would be pretty solid after that. 
    Thanks again for helping me think it through

Maybe you are looking for

  • Hyperlinks from converted excel file are not working after pdf file is moved

    I have created a pdf file from an excel file that has hyperlinks in it. The hyperlinks work fine if the files are all kept in the same exact location as the time they were created. Once the files are moved (i.e. emailed to another user) the hyperlink

  • Read at each new line from .txt file

    Hi guys I want to read from a file which I am saving using labview. What I am doing is reading 128 bytes fro VISA port and saving it in .txt file with new line constant. At some later time I want to read 128 bytes from that text file do some processi

  • Having problems with outlook 2007

    I got outlook 2007 and am using it to receive my gmail account email and when it downloads a new message it deletes it from my phone. Does anyone have a fix for this?

  • GR against scheduling agreement -duplicate entry

    Hi there, I am receiving goods against a scheduling agreement. There are several schedule lines due for various dates. Fore one particular qty - 53 PC, there are two entries showing GR happened for both these entries. While only once the GR has actua

  • Import Format: Copy source account into UD1

    The Source G/L Account is used for both the HFM Account and HFM UD1 (Custom1). The mapping for FM Accounts and FM UD1 is set-up based on the GL Accounts. UD1 is not included in the GL extract file. How can I easy copy source Account into UD1 through