Lines 1-10
Link Here
|
1 |
#!/usr/local/bin/ruby |
1 |
#!/usr/bin/env ruby |
2 |
# |
2 |
# |
3 |
# tdiaryinstall.rb - tDiary user directory copy script |
3 |
# tdiaryinstall.rb - tDiary user directory copy script |
4 |
# Date created: 13 July 2003 |
4 |
# Date created: 13 July 2003 |
5 |
# Whom: KAMIYA Satosi <mimoriso@anet.ne.jp> |
5 |
# Whom: KAMIYA Satosi <mimoriso@anet.ne.jp> |
6 |
# |
6 |
# |
7 |
# $FreeBSD: ports/www/tdiary/files/tdiaryinst.rb.in,v 1.1 2003/07/29 05:53:24 daichi Exp $ |
7 |
# $FreeBSD$ |
8 |
# |
8 |
# |
9 |
|
9 |
|
10 |
require 'getoptlong' |
10 |
require 'getoptlong' |
Lines 17-22
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 |
rescue TypeError |
34 |
optionhash = {} |
35 |
options.each { |o| optionhash[o] = true } |
36 |
FileUtils.cp(src, dest, optionhash) |
37 |
end |
38 |
end |
39 |
def FileUtils16.cp_r(src, dest, *options) |
40 |
begin |
41 |
FileUtils.cp_r(src, dest, *options) |
42 |
rescue TypeError |
43 |
optionhash = {} |
44 |
options.each { |o| optionhash[o] = true } |
45 |
FileUtils.cp_r(src, dest, optionhash) |
46 |
end |
47 |
end |
48 |
def FileUtils16.rm(list, *options) |
49 |
begin |
50 |
FileUtils.rm(list, *options) |
51 |
rescue TypeError |
52 |
optionhash = {} |
53 |
options.each { |o| optionhash[o] = true } |
54 |
FileUtils.rm(list, optionhash) |
55 |
end |
56 |
end |
57 |
def FileUtils16.ln_s(list, destdir, *options) |
58 |
begin |
59 |
FileUtils.ln_s(list, destdir, *options) |
60 |
rescue TypeError |
61 |
optionhash = {} |
62 |
options.each { |o| optionhash[o] = true } |
63 |
FileUtils.ln_s(list, destdir, optionhash) |
64 |
end |
65 |
end |
66 |
def FileUtils16.chmod(mode, list, *options) |
67 |
begin |
68 |
FileUtils.chmod(mode, list, *options) |
69 |
rescue TypeError |
70 |
optionhash = {} |
71 |
options.each { |o| optionhash[o] = true } |
72 |
FileUtils.chmod(mode, list, optionhash) |
73 |
end |
74 |
end |
75 |
end |
76 |
|
20 |
def usage |
77 |
def usage |
21 |
STDERR.print "Usage: #{File.basename($0)} [options]\n" |
78 |
STDERR.print "Usage: #{File.basename($0)} [options]\n" |
22 |
STDERR.print "Options:\n" |
79 |
STDERR.print "Options:\n" |
Lines 73-89
Link Here
|
73 |
attr_accessor :fileutilOptions |
130 |
attr_accessor :fileutilOptions |
74 |
attr_accessor :author_name |
131 |
attr_accessor :author_name |
75 |
attr_accessor :author_mail |
132 |
attr_accessor :author_mail |
76 |
attr_accessor :author_host |
133 |
attr_reader :author_host #FK |
77 |
def initialize # ½é´üÃͤÎÀßÄê |
134 |
def initialize # ½é´üÃͤÎÀßÄê |
78 |
@passwd = Etc.getpwuid() # ½é´üÃÍ¤Ï¥í¥°¥¤¥ó¥æ¡¼¥¶ |
135 |
@passwd = Etc.getpwuid() # ½é´üÃÍ¤Ï¥í¥°¥¤¥ó¥æ¡¼¥¶ |
79 |
@euid = @passwd.uid |
136 |
@euid = @passwd.uid |
80 |
@username = (@passwd.name) # username=(value) ¥á¥½¥Ã¥É¤ÇºÆÄêµÁ¤·¤Æ¤¤¤ë |
137 |
@username =(@passwd.name) # username=(value) ¥á¥½¥Ã¥É¤ÇºÆÄêµÁ¤·¤Æ¤¤¤ë #FK |
81 |
@diarydir = 'diary' |
138 |
@diarydir = 'diary' |
82 |
@httpdir = 'public_html' |
139 |
@httpdir = 'public_html' |
83 |
@fileutilOptions = [] |
140 |
@fileutilOptions = [] |
84 |
@author_name = @passwd.gecos # F.Kimura |
141 |
@author_name = @passwd.gecos #FK |
85 |
@author_host = "#{`hostname`.chomp}" # F.Kimura |
142 |
@author_host = "#{`hostname`.chomp}" #FK |
86 |
@author_mail = "#{@username}@#{`hostname`.chomp}" |
143 |
@author_mail = "#{@username}@#{`hostname`.chomp}" #FK |
87 |
end |
144 |
end |
88 |
|
145 |
|
89 |
def username=(value) # username ¤òÂåÆþ¤¹¤ëºÝ¤Ë passwd¥á¥ó¥ÐÊÑ¿ô¤â¹¹¿·¤¹¤ë |
146 |
def username=(value) # username ¤òÂåÆþ¤¹¤ëºÝ¤Ë passwd¥á¥ó¥ÐÊÑ¿ô¤â¹¹¿·¤¹¤ë |
Lines 135-165
Link Here
|
135 |
def prepareDirs |
192 |
def prepareDirs |
136 |
# ¥¤¥ó¥¹¥È¡¼¥ëÀè¥Ç¥£¥ì¥¯¥È¥ê¤ÎÍÑ°Õ |
193 |
# ¥¤¥ó¥¹¥È¡¼¥ëÀè¥Ç¥£¥ì¥¯¥È¥ê¤ÎÍÑ°Õ |
137 |
if ! FileTest.exist?("#{@passwd.dir}/#{@diarydir}") |
194 |
if ! FileTest.exist?("#{@passwd.dir}/#{@diarydir}") |
138 |
FileUtils.mkdir_p("#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) |
195 |
FileUtils16.mkdir_p("#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) |
139 |
end |
196 |
end |
140 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}") |
197 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}") |
141 |
FileUtils.mkdir_p("#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
198 |
FileUtils16.mkdir_p("#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
142 |
end |
199 |
end |
143 |
end |
200 |
end |
144 |
|
201 |
|
145 |
def linkBaseFile # tDiary¤ÎÇÛÉÛ¥Õ¥¡¥¤¥ë¤Ï¥³¥Ô¡¼¤·¤Ê¤¤ |
202 |
def linkBaseFile # tDiary¤ÎÇÛÉÛ¥Õ¥¡¥¤¥ë¤Ï¥³¥Ô¡¼¤·¤Ê¤¤ |
146 |
FileUtils.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
203 |
FileUtils16.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
147 |
FileUtils.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
204 |
FileUtils16.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
148 |
FileUtils.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
205 |
FileUtils16.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
149 |
tempfile = Tempfile.new("index.rb") |
206 |
tempfile = Tempfile.new("index.rb") |
150 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/index'\n" |
207 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/index'\n" |
151 |
tempfile.close |
208 |
tempfile.close |
152 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
209 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
153 |
FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
210 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
154 |
tempfile = Tempfile.new("update.rb") |
211 |
tempfile = Tempfile.new("update.rb") |
155 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/update'\n" |
212 |
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/update'\n" |
156 |
tempfile.close |
213 |
tempfile.close |
157 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
214 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
158 |
FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
215 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
159 |
end |
216 |
end |
160 |
|
217 |
|
161 |
def copyBaseFile # tDiary¤ÎÇÛÉÛ¥Õ¥¡¥¤¥ë¤ò¤¹¤Ù¤Æ¥³¥Ô¡¼ |
218 |
def copyBaseFile # tDiary¤ÎÇÛÉÛ¥Õ¥¡¥¤¥ë¤ò¤¹¤Ù¤Æ¥³¥Ô¡¼ |
162 |
FileUtils.cp_r("#{@tdiarymaster}/", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
219 |
FileUtils16.cp_r("#{@tdiarymaster}/", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
163 |
end |
220 |
end |
164 |
|
221 |
|
165 |
def installConfig |
222 |
def installConfig |
Lines 167-197
Link Here
|
167 |
tempfile = Tempfile.new("tdiary.conf-ja") # ÆüËܸì´Ä¶¥µ¥ó¥×¥ë |
224 |
tempfile = Tempfile.new("tdiary.conf-ja") # ÆüËܸì´Ä¶¥µ¥ó¥×¥ë |
168 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/tdiary.conf.sample") |
225 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/tdiary.conf.sample") |
169 |
tempfile.close |
226 |
tempfile.close |
170 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", *@fileutilOptions) |
227 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", *@fileutilOptions) |
171 |
|
228 |
|
172 |
tempfile = Tempfile.new("tdiary.conf-en") # sample configuration for English Environment |
229 |
tempfile = Tempfile.new("tdiary.conf-en") # sample configuration for English Environment |
173 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/misc/i18n/tdiary.conf.sample-en") |
230 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/misc/i18n/tdiary.conf.sample-en") |
174 |
tempfile.close |
231 |
tempfile.close |
175 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", *@fileutilOptions) |
232 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", *@fileutilOptions) |
176 |
|
233 |
|
177 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf") # tdiary.conf ¤¬¤Ê¤±¤ì¤ÐÀßÃÖ |
234 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf") # tdiary.conf ¤¬¤Ê¤±¤ì¤ÐÀßÃÖ |
178 |
FileUtils.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", *@fileutilOptions) |
235 |
FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", *@fileutilOptions) |
179 |
end |
236 |
end |
180 |
# TODO: @lang¤ÎÃͤˤè¤Ã¤Æ plugin/00lang.en.rb ¥³¥Ô¡¼/ºï½ü¤ÎÀ©¸æ¤â¤·¤¿¤¤ |
237 |
# TODO: @lang¤ÎÃͤˤè¤Ã¤Æ plugin/00lang.en.rb ¥³¥Ô¡¼/ºï½ü¤ÎÀ©¸æ¤â¤·¤¿¤¤ |
181 |
|
238 |
|
182 |
tempfile = Tempfile.new("dot.htaccess") |
239 |
tempfile = Tempfile.new("dot.htaccess") |
183 |
tempfile.write dothtaccessReplace("#{@tdiarymaster}/dot.htaccess") |
240 |
tempfile.write dothtaccessReplace("#{@tdiarymaster}/dot.htaccess") |
184 |
tempfile.close |
241 |
tempfile.close |
185 |
FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", *@fileutilOptions) |
242 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", *@fileutilOptions) |
186 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess") |
243 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess") |
187 |
FileUtils.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess", *@fileutilOptions) |
244 |
FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess", *@fileutilOptions) |
188 |
end |
245 |
end |
189 |
end |
246 |
end |
190 |
|
247 |
|
191 |
def setPermissions # ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼¡¦À¸À®°Ê³°¤Î½èÍý |
248 |
def setPermissions # ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼¡¦À¸À®°Ê³°¤Î½èÍý |
192 |
FileUtils.chmod(0777, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
249 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
193 |
FileUtils.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
250 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
194 |
FileUtils.rm("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary-FreeBSD.sh", :force, *@fileutilOptions) |
251 |
FileUtils16.rm("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary-FreeBSD.sh", :force, *@fileutilOptions) |
195 |
|
252 |
|
196 |
if @euid == 0 then # superuser ¸¢¸Â¤Ç¤³¤Î¥¤¥ó¥¹¥È¡¼¥é¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¾ì¹ç |
253 |
if @euid == 0 then # superuser ¸¢¸Â¤Ç¤³¤Î¥¤¥ó¥¹¥È¡¼¥é¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¾ì¹ç |
197 |
# ¤¹¤Ù¤Æ¤Î¥Ç¥£¥ì¥¯¥È¥ê¡¦¥Õ¥¡¥¤¥ë¤Ë chown ¤Ç½êͼÔÊѹ¹ |
254 |
# ¤¹¤Ù¤Æ¤Î¥Ç¥£¥ì¥¯¥È¥ê¡¦¥Õ¥¡¥¤¥ë¤Ë chown ¤Ç½êͼÔÊѹ¹ |
Lines 216-222
Link Here
|
216 |
line = "@author_name = '#{@author_name}'\n" if line =~ /^\@author_name\s/ |
273 |
line = "@author_name = '#{@author_name}'\n" if line =~ /^\@author_name\s/ |
217 |
line = "@author_mail = '#{@author_mail}'\n" if line =~ /^\@author_mail\s/ |
274 |
line = "@author_mail = '#{@author_mail}'\n" if line =~ /^\@author_mail\s/ |
218 |
line = "@html_title = '#{@author_name} diary'\n" if line =~ /^\@html_title\s/ |
275 |
line = "@html_title = '#{@author_name} diary'\n" if line =~ /^\@html_title\s/ |
219 |
line = "@index_page = 'http://#{@author_host}/~#{@username}\/'" if line =~ /^\@index_page\s/ # F.Kimura |
276 |
line = "@index_page = 'http://#{@author_host}/~#{@username}\/'" if line =~ /^\@index_page\s/ #FK |
220 |
s += line |
277 |
s += line |
221 |
} |
278 |
} |
222 |
} |
279 |
} |