recorded this file from former fc4-based build
[infrastructure.git] / scripts / functions.sh
1 ### -*-sh-*-
2
3
4
5 ### create a symlink in same dir
6 # arguments 
7 # actual : full path of the actual file
8 # link : the link name, only basename is used, will be created in same dir
9 function manage_link () {
10     actual=$1; shift
11     latest=$1; shift
12     # go in the right directory
13     cd $(dirname $actual)
14     actualbase=$(basename $actual)
15     # just in case 
16     latest=$(basename $latest)
17     echo "In $(pwd) : linking $actualbase to $latest"
18     rm -f $latest ; ln -s $actualbase $latest
19     # go back to current dir
20     cd -
21 }
22     
23 # usage
24 # clean <where> <keeptime> [... find arguments]
25 function clean () {
26     where=$1; shift
27     keeptime=$1; shift
28     echo "== In $where"
29     echo "Cleaning $@ - older than $keeptime days"
30     find $where "$@" -atime +$keeptime | xargs rm 
31 }
32