/[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

Contents of /migrate.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Wed Jun 11 14:07:23 2003 UTC (20 years, 10 months ago) by dpavlin
Branch: MAIN
Changes since 1.2: +16 -5 lines
File MIME type: application/x-sh
die if not started from docman installation directory

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

  ViewVC Help
Powered by ViewVC 1.1.26