Created
January 3, 2012 22:23
-
-
Save gboudreau/1557265 to your computer and use it in GitHub Desktop.
smbln executable that allows the creation of symlinks on Samba shares mounted with the mfsymlinks option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
if ($argv[1] == '-s') { | |
$argv[1] = $argv[2]; | |
$argv[2] = @$argv[3]; | |
} | |
if (empty($argv[2])) { | |
$argv[2] = basename($argv[1]); | |
} | |
$target = $argv[1]; | |
$symlink = $argv[2]; | |
if (file_exists($symlink)) { | |
echo basename($argv[0]) . ": creating symbolic link `$symlink': File exists\n"; | |
exit(1); | |
} | |
$md5 = trim(`echo -n $target | md5sum | awk '{print \$1}'`); | |
$symlink_data = sprintf("XSym\n%04d\n%s\n%s\n%s", | |
strlen($target), | |
$md5, | |
$target, | |
str_repeat(' ', 1024-1-strlen($target)) | |
); | |
file_put_contents($symlink, $symlink_data); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment