/[docman2]/migrate.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /migrate.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Wed Jun 11 14:09:18 2003 UTC (20 years, 9 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +17 -15 lines
File MIME type: application/x-sh
first check if directory in docman 1.x site

1 dpavlin 1.1 #!/bin/sh
2    
3     # this shell script will try (when run inside old docman directory) to
4     # migrate docman v1.x installation to new v2.x directory layout
5     #
6     # 2003-06-11 Dobrica Pavlinusic <dpavlin@rot13.org>
7    
8     dir=`pwd`
9    
10     #
11 dpavlin 1.3 # try to guess docman installation directory from this script path
12     #
13    
14     D=`dirname "$0"`
15     docman2_dir="`cd \"$D\" 2>/dev/null && pwd || echo \"$D\"`"
16     docman2_realm="$docman2_dir/realm"
17    
18     if [ ! -e "$docman2_realm" -o ! -e "$docman2_dir/docman.php" ] ; then
19     echo "FATAL: You should start this script using full path to"
20     echo "docman installation directory and not from some other"
21     echo "path!! (e.g. /home/httpd/docman2/`basename $0`)"
22     exit 1
23     fi
24    
25     #
26 dpavlin 1.4 # try to find .htusers and .docman.conf which should always exists in
27     # valid existing repository
28     #
29    
30     if [ ! -e "$dir/.htusers" ] ; then
31     echo "FATAL: can't find $dir/.htusers file... aborting automatic migration"
32     echo "(is this really docman 1.x site directory?)"
33     exit 1
34     fi
35    
36     if [ ! -e "$dir/.docman.conf" ] ; then
37     echo "FATAL: can't find $dir/.docman.conf file... aborting automatic migration"
38     echo "(is this really docman 1.x site directory?)"
39     exit 1
40     fi
41    
42     #
43 dpavlin 1.1 # try to guess existing DirectoryIndex (docman.php)
44     #
45    
46     if [ -e "index.php" ] ; then
47     docman_php="index.php"
48     elif [ -e ".index.php" ] ; then
49     docman_php=".index.php"
50     elif [ -e "docman.php" ] ; then
51     docman_php="docman.php"
52     else
53     echo "can't find docman.php in current directory,"
54     echo -n "please enter it's name: "
55     read docman_php
56     if [ ! -e "$docman_php" ] ; then
57     echo "FATAL: $docman_php doesn't exits!"
58     exit 1
59     fi
60     fi
61    
62     #
63 dpavlin 1.3 # get some version numbers
64 dpavlin 1.1 #
65    
66     docman1_ver=`grep "gblVersion *=" $docman_php | cut -d\" -f2`
67     # convert dir to absolute path
68     docman2_ver=`grep "gblVersion *=" $docman2_dir/docman.php | cut -d\" -f2`
69    
70     #
71     # do some sanity checks
72     #
73    
74     if [ ! -e "$docman2_realm" ] ; then
75     echo "can't guess docman2 realm dir (it should be $docman2_realm),"
76     echo -n "enter it here: "
77     read $docman2_realm
78     fi
79    
80     if [ ! -w "$docman2_realm" ] ; then
81     echo "FATAL: $docman2_realm is not writable by current user..."
82 dpavlin 1.2 echo "(this is needed to create configuration files there)"
83 dpavlin 1.1 exit 1
84     fi
85    
86 dpavlin 1.2 if [ ! -w "$dir" -a ! -w "$dir/.html" ] ; then
87     echo "FATAL: $dir is not writable by current user..."
88     echo "(we needed to create new DocumentRoot dir $dir/.html; you can create"
89     echo "$dir/.html directory writable to current user manually)"
90     exit 1
91     fi
92    
93    
94 dpavlin 1.1 #
95     # begin real move
96     #
97    
98     d=`hostname -f`
99     echo "upgrading docman repository $dir from $docman1_ver to $docman2_ver..."
100     echo -n "docman2 virtual hostname [$d]: "
101     read http_virtual_host
102    
103     if [ -z "$http_virtual_host" ] ; then
104     http_virtual_host=$d
105     fi
106    
107     #
108     # migrate docman.conf
109     #
110    
111     f="$docman2_realm/$http_virtual_host.conf"
112     echo "creating $f"
113     #
114     # remove gblIncDir, fix gblUsers
115     #
116     cat $dir/.docman.conf | sed \
117     -e 's#\(\$gblIncDir\)#// -- removed in migration -- \1#g' \
118     -e 's#\(\$gblUsers.*\)htusers_#\1#' \
119     -e 's#?>#\
120     \
121     // added by migration script to create valid configuration\
122     \$gblRepositoryDir = "'$dir'";\
123     \
124     ?>#' > $f
125    
126     #
127     # migrate htusers
128     #
129     f="$docman2_realm/$http_virtual_host.htusers"
130     echo "creating $f"
131     cat $dir/.htusers > $f
132    
133     #
134     # copy template trustee file from distribution
135     #
136     f="$docman2_realm/$http_virtual_host.trustee"
137     echo "creating $f"
138     cat $docman2_realm/localhost.trustee.dist > $f
139 dpavlin 1.2 #
140     # add some permissions
141     #
142     echo "#
143     # this will give all permissions to all users (to emulate docman 1.x
144     # behaviour) -- you *WILL WANT* to change this!
145     /:*:RWB
146     #" >> $f
147 dpavlin 1.1
148     #
149     # now, create new .html directory which will be DocumentRoot
150     #
151     echo "creating $dir/.html -- new DocumentRoot"
152     mkdir $dir/.html
153     ln -sf $docman2_dir/docman.php $dir/.html/index.php
154     ln -sf $docman2_dir/html/docman.css $dir/.html/docman.css
155     echo
156     echo "!!!!!!!!!!!!!!!!!"
157     echo "!!! IMPORTANT !!!"
158     echo "!!!!!!!!!!!!!!!!!"
159     echo
160     echo "You will have to change apache's httpd.conf for"
161     echo "virtual host $http_virtual_host as follows:"
162     echo
163     echo " DocumentRoot $dir/.html"
164     echo " DirectoryIndex index.php"
165     echo
166     echo -n "remove old $docman1_ver files (new version are in $docman2_realm)? [y]: "
167     read rm_old
168     if [ "$rm_old" = "y" -o -z "$rm_old" ] ; then
169     rm $dir/$docman_php $dir/.docman.conf $dir/.htusers
170 dpavlin 1.2 else
171     echo "remove files manually: $dir/$docman_php $dir/.docman.conf $dir/.htusers"
172 dpavlin 1.1 fi
173     echo "migration done..."

  ViewVC Help
Powered by ViewVC 1.1.26