updated on Thu Jan 19 12:17:07 UTC 2012
[aur-mirror.git] / gtkradiant-svn / gtkradiant.sh
blobb5524278b0be4fdf447a5735569adaf6a0704a00
1 #!/bin/bash
3 # A wrapper for applications that need write access
4 # to a directory that is write protected. We just link
5 # it to somewhere in home and it will work :)
6 # - thoughtcrime
9 # Configuration
11 # Path to the program
12 path_program="/usr/share/gtkradiant"
14 # Where will we put the files?
15 # (Somewhere in home would make sense)
16 path_target=~/.radiant/1.6.0
18 # Make sure that the temp path is unique
19 # for each user!
20 path_temp="/tmp/gtkradiant-`id -un`"
22 # $path_link are the folders where write access
23 # is required. Both variables are relative to the
24 # program folder.
25 path_link=("games")
26 path_app="radiant.bin"
28 # This is required if the application would find out
29 # its correctly installed path otherwise
30 hardlink_app="true"
32 # Configuration end
35 # Install the temporary folder
36 install -d "$path_temp"
38 # Link everything from the program in the temporary folder
39 for file_target in ${path_program}/*; do
40 if [[ "$hardlink_app" = "true" && "$path_temp/${file_target##*/}" = "$path_temp/$path_app" ]]; then
41 if [ ! -e "$path_temp/$path_app" ]; then
42 ln "$file_target" "$path_temp/$path_app"
44 elif [ ! -L "$path_temp/${file_target##*/}" ]; then
45 ln -s "$file_target" "$path_temp/${file_target##*/}"
47 done
49 # Link all folders that need write access
50 for file_link in ${path_link[@]}; do
51 if [ ! -d "$path_target/$file_link" ]; then
52 install -d "$path_target/$file_link"
54 if [ ! -L "$path_temp/$file_link" ]; then
55 ln -s "$path_target/$file_link" "$path_temp/$file_link"
57 done
59 # Start the application
60 cd "$path_temp"
61 ./"$path_app" $*