Lines 17-80
Link Here
|
17 |
$OPT_TDIARYMASTER = "@@@@PREFIX@@@@/share/examples/tdiary" |
17 |
$OPT_TDIARYMASTER = "@@@@PREFIX@@@@/share/examples/tdiary" |
18 |
$OPT_LANG = '@@@@LANG@@@@' |
18 |
$OPT_LANG = '@@@@LANG@@@@' |
19 |
|
19 |
|
20 |
module FileUtils16 |
|
|
21 |
def FileUtils16.mkdir_p(dir, *options) |
22 |
begin |
23 |
FileUtils.mkdir_p(dir, *options) |
24 |
rescue TypeError |
25 |
optionhash = {} |
26 |
options.each { |o| optionhash[o] = true } |
27 |
FileUtils.mkdir_p(dir, optionhash) |
28 |
end |
29 |
end |
30 |
def FileUtils16.cp(src, dest, *options) |
31 |
begin |
32 |
FileUtils.cp(src, dest, *options) |
33 |
FileUtils.chmod(0644, dest, *options) |
34 |
rescue TypeError |
35 |
optionhash = {} |
36 |
options.each { |o| optionhash[o] = true } |
37 |
FileUtils.cp(src, dest, optionhash) |
38 |
end |
39 |
end |
40 |
def FileUtils16.cp_r(src, dest, *options) |
41 |
begin |
42 |
FileUtils.cp_r(src, dest, *options) |
43 |
rescue TypeError |
44 |
optionhash = {} |
45 |
options.each { |o| optionhash[o] = true } |
46 |
FileUtils.cp_r(src, dest, optionhash) |
47 |
end |
48 |
end |
49 |
def FileUtils16.rm(list, *options) |
50 |
begin |
51 |
FileUtils.rm(list, *options) |
52 |
rescue TypeError |
53 |
optionhash = {} |
54 |
options.each { |o| optionhash[o] = true } |
55 |
FileUtils.rm(list, optionhash) |
56 |
end |
57 |
end |
58 |
def FileUtils16.ln_s(list, destdir, *options) |
59 |
begin |
60 |
FileUtils.ln_s(list, destdir, *options) |
61 |
rescue TypeError |
62 |
optionhash = {} |
63 |
options.each { |o| optionhash[o] = true } |
64 |
FileUtils.ln_s(list, destdir, optionhash) |
65 |
end |
66 |
end |
67 |
def FileUtils16.chmod(mode, list, *options) |
68 |
begin |
69 |
FileUtils.chmod(mode, list, *options) |
70 |
rescue TypeError |
71 |
optionhash = {} |
72 |
options.each { |o| optionhash[o] = true } |
73 |
FileUtils.chmod(mode, list, optionhash) |
74 |
end |
75 |
end |
76 |
end |
77 |
|
78 |
def usage |
20 |
def usage |
79 |
STDERR.print "Usage: #{File.basename($0)} [options]\n" |
21 |
STDERR.print "Usage: #{File.basename($0)} [options]\n" |
80 |
STDERR.print "Options:\n" |
22 |
STDERR.print "Options:\n" |
Lines 137-143
Link Here
|
137 |
@username =(@passwd.name) |
79 |
@username =(@passwd.name) |
138 |
@diarydir = 'diary' |
80 |
@diarydir = 'diary' |
139 |
@httpdir = 'public_html' |
81 |
@httpdir = 'public_html' |
140 |
@fileutilOptions = [] |
82 |
@fileutilOptions = {} |
141 |
@author_name = @passwd.gecos |
83 |
@author_name = @passwd.gecos |
142 |
@author_host = "#{`hostname`.chomp}" |
84 |
@author_host = "#{`hostname`.chomp}" |
143 |
@author_mail = "#{@username}@#{`hostname`.chomp}" |
85 |
@author_mail = "#{@username}@#{`hostname`.chomp}" |
Lines 193-272
Link Here
|
193 |
|
135 |
|
194 |
def prepareDirs |
136 |
def prepareDirs |
195 |
if ! FileTest.exist?("#{@passwd.dir}/#{@diarydir}") |
137 |
if ! FileTest.exist?("#{@passwd.dir}/#{@diarydir}") |
196 |
FileUtils16.mkdir_p("#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) |
138 |
FileUtils.mkdir_p("#{@passwd.dir}/#{@diarydir}", @fileutilOptions) |
197 |
end |
139 |
end |
198 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}") |
140 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}") |
199 |
FileUtils16.mkdir_p("#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
141 |
FileUtils.mkdir_p("#{@passwd.dir}/#{@httpdir}/#{@diarydir}", @fileutilOptions) |
200 |
end |
142 |
end |
201 |
end |
143 |
end |
202 |
|
144 |
|
203 |
def linkBaseFile |
145 |
def linkBaseFile |
204 |
FileUtils16.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
146 |
FileUtils.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", @fileutilOptions) |
205 |
FileUtils16.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
147 |
FileUtils.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", @fileutilOptions) |
206 |
FileUtils16.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
|
|
207 |
tempfile = Tempfile.new("index.rb") |
148 |
tempfile = Tempfile.new("index.rb") |
208 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/index'\n" |
149 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/index'\n" |
209 |
tempfile.close |
150 |
tempfile.close |
210 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
151 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", @fileutilOptions) |
211 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
152 |
FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", @fileutilOptions) |
212 |
tempfile = Tempfile.new("update.rb") |
153 |
tempfile = Tempfile.new("update.rb") |
213 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/update'\n" |
154 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/update'\n" |
214 |
tempfile.close |
155 |
tempfile.close |
215 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
156 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", @fileutilOptions) |
216 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
157 |
FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", @fileutilOptions) |
217 |
end |
158 |
end |
218 |
|
159 |
|
219 |
def copyBaseFile |
160 |
def copyBaseFile |
220 |
FileUtils16.cp_r("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
161 |
opts = @fileutilOptions.dup |
221 |
FileUtils16.cp_r("#{@tdiarymaster}/misc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
162 |
opts.store(:preserve, true) |
222 |
FileUtils16.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
163 |
FileUtils.cp_r("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", opts) |
223 |
FileUtils16.cp_r("#{@tdiarymaster}/skel", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
164 |
FileUtils.cp_r("#{@tdiarymaster}/misc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", opts) |
224 |
FileUtils16.cp_r("#{@tdiarymaster}/tdiary", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
165 |
FileUtils.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", opts) |
225 |
FileUtils16.cp_r("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
166 |
FileUtils.cp_r("#{@tdiarymaster}/skel", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", opts) |
226 |
FileUtils16.cp("#{@tdiarymaster}/index.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
167 |
FileUtils.cp_r("#{@tdiarymaster}/tdiary", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", opts) |
227 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
168 |
FileUtils.cp_r("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", opts) |
228 |
FileUtils16.cp("#{@tdiarymaster}/update.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
169 |
FileUtils.cp("#{@tdiarymaster}/index.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", @fileutilOptions) |
229 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
170 |
FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", @fileutilOptions) |
230 |
FileUtils16.cp("#{@tdiarymaster}/tdiary.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.rb", *@fileutilOptions) |
171 |
FileUtils.cp("#{@tdiarymaster}/update.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", @fileutilOptions) |
231 |
FileUtils16.cp("#{@tdiarymaster}/README", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/README", *@fileutilOptions) |
172 |
FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", @fileutilOptions) |
232 |
if @lang == 'ja' then |
173 |
FileUtils.cp("#{@tdiarymaster}/tdiary.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.rb", @fileutilOptions) |
233 |
FileUtils16.ln_s("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/misc/plugin/jdate.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/plugin/000jdate.rb", *@fileutilOptions) |
174 |
FileUtils.cp("#{@tdiarymaster}/README", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/README", @fileutilOptions) |
234 |
end |
|
|
235 |
end |
175 |
end |
236 |
|
176 |
|
237 |
def installConfig |
177 |
def installConfig |
238 |
tempfile = Tempfile.new("tdiary.conf-ja") |
178 |
tempfile = Tempfile.new("tdiary.conf-ja") |
239 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/tdiary.conf.sample") |
179 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/tdiary.conf.sample") |
240 |
tempfile.close |
180 |
tempfile.close |
241 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", *@fileutilOptions) |
181 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", @fileutilOptions) |
242 |
|
182 |
|
243 |
tempfile = Tempfile.new("tdiary.conf-en") # sample configuration for English Environment |
183 |
tempfile = Tempfile.new("tdiary.conf-en") # sample configuration for English Environment |
244 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/misc/i18n/tdiary.conf.sample-en") |
184 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/misc/i18n/tdiary.conf.sample-en") |
245 |
tempfile.close |
185 |
tempfile.close |
246 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", *@fileutilOptions) |
186 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", @fileutilOptions) |
247 |
|
187 |
|
248 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf") |
188 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf") |
249 |
FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", *@fileutilOptions) |
189 |
FileUtils.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", @fileutilOptions) |
250 |
end |
190 |
end |
251 |
|
191 |
|
252 |
tempfile = Tempfile.new("dot.htaccess") |
192 |
tempfile = Tempfile.new("dot.htaccess") |
253 |
tempfile.write dothtaccessReplace("#{@tdiarymaster}/dot.htaccess") |
193 |
tempfile.write dothtaccessReplace("#{@tdiarymaster}/dot.htaccess") |
254 |
tempfile.close |
194 |
tempfile.close |
255 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", *@fileutilOptions) |
195 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", @fileutilOptions) |
256 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess") |
196 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess") |
257 |
FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess", *@fileutilOptions) |
197 |
FileUtils.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess", @fileutilOptions) |
258 |
end |
198 |
end |
259 |
end |
199 |
end |
260 |
|
200 |
|
261 |
def setPermissions |
201 |
def setPermissions |
262 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
202 |
FileUtils.chmod(0777, "#{@passwd.dir}/#{@diarydir}", @fileutilOptions) if ! defined?($OPT_SUEXEC) |
263 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
203 |
FileUtils.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", @fileutilOptions) if ! defined?($OPT_SUEXEC) |
264 |
FileUtils16.rm("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary-FreeBSD.sh", :force, *@fileutilOptions) |
204 |
|
265 |
|
205 |
FileUtils.chmod(0701, "#{@passwd.dir}/#{@diarydir}", @fileutilOptions) if defined?($OPT_SUEXEC) |
266 |
FileUtils16.chmod(0701, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if defined?($OPT_SUEXEC) |
206 |
FileUtils.chmod(0701, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", @fileutilOptions) if defined?($OPT_SUEXEC) |
267 |
FileUtils16.chmod(0701, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if defined?($OPT_SUEXEC) |
207 |
FileUtils.chmod(0604, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess", @fileutilOptions) if defined?($OPT_SUEXEC) |
268 |
FileUtils16.chmod(0700, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) if defined?($OPT_SUEXEC) |
208 |
FileUtils.chmod(0700, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", @fileutilOptions) if defined?($OPT_SUEXEC) |
269 |
FileUtils16.chmod(0700, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) if defined?($OPT_SUEXEC) |
209 |
FileUtils.chmod(0700, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", @fileutilOptions) if defined?($OPT_SUEXEC) |
270 |
|
210 |
|
271 |
if @euid == 0 then |
211 |
if @euid == 0 then |
272 |
Find.find("#{@passwd.dir}/#{@diarydir}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}") do |f| |
212 |
Find.find("#{@passwd.dir}/#{@diarydir}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}") do |f| |
Lines 320-327
Link Here
|
320 |
tdiaryinst.httpdir = $OPT_HTTPDIR if defined?($OPT_HTTPDIR) |
260 |
tdiaryinst.httpdir = $OPT_HTTPDIR if defined?($OPT_HTTPDIR) |
321 |
tdiaryinst.author_name = $OPT_NAME if defined?($OPT_NAME) |
261 |
tdiaryinst.author_name = $OPT_NAME if defined?($OPT_NAME) |
322 |
tdiaryinst.author_mail = $OPT_MAIL if defined?($OPT_MAIL) |
262 |
tdiaryinst.author_mail = $OPT_MAIL if defined?($OPT_MAIL) |
323 |
tdiaryinst.fileutilOptions.push(:noop) if defined?($OPT_NOOP) |
263 |
tdiaryinst.fileutilOptions.store(:noop, true) if defined?($OPT_NOOP) |
324 |
tdiaryinst.fileutilOptions.push(:verbose) if defined?($OPT_VERBOSE) |
264 |
tdiaryinst.fileutilOptions.store(:verbose, true) if defined?($OPT_VERBOSE) |
325 |
|
265 |
|
326 |
tdiaryinst.installAll |
266 |
tdiaryinst.installAll |