/[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.2 - (show annotations)
Wed Jun 11 02:54:44 2003 UTC (20 years, 10 months ago) by dpavlin
Branch: MAIN
Changes since 1.1: +19 -0 lines
File MIME type: application/x-sh
add trustee permissions

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

  ViewVC Help
Powered by ViewVC 1.1.26