root/trunk/licq/bin/sidclean.sh

Revision 6202, 1.1 kB (checked in by eugene, 6 months ago)

Added executable flag to sidclean.sh

  • Property svn:executable set to *
Line 
1#!/bin/bash
2# By Juan. (juam on #licq)
3#
4# !!! BACKUP YOUR LICQ FOLDER (~/.licq) JUST IN CASE!!!
5#
6
7BACK_SUFIX="~"
8
9function change_val()
10{   local back;
11
12    back="$1$BACK_SUFIX"
13    vars=$2
14    cp "$1" "$back"
15    awk  '
16        $1 ~ /^('$vars')/ {
17            print $1 " = 0"
18        }
19        $1 !~ /^('$vars')/ {
20            print
21        }
22    ' < "$back" > "$1" 
23
24}
25
26
27function check()
28{   
29    if [[  ! -a $1 ]]; then
30        echo "$1: not found. exiting."
31        exit 1
32    fi
33}
34
35case $# in
36    0)  echo "Usage: $0 licq-dir"
37            exit 1
38esac
39
40for root in $@; do
41
42    echo "changing users from $root/users/\*.Licq"
43    check "$root/users"
44    for i in "$root"/users/*.Licq; do
45        change_val "$i" "SID|GSID|InvisibleSID|VisibleSID"
46    done
47
48    echo "changing $root/owner.Licq"
49    check "$root/owner.Licq"
50    change_val "$root/owner.Licq" "SSTime|SSCount"
51
52    echo "changing $root/licq.conf"
53    check "$root/licq.conf"
54    t=`grep NumOfGroups "$root/licq.conf" |
55       cut -d'=' -f2 |
56       awk '
57       {    for(i=1;i<=$1;i++)
58        {   if( i == 1)
59                c = "";
60            else
61                c = "|";
62            ba = sprintf("%s%sGroup%d.id",ba,c,i);
63        }
64        print ba
65       }'`
66    change_val "$root"/licq.conf "$t"
67
68done
Note: See TracBrowser for help on using the browser.