modified: myjupyterlab.sh
[GalaxyCodeBases.git] / etc / Mac / MoveTemporaryFoldersToRamdisk_MacOSX.sh
blobc99476009bd924efef4b9baf2e1414ec4e3ef99b
1 #!/bin/bash
3 # +----------------------------------------------------------------------+
4 # | |
5 # | Set up Mac OS X to store temporary files in RAM rather than on disk.|
6 # | Updated for Yosemite, 16 GB of RAM |
7 # | |
8 # | By James Newell <jrnewell@github> |
9 # | |
10 # | Originally by Ricardo Gameiro <http://blogs.nullvision.com/?p=357> |
11 # | Changes by Daniel Jenkins |
12 # | <http://blogs.nullvision.com/?p=357#comment-1140> |
13 # | Additional changes by Benjamin Chu <http://intechnicolor.net> |
14 # +----------------------------------------------------------------------+
16 # if you want a different location for startup script, change this variable
17 SCRIPT_DIR=/usr/local/sbin
18 SCRIPT=ram-temp-disks
20 SCRIPT_DIR=/opt/Galaxy
21 SCRIPT=RamDisks
23 if [ ! -d "$SCRIPT_DIR" ]; then
24 echo "$SCRIPT_DIR does not exist. Either create the directory or change SCRIPT_DIR in this script..."
25 exit 1
27 cd "$SCRIPT_DIR"
29 cat << "EOF" | tee "$SCRIPT" > /dev/null
30 #!/bin/sh
32 # Create a RAM disk with same perms as mount point
33 RAMDisk() {
34 local mount_pt="$1"
35 local ramdisk_size=$(($2*1024*1024/512))
37 # create ram disk
38 echo "Creating RamFS for $mount_pt"
39 local ramdisk_dev="$(hdiutil attach -drivekey system-image=yes -nomount -noautoopen ram://${ramdisk_size} | sed -e 's/[[:space:]]*$//')"
41 # seems to help with preventing issue where some disks did not mount
42 sleep 1
44 # success
45 if [ $? -eq 0 ]; then
47 # Create HFS on the RAM volume.
48 sudo newfs_hfs -v "$3" $ramdisk_dev
50 # Store permissions from old mount point.
51 eval `/usr/bin/stat -s $mount_pt`
53 # Mount the RAM disk to the target mount point.
54 sudo mount -t hfs -o noatime -o union -o nobrowse "$ramdisk_dev" "$mount_pt"
56 # Restore permissions like they were on old volume.
57 sudo chown $st_uid:$st_gid "$mount_pt"
58 sudo chmod $st_mode "$mount_pt"
62 # 512 MB for temp directory
63 #RAMDisk "/private/tmp" 512 "RAM Temp"
64 RAMDisk "/private/tmp" 768 "RAM_Temp"
66 # 128 MB for run directory
67 #RAMDisk "/var/run" 128 "RAM Run"
69 EOF
70 sudo chmod u+x,g+x,o+x "$SCRIPT"
72 cd /Library/LaunchDaemons
73 cat << EOF | sudo tee me.Galaxy.ramdisk.plist > /dev/null
74 <?xml version="1.0" encoding="UTF-8"?>
75 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
76 <plist version="1.0">
77 <dict>
78 <key>Label</key>
79 <string>RAM Temp Disks</string>
81 <key>ProgramArguments</key>
82 <array>
83 <string>${SCRIPT_DIR}/${SCRIPT}</string>
84 </array>
86 <key>RunAtLoad</key>
87 <true/>
88 </dict>
89 </plist>
90 EOF
92 exit 0