-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.sh
executable file
·233 lines (171 loc) · 5.41 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# $Header: /cvsroot/tikiwiki/tiki/setup.sh,v 1.42.2.4 2008-03-04 16:43:35 chriscramer Exp $
# Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
# All Rights Reserved. See copyright.txt for details and a complete list of authors.
# Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
# List of directories affected by this script:
DIRS="backups db dump files img/wiki img/wiki_up img/trackers installer modules/cache temp temp/cache templates_c templates styles maps whelp mods tiki_tests/tests"
if [ -d 'lib/Galaxia' ]; then
DIRS=$DIRS" lib/Galaxia/processes"
fi
if [ -d 'lib/equation' ]; then
DIRS=$DIRS" lib/equation/tmp"
DIRS=$DIRS" lib/equation/pictures"
fi
AUSER=nobody
AGROUP=nobody
RIGHTS=02775
VIRTUALS=""
UNAME=`uname | cut -c 1-6`
if [ -f /etc/debian_version ]; then
AUSER=www-data
AGROUP=www-data
fi
if [ -f /etc/redhat-release ]; then
AUSER=apache
AGROUP=apache
fi
if [ -f /etc/gentoo-release ]; then
AUSER=apache
AGROUP=apache
fi
if [ -f /etc/SuSE-release ]; then
AUSER=wwwrun
AGROUP=www
fi
if [ "$UNAME" = "CYGWIN" ]; then
AUSER=SYSTEM
AGROUP=SYSTEM
fi
if [ -z "$1" ]; then
cat <<EOF
This script assigns necessary permissions for the directories that the
webserver writes files to. It also creates the (initially empty) cache
directories, if necessary.
Usage sh $0 user [group] [rights] [list of virtual host domains]
For example, if apache is running as user $AUSER and group $AGROUP (can be found in phpinfo),
and if you are running as user $USER, type:
su -c 'sh $0 $USER $AGROUP'
This will allow you to delete certain files/directories without becoming root.
Or, if you can't become root, but are a member of the group apache runs under
(for example: $AGROUP), you can type:
sh $0 $USER $AGROUP
Be aware, that you probably have to do a
chown -R $USER *
if your tiki runs in a PHP-safe-mode environment.
If you can't become root, and are not a member of the apache group, but if
your system uses ACL's (check with "mount | grep acl"), then type:
sh $0 -acl $USER $AGROUP
If you can't become root, and are not a member of the apache group, and
your system does not support ACL's then type:
sh $0 $USER yourgroup 02777
Replace yourgroup with your default group. Tip: You can find your group using the command 'id'.
If you are on a shared hosting account, you can't become root, and your
group is probably the same as your user name. The following should work for you:
sh $0 $USER $USER 02777
NOTE: If you do execute on of the three last commands, you will not be able
to delete certain files created by apache, and will need to ask your system
administrator to delete them for you if needed. However, you may still be able to
rename (move) them.
---MultiTiki---
More information here:
http://doc.tikiwiki.org/MultiTiki
To use Tiki's multi-site capability (virtual hosts from a single DocumentRoot)
add a list of domains to the command to create all the needed directories.
For example:
su -c 'sh $0 $USER $AGROUP $RIGHTS domain1 domain2 domain3'
or, if you can't become root:
sh $0 $USER $AGROUP 02777 domain1 domain2 domain3
---Mods----
More information here:
http://mods.tikiwiki.org/
special for mods installer
sh $0 $AUSER all
will change perms on all tiki files so you can use the tikimods power.
Remember to run the perms setup again when mods installer use if done.
sh $0 $USER $AGROUP
EOF
exit 1
fi
if [ "$1" = "-acl" ]; then
ACL=1
shift
else
ACL=0
fi
if [ -n "$1" ]; then
AUSER=$1
shift
fi
if [ -n "$1" ]; then
if [ $1 = "all" ]; then
chown -R $AUSER *
exit 0
fi
AGROUP=$1
shift
fi
if [ -n "$1" ]; then
RIGHTS=$1
shift
fi
if [ -n "$1" ]; then
VIRTUALS=$@
touch db/virtuals.inc
fi
# Create directories as needed
for dir in $DIRS; do
if [ ! -d $dir ]; then
echo Creating directory "$dir"
mkdir -p $dir
fi
for vdir in $VIRTUALS; do
if [ ! -d "$dir/$vdir" ]; then
echo Creating directory "$dir/$vdir"
mkdir -p "$dir/$vdir"
fi
echo $vdir >> db/virtuals.inc
cat db/virtuals.inc | sort | uniq > db/virtuals.inc_new
rm -f db/virtuals.inc && mv db/virtuals.inc_new db/virtuals.inc
done
done
# Create htaccees files as needed
if [ ! -e "templates_c/_htaccess" ]; then
if [ ! -e "templates_c/.htaccess" ]; then
echo '<FilesMatch "*">
order deny,allow
deny from all
</FilesMatch>' > templates_c/_htaccess
fi
fi
# Create index.php files as needed
if [ ! -e "templates_c/index.php" ]; then
echo '<?php
// This file was generated by setup.sh script
// Copyright (c) 2002-2006, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// This redirects to the site root to prevent directory browsing
header ("location: ../tiki-index.php");
die;
?>' > templates_c/index.php
fi
# Set ownerships of the directories
chown -R $AUSER *
if [ -n "$AGROUP" ]; then
if [ $ACL = 1 ] ; then
setfacl -R -m g:${AGROUP}:rwx $DIRS
setfacl -m g:${AGROUP}:rwx robots.txt
else
chgrp -R $AGROUP $DIRS
chgrp $AGROUP robots.txt
fi
fi
if [ $ACL = 0 ] ; then
chmod -R $RIGHTS $DIRS
chmod $RIGHTS robots.txt
chmod $RIGHTS tiki-install.php
fi
chown $AUSER robots.txt
# by setting the rights to tiki-install.php file, tiki-installer can be used in most cases to disable execution of the script
chown $AUSER tiki-install.php
exit 0