s3: Use dbwrap_parse_record in fetch_share_mode_unlocked
[kai/samba.git] / source3 / script / installmo.sh
1 #!/bin/sh
2
3 DESTDIR=$1
4 LOCALEDIR=`echo $2 | sed 's/\/\//\//g'`
5 SRCDIR=$3/
6 MSGFMT=msgfmt
7
8 case $0 in
9         *uninstall*)
10                 if test ! -d "$DESTDIR/$LOCALEDIR"; then
11                         echo "Directory $DESTDIR/$LOCALEDIR doesn't exist!"
12                         echo "Do a \"make installmo\" or \"make install\" first."
13                         exit 1
14                 fi
15                 mode='uninstall'
16         ;;
17         *)
18                 mode='install'
19         ;;
20 esac
21
22 for dir in $SRCDIR/locale/*; do
23         MODULE=`basename $dir`
24         for f in $SRCDIR/locale/$MODULE/*.po; do
25                 BASE=`basename $f`
26                 LANGUAGE=`echo $BASE | sed 's/\.po//g'`
27                 if test "$LANGUAGE" = '*'; then
28                         echo "No .po file exists!"
29                         exit 0
30                 fi
31                 FNAME="$DESTDIR/$LOCALEDIR/$LANGUAGE/LC_MESSAGES/$MODULE.mo"
32                 if test ! -d "$DESTDIR/$LOCALEDIR/$LANGUAGE/LC_MESSAGES/"; then
33                         mkdir -p "$DESTDIR/$LOCALEDIR/$LANGUAGE/LC_MESSAGES/"
34                 fi
35                 if test "$mode" = 'install'; then
36                         echo "Installing $f as $FNAME"
37                         touch "$FNAME"
38                         $MSGFMT -f -o "$FNAME" "$f"
39                         if test ! -f "$FNAME"; then
40                                 echo "Cannot install $FNAME. Does $USER have privileges?"
41                                 exit 1
42                         fi
43                         chmod 0644 "$FNAME"
44                 elif test "$mode" = 'uninstall'; then
45                         echo "removing $FNAME"
46                         rm -f "$FNAME"
47                         if test -f "$FNAME"; then
48                                 echo "Cannot remove $FNAME. Does $USER have privileges?"
49                                 exit 1
50                         fi
51                 else
52                         echo "Unknown mode $mode. script called as $0."
53                         exit 1
54                 fi
55         done
56         if test "$mode" = 'install'; then
57                 cat << EOF
58 ==============================================================
59 MO files for $MODULE are installed.
60 ==============================================================
61 EOF
62         else
63                 cat << EOF
64 ==============================================================
65 MO files for $MODULE are removed.
66 ==============================================================
67 EOF
68         fi
69 done
70
71 if test "$mode" = 'install'; then
72         cat << EOF
73 ==============================================================
74 All MO files for Samba are installed. You can use "make uninstall"
75 or "make uninstallmo" to remove them.
76 ==============================================================
77 EOF
78 else
79         cat << EOF
80 ==============================================================
81 All MO files for Samba are removed. you can use "make install"
82 or "make installmo" to install them.
83 ==============================================================
84 EOF
85 fi
86
87 exit 0