Категории: Все - file - script

по Mike Ton 9 лет назад

510

SymLink

On Mac OS X, symbolic links are special file types stored in the HFS+ disk directory, containing extra information like file type, creator code, and Finder flag. These links are essential for various file operations and scripts.

SymLink

SymLink

unity

NOTE:
.dll

DON'T WORK???

Vectrosity.dll fails to find namespace

Vectrosity source symlinks fine

will fail to path towards usb drive

must be on the same drive as unity installation??

PluginRepo
$DEST
$SOURCE

Phsyics2D

ControlFreak

project

Asset/

Project/

(layer tags)

(input settings)

win

mac

script
scheduler

launchd

https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html#//apple_ref/doc/uid/TP40001762-104142

(pList)

(rec Property)

KeepAlive

This key specifies whether your daemon launches on-demand or must always be running. It is recommended that you design your daemon to be launched on-demand.

inetdCompatibility

Indicates that your daemon requires a separate instance per incoming connection. This causes launchd to behave like inetd, passing each daemon a single socket that is already connected to the incoming client. (required if your daemon was designed to be launched by inetd; otherwise, must not be included)

ProgramArguments

Contains the arguments used to launch your daemon. (required)

Label

Contains a unique string that identifies your daemon to launchd. (required)

Creating a launchd Property List File

Examples

Emulating inetd

<?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>Label</key>

<string>com.example.telnetd</string>

<key>ProgramArguments</key>

<array>

<string>/usr/libexec/telnetd</string>

</array>

<key>inetdCompatibility</key>

<dict>

<key>Wait</key>

<false/>

</dict>

<key>Sockets</key>

<dict>

<key>Listeners</key>

<dict>

<key>SockServiceName</key>

<string>telnet</string>

<key>SockType</key>

<string>stream</string>

</dict>

</dict>

</dict>

</plist>

Monitoring a Directory

<?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>Label</key>

<string>com.example.watchhostconfig</string>

<key>ProgramArguments</key>

<array>

<string>syslog</string>

<string>-s</string>

<string>-l</string>

<string>notice</string>

<string>somebody touched /etc/hostconfig</string>

</array>

<key>WatchPaths</key>

<array>

<string>/etc/hostconfig</string>

</array>

</dict>

</plist>

An additional file system trigger is the notion of a queue directory. The launchd daemon starts your job whenever the given directories are non-empty, and it keeps your job running as long as those directories are not empty:

<?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>Label</key>

<string>com.example.mailpush</string>

<key>ProgramArguments</key>

<array>

<string>my_custom_mail_push_tool</string>

</array>

<key>QueueDirectories</key>

<array>

<string>/var/spool/mymailqdir</string>

</array>

</dict>

</plist>

Running a Job Periodically

<?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>Label</key>

<string>com.example.touchsomefile</string>

<key>ProgramArguments</key>

<array>

<string>touch</string>

<string>/tmp/helloworld</string>

</array>

<key>StartInterval</key>

<integer>300</integer>

</dict>

</plist>

specify a calendar-based interval

<?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>Label</key>

<string>com.example.touchsomefile</string>

<key>ProgramArguments</key>

<array>

<string>touch</string>

<string>/tmp/helloworld</string>

</array>

<key>StartCalendarInterval</key>

<dict>

<key>Minute</key>

<integer>45</integer>

<key>Hour</key>

<integer>13</integer>

<key>Day</key>

<integer>7</integer>

</dict>

</dict>

</plist>

Debugging launchd Jobs

<?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>Label</key>

<string>com.example.sleep</string>

<key>ProgramArguments</key>

<array>

<string>sleep</string>

<string>100</string>

</array>

<key>StandardOutPath</key>

<string>/var/log/myjob.log</string>

<key>StandardErrorPath</key>

<string>/var/log/myjob.log</string>

<key>Debug</key>

<true/>

<key>SoftResourceLimits</key>

<dict>

<key>Core</key>

<integer>9223372036854775807</integer>

</dict>

<key>HardResourceLimits</key>

<dict>

<key>Core</key>

<integer>9223372036854775807</integer>

</dict>

</dict>

</plist>

Listening on Sockets

<key>Sockets</key>

<dict>

<key>Listeners</key>

<dict>

<key>SockServiceName</key>

<string>bootps</string>

<key>SockType</key>

<string>dgram</string>

<key>SockFamily</key>

<string>IPv4</string>

</dict>

</dict>

Writing a “Hello World!” launchd Job

<?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>Label</key>

<string>com.example.hello</string>

<key>ProgramArguments</key>

<array>

<string>hello</string>

<string>world</string>

</array>

<key>KeepAlive</key>

<true/>

</dict>

</plist>

// You indicate whether it describes a daemon or agent by the directory you place it in

// To run under launchd, you must provide a configuration property list file for your daemon

(types)

daemons : software tools

/Library/LaunchDaemons

agent : per-user processes

/Library/LaunchAgents

// or LaunchAgents subdirectory of an individual user’s Library directory

(deprecated)

Cron

(file to run)

copy folder

cp -r source destination

// -r == recursive

copy file

cp source destination

updateSymlinkMton(dest, source)

//update symlink from new source

//read from symlink.txt and dereference

while read line; do echo -e "$line"; done < mySymLink.txt

//find symlink at dest and write to file

find /Users/mton/Google\ Drive/Unity/Android_Project/ -type l > mySymLink.txt

cmd
$ rsync

how-to-copy-only-symbolic-links

find /path/to/files -type l -print | \ rsync -av --files-from=- /path/to/files user@targethost:/path

The find command starts at /path/to/files and steps recursively through everything "under" that point. The options to find are conditions that limit what gets output by the -print option. In this case, only things of -type l (symbolic link, according to man find) will be printed to find's "standard output".

These files become the "standard input" of the rsync command's --file-from option.

Give it a shot. I haven't actually tested this, but it seems to me that it should work.

copy symlink

rsync --dry-run -r --copy-links $SOURCE $DEST

flags

--copy-links

--copy-dirlinks

gets just directories

gets all files

//remove --dry-run flag when ready to do for real

rsync -n -a --del -v /Users/mton/GoogleDrive_mt/RemoteWork/BlubberBuster/Enemy_AI/Assets/Shared/__MtonFrameWork /Users/mton/Dropbox/Code/SymLink/Unity/Assets/Shared

rsync –options SrcDir DstDir

(-options)

−−del

//(alias for −−delete−during)

(other)

−−max−delete=NUM (don’t delete more than NUM files)

−−delete−excluded (also delete excluded files from dest dirs)

???

−−delete−after (receiver deletes after xfer, not before)

−−delete−before (receiver deletes before xfer [default])

−−delete (deletes extraneous files from dest dirs)

−−delete−during (receiver deletes during xfer, not before)

(others)

--exclude '.DS_Store'

//Do not copy over any invisible DS_Store files

--ignore-existing

ignore any files that already exist in the destination directory. We don't want to copy a file twice, update or overwrite current files.

–dr

//syncs only directories, no files

-nEvauz

-z

// compression mode can speed up copying by compressing/uncompressing file data before/after being copied.

-u

update mode prevents newer files at the destination directory from being over-written.

//recursive

-a

−a, −−archive >

This is equivalent to −rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with −H being a notable omission). The only exception to the above equivalence is when −−files−from is specified, in which case −r is not implied.

Note that −a does not preserve hardlinks, because finding multiply-linked files is expensive. You must separately specify −H.

//archive mode tells rsync to--essentially--copy files recursively through sub-directories while maintaining permissions.

//equivalent to −rlptgoD

//recursive +

// preserve any symbolic links, preserves file and directory permissions, preserves the timestamp, and preserve the owner and group

-r

–v

// verbose mode tells rsync to output results and messages

-E

// extended-attributes such as Mac-centric ACLs and resource forks will be preserved.

-n

//puts rsync into "dry run" mode. rsync will return a list of files that would have been copied but will not actually copy anything.

EX:

rsync –r -v SrcDir DstDir

$ readlink

pwd -P

//find list of symlinks, cd to directory, pwd???

//returns absolute path of current dir

greadlink -f path

coreutils solution

//sudo brew install coreutils

readlink [path]

//Mac OSX only; on unix use -f flag

//returns absolute path of symlink

$ find

find . -type l

//finds all symlink in current dir

find [path] -type l

//finds all symlink at specified path

$ ln -s SOURCE_DIR DEST_DIR
file
OS X

stored in the HFS+ disk directory

extra "Mac" information == symbolic link.

special file type, creator code, and Finder flag information

plain text files