sh 在OSX上创建和管理区分大小写的磁盘映像。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在OSX上创建和管理区分大小写的磁盘映像。相关的知识,希望对你有一定的参考价值。

#!/bin/bash

# ---------------------------------------------------------
# Customizable Settings
# ---------------------------------------------------------

# where to store the sparse-image
WORKSPACE=${HOME}/.workspace.dmg.sparseimage

# location where workspace will be mounted
MOUNTPOINT=${HOME}/workspace

# name of workspace as visible in Finder
VOLUME_NAME=workspace

# volume size
VOLUME_SIZE=60g

# ---------------------------------------------------------
# Functionality
# ---------------------------------------------------------

create() {
    hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size ${VOLUME_SIZE} -volname ${VOLUME_NAME} ${WORKSPACE}
}

automount() {
    cat << EOF > com.workspace.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>RunAtLoad</key>
        <true/>
        <key>Label</key>
        <string>com.workspace</string>
        <key>ProgramArguments</key>
        <array>
            <string>hdiutil</string>
            <string>attach</string>
            <string>-notremovable</string>
            <string>-nobrowse</string>
            <string>-mountpoint</string>
            <string>${MOUNTPOINT}</string>
            <string>${WORKSPACE}</string>
        </array>
    </dict>
</plist>
EOF
    sudo cp com.workspace.plist /Library/LaunchDaemons/com.workspace.plist
}

detach() {
    m=$(hdiutil info | grep "${MOUNTPOINT}" | cut -f1)
    if [ ! -z "$m" ]; then
        sudo hdiutil detach $m
    fi
}

attach() {
    sudo hdiutil attach -notremovable -nobrowse -mountpoint ${MOUNTPOINT} ${WORKSPACE}
}

compact() {
    detach
    hdiutil compact ${WORKSPACE} -batteryallowed
    attach
}

help() {
    cat <<EOF
usage: workspace <command>

Possible commands:
   create       Initialize case-sensitive volume (only needed first time)
   automount    Configure OS X to mount the volume automatically on restart
   mount        Attach the case-sensitive volume
   unmount      Detach the case-sensitive volume
   compact      Remove any uneeded reserved space in the volume
   help         Display this message
EOF
}

invalid() {
    printf "workspace: '$1' is not a valid command.\n\n";
    help
}

case "$1" in
    create) create;;
    automount) automount;;
    mount) attach;;
    unmount) detach;;
    compact) compact;;
    help) help;;
    '') help;;
    *) invalid $1;;
esac

以上是关于sh 在OSX上创建和管理区分大小写的磁盘映像。的主要内容,如果未能解决你的问题,请参考以下文章

sh 修复损坏的qemu磁盘映像

硬盘分区类型

在 OSX 中报告不区分大小写(使用 OSXFuse)

sh [在MAC OSX上配置允许多个用户的自制权限]。管理员组中的任何用户都可以管理自制软件和c

将 OSX Clang 配置为区分大小写以包含语句

sh 在OSX上使用通配符和备用名称创建SSL证书签名请求