Reset /Users/X in MacOSX

http://www.macosxhints.com/article.php?story=20081009204908181&mode=print

#!/bin/bash

if [ ! -n “$1” ]; then
echo $0: user
exit 1
fi

sudo chown -R $1:staff /Users/${1}
sudo chmod -R 700 /Users/${1}
sudo chmod 755 /Users/${1}
sudo chmod -R 755 /Users/${1}/Public /Users/${1}/Sites
sudo chmod -R 733 /Users/${1}/Public/Drop Box
sudo chmod +a “everyone deny delete” /Users/${1} /Users/${1}/Sites /Users/${1}/Public /Users/${1}/Desktop
/Users/${1}/Documents /Users/${1}/Downloads /Users/${1}/Pictures /Users/${1}/Music /Users/${1}/Movies
/Users/${1}/Library
sudo chmod -R +a “${1} allow readattr,readextattr,readsecurity,list,search,read,execute,file_inherit,directory_inherit,delete,writeextattr,writeattr,write,append,delete_child,add_file,add_subdirectory”
/Users/${1}/Public/Drop Box

Change uid in MacOSX

#!/bin/bash

echo dscl . -change /Users/xxx UniqueID 501 new_uid
echo dscl . -change /Users/xxx PrimaryGroupID 20 new_gid
echo chown -R : /Users/xxx
echo ls -n

how to create sparsebundle image file in Mac OSX

#!/bin/bash

if [ ! -n “$2” ]; then
echo $0: machine_name MACid
exit 1
fi

hdiutil create -size 80G -type SPARSEBUNDLE
-imagekey sparse-band-size=65536
-fs HFS+J
-volname “Backup $1”
~/Documents/”$1_$2″.sparsebundle

Above is to create a sparsebundle file required for Time Machine backup to remote afp

madplay

diff -up ./audio_carbon.c.lama ./audio_carbon.c
— ./audio_carbon.c.lama 2004-01-23 17:41:31.000000000 +0800
+++ ./audio_carbon.c 2008-10-01 20:22:00.000000000 +0800
@@ -94,7 +94,7 @@ void callback(SndChannelPtr channel, Snd
}

static
-int wait(struct buffer *buffer)
+int delay(struct buffer *buffer)
{
if (MPWaitOnSemaphore(buffer->semaphore, kDurationForever) != noErr) {
audio_error = _(“MPWaitOnSemaphore() failed”);
@@ -263,7 +263,7 @@ int play(struct audio_play *play)
/* wait for block to finish playing */

if (buffer->pcm_nsamples == 0) {
– if (wait(buffer) == -1)
+ if (delay(buffer) == -1)
return -1;

buffer->pcm_length = 0;

#!/bin/bash

export CFLAGS=”
-I/Users/Shared/gnu/libid3tag-0.15.1b/include
-I/Users/Shared/gnu/libmad-0.15.1b/include
-msse

export CPPFLAGS=”
-I/Users/Shared/gnu/libid3tag-0.15.1b/include
-I/Users/Shared/gnu/libmad-0.15.1b/include

export LDFLAGS=”
-L/Users/Shared/gnu/libid3tag-0.15.1b/lib
-L/Users/Shared/gnu/libmad-0.15.1b/lib

./configure
–prefix=/Users/Shared/gnu/madplay-0.15.2b

enable subversion server come with Leopard

Mac Leopard actually come with subversion server and client that integrated with its own apache2.


Steps to enable it:

LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so
LoadModule authz_svn_module libexec/apache2/mod_authz_svn.so

    • enable httpd-ssl.conf by removing the comment from the following line in /etc/apache2/httpd.conf:

    Include /private/etc/apache2/extra/httpd-ssl.conf

    • Add the following line at the end of file /etc/apache2/extra/httpd-ssl.conf but before the </VirtualHost>
    DAV svn
    SVNPath /opt/repos
    AuthType Basic
    AuthName “Authorization Realm”
    AuthUserFile /etc/svn-auth-file
    Require valid-user
    • create the /etc/svn-auth-file using the following command to create user id. It will prompt for password twice

    htpasswd -cm /etc/svn-auth-file

    • restart apache by

    /usr/sbin/apachectl restart

    • mkdir the subversion repository, generate the first repository and change ownership of the folder to match with apache user

    mkdir /opt/repos

    svnadmin create /opt/repos
    chown -R www:www /opt/repos
    • test the access to subversion server using the https://127.0.0.1/svn/
    • try with svn co https://127.0.0.1/svn/trunk –username