Lines 13-19
Link Here
|
13 |
require 'find' |
13 |
require 'find' |
14 |
require 'tempfile' |
14 |
require 'tempfile' |
15 |
|
15 |
|
16 |
# make install»þ¤ËÃÖ´¹¤µ¤ì¤ë¥°¥í¡¼¥Ð¥ëÊÑ¿ô --tdiarymaster, --lang ¥ª¥×¥·¥ç¥ó¤Ç¾å½ñ¤²Äǽ |
16 |
# |
17 |
$OPT_TDIARYMASTER = "@@@@PREFIX@@@@/share/examples/tdiary" |
17 |
$OPT_TDIARYMASTER = "@@@@PREFIX@@@@/share/examples/tdiary" |
18 |
$OPT_LANG = '@@@@LANG@@@@' |
18 |
$OPT_LANG = '@@@@LANG@@@@' |
19 |
|
19 |
|
Lines 93-99
Link Here
|
93 |
exit 1 |
93 |
exit 1 |
94 |
end |
94 |
end |
95 |
|
95 |
|
96 |
# °ú¿ô¤Î²òÀÏ |
|
|
97 |
parser = GetoptLong.new |
96 |
parser = GetoptLong.new |
98 |
parser.set_options( |
97 |
parser.set_options( |
99 |
['--user', '-u', GetoptLong::REQUIRED_ARGUMENT], |
98 |
['--user', '-u', GetoptLong::REQUIRED_ARGUMENT], |
Lines 122-128
Link Here
|
122 |
attr_accessor :tdiarymaster |
121 |
attr_accessor :tdiarymaster |
123 |
attr_accessor :tdconfig |
122 |
attr_accessor :tdconfig |
124 |
attr_accessor :lang |
123 |
attr_accessor :lang |
125 |
attr_reader :euid # tdiaryinstall¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¥æ¡¼¥¶ID |
124 |
attr_reader :euid |
126 |
attr_accessor :username |
125 |
attr_accessor :username |
127 |
attr_accessor :diarydir |
126 |
attr_accessor :diarydir |
128 |
attr_accessor :httpdir |
127 |
attr_accessor :httpdir |
Lines 130-152
Link Here
|
130 |
attr_accessor :fileutilOptions |
129 |
attr_accessor :fileutilOptions |
131 |
attr_accessor :author_name |
130 |
attr_accessor :author_name |
132 |
attr_accessor :author_mail |
131 |
attr_accessor :author_mail |
133 |
attr_reader :author_host #FK |
132 |
attr_reader :author_host |
134 |
def initialize # ½é´üÃͤÎÀßÄê |
133 |
def initialize |
135 |
@passwd = Etc.getpwuid() # ½é´üÃÍ¤Ï¥í¥°¥¤¥ó¥æ¡¼¥¶ |
134 |
@passwd = Etc.getpwuid() |
136 |
@euid = @passwd.uid |
135 |
@euid = @passwd.uid |
137 |
@username =(@passwd.name) # username=(value) ¥á¥½¥Ã¥É¤ÇºÆÄêµÁ¤·¤Æ¤¤¤ë #FK |
136 |
@username =(@passwd.name) |
138 |
@diarydir = 'diary' |
137 |
@diarydir = 'diary' |
139 |
@httpdir = 'public_html' |
138 |
@httpdir = 'public_html' |
140 |
@fileutilOptions = [] |
139 |
@fileutilOptions = [] |
141 |
@author_name = @passwd.gecos #FK |
140 |
@author_name = @passwd.gecos |
142 |
@author_host = "#{`hostname`.chomp}" #FK |
141 |
@author_host = "#{`hostname`.chomp}" |
143 |
@author_mail = "#{@username}@#{`hostname`.chomp}" #FK |
142 |
@author_mail = "#{@username}@#{`hostname`.chomp}" |
144 |
end |
143 |
end |
145 |
|
144 |
|
146 |
def username=(value) # username ¤òÂåÆþ¤¹¤ëºÝ¤Ë passwd¥á¥ó¥ÐÊÑ¿ô¤â¹¹¿·¤¹¤ë |
145 |
def username=(value) |
147 |
@username = value |
146 |
@username = value |
148 |
@passwd = Etc.getpwnam(@username) # getpwnam(3) ¤Ë¤è¤ê passwd ¹½Â¤ÂΤò¼èÆÀ¤¹¤ë |
147 |
@passwd = Etc.getpwnam(@username) |
149 |
# ¥æ¡¼¥¶Ì¾¤¬Â¸ºß¤·¤Ê¤«¤Ã¤¿¾ì¹ç¡¢Etc.getpwnam() ¤ÏÎã³°¤òȯÀ¸¤¹¤ë¡£ |
|
|
150 |
@author_name = @passwd.gecos |
148 |
@author_name = @passwd.gecos |
151 |
@author_mail = "#{@username}@#{`hostname`.chomp}" |
149 |
@author_mail = "#{@username}@#{`hostname`.chomp}" |
152 |
end |
150 |
end |
Lines 190-196
Link Here
|
190 |
end |
188 |
end |
191 |
|
189 |
|
192 |
def prepareDirs |
190 |
def prepareDirs |
193 |
# ¥¤¥ó¥¹¥È¡¼¥ëÀè¥Ç¥£¥ì¥¯¥È¥ê¤ÎÍÑ°Õ |
|
|
194 |
if ! FileTest.exist?("#{@passwd.dir}/#{@diarydir}") |
191 |
if ! FileTest.exist?("#{@passwd.dir}/#{@diarydir}") |
195 |
FileUtils16.mkdir_p("#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) |
192 |
FileUtils16.mkdir_p("#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) |
196 |
end |
193 |
end |
Lines 199-205
Link Here
|
199 |
end |
196 |
end |
200 |
end |
197 |
end |
201 |
|
198 |
|
202 |
def linkBaseFile # tDiary¤ÎÇÛÉÛ¥Õ¥¡¥¤¥ë¤Ï¥³¥Ô¡¼¤·¤Ê¤¤ |
199 |
def linkBaseFile |
203 |
FileUtils16.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
200 |
FileUtils16.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
204 |
FileUtils16.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
201 |
FileUtils16.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
205 |
FileUtils16.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
202 |
FileUtils16.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
Lines 215-227
Link Here
|
215 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
212 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
216 |
end |
213 |
end |
217 |
|
214 |
|
218 |
def copyBaseFile # tDiary¤ÎÇÛÉÛ¥Õ¥¡¥¤¥ë¤ò¤¹¤Ù¤Æ¥³¥Ô¡¼ |
215 |
def copyBaseFile |
219 |
FileUtils16.cp_r("#{@tdiarymaster}/", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
216 |
FileUtils16.cp_r("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
|
|
217 |
FileUtils16.cp_r("#{@tdiarymaster}/erb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
218 |
FileUtils16.cp_r("#{@tdiarymaster}/misc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
219 |
FileUtils16.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
220 |
FileUtils16.cp_r("#{@tdiarymaster}/skel", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
221 |
FileUtils16.cp_r("#{@tdiarymaster}/tdiary", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
222 |
FileUtils16.cp_r("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions) |
223 |
FileUtils16.cp("#{@tdiarymaster}/index.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
224 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions) |
225 |
FileUtils16.cp("#{@tdiarymaster}/update.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
226 |
FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions) |
227 |
FileUtils16.cp("#{@tdiarymaster}/tdiary.rb", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
228 |
FileUtils16.cp("#{@tdiarymaster}/README", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) |
220 |
end |
229 |
end |
221 |
|
230 |
|
222 |
def installConfig |
231 |
def installConfig |
223 |
# ÀßÄê¥Õ¥¡¥¤¥ë¤òÀ¸À®¤·¤Æ¥¤¥ó¥¹¥È¡¼¥ë |
232 |
tempfile = Tempfile.new("tdiary.conf-ja") |
224 |
tempfile = Tempfile.new("tdiary.conf-ja") # ÆüËܸì´Ä¶¥µ¥ó¥×¥ë |
|
|
225 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/tdiary.conf.sample") |
233 |
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/tdiary.conf.sample") |
226 |
tempfile.close |
234 |
tempfile.close |
227 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", *@fileutilOptions) |
235 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", *@fileutilOptions) |
Lines 231-240
Link Here
|
231 |
tempfile.close |
239 |
tempfile.close |
232 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", *@fileutilOptions) |
240 |
FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", *@fileutilOptions) |
233 |
|
241 |
|
234 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf") # tdiary.conf ¤¬¤Ê¤±¤ì¤ÐÀßÃÖ |
242 |
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf") |
235 |
FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", *@fileutilOptions) |
243 |
FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", *@fileutilOptions) |
236 |
end |
244 |
end |
237 |
# TODO: @lang¤ÎÃͤˤè¤Ã¤Æ plugin/00lang.en.rb ¥³¥Ô¡¼/ºï½ü¤ÎÀ©¸æ¤â¤·¤¿¤¤ |
|
|
238 |
|
245 |
|
239 |
tempfile = Tempfile.new("dot.htaccess") |
246 |
tempfile = Tempfile.new("dot.htaccess") |
240 |
tempfile.write dothtaccessReplace("#{@tdiarymaster}/dot.htaccess") |
247 |
tempfile.write dothtaccessReplace("#{@tdiarymaster}/dot.htaccess") |
Lines 245-271
Link Here
|
245 |
end |
252 |
end |
246 |
end |
253 |
end |
247 |
|
254 |
|
248 |
def setPermissions # ¥Õ¥¡¥¤¥ë¥³¥Ô¡¼¡¦À¸À®°Ê³°¤Î½èÍý |
255 |
def setPermissions |
249 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
256 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
250 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
257 |
FileUtils16.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC) |
251 |
FileUtils16.rm("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary-FreeBSD.sh", :force, *@fileutilOptions) |
258 |
FileUtils16.rm("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary-FreeBSD.sh", :force, *@fileutilOptions) |
252 |
|
259 |
|
253 |
if @euid == 0 then # superuser ¸¢¸Â¤Ç¤³¤Î¥¤¥ó¥¹¥È¡¼¥é¤ò¼Â¹Ô¤·¤Æ¤¤¤ë¾ì¹ç |
260 |
if @euid == 0 then |
254 |
# ¤¹¤Ù¤Æ¤Î¥Ç¥£¥ì¥¯¥È¥ê¡¦¥Õ¥¡¥¤¥ë¤Ë chown ¤Ç½êͼÔÊѹ¹ |
|
|
255 |
Find.find("#{@passwd.dir}/#{@diarydir}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}") do |f| |
261 |
Find.find("#{@passwd.dir}/#{@diarydir}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}") do |f| |
256 |
File.chown(@passwd.uid, @passwd.gid, f) |
262 |
File.chown(@passwd.uid, @passwd.gid, f) |
257 |
end |
263 |
end |
258 |
if File::Stat.new("#{@passwd.dir}/#{@httpdir}").uid == 0 # ~/public_html ¤Î¥ª¡¼¥Ê¡¼¤¬superuser |
264 |
if File::Stat.new("#{@passwd.dir}/#{@httpdir}").uid == 0 |
259 |
File.chown(@passwd.uid, @passwd.gid, "#{@passwd.dir}/#{@httpdir}") |
265 |
File.chown(@passwd.uid, @passwd.gid, "#{@passwd.dir}/#{@httpdir}") |
260 |
end |
266 |
end |
261 |
end |
267 |
end |
262 |
end |
268 |
end |
263 |
|
269 |
|
264 |
def echo(s) # --quiet ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¾ì¹ç¤Ë¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ¹¤ë |
270 |
def echo(s) |
265 |
STDOUT.print s if ! defined?($OPT_QUIET) |
271 |
STDOUT.print s if ! defined?($OPT_QUIET) |
266 |
end |
272 |
end |
267 |
|
273 |
|
268 |
def tdiaryConfReplace(filename) # ¥µ¥ó¥×¥ë tdiary.conf ¤ò½ñ¤´¹¤¨¤ë¥á¥½¥Ã¥É |
274 |
def tdiaryConfReplace(filename) |
269 |
s = '' |
275 |
s = '' |
270 |
File.open(filename) { |fp| |
276 |
File.open(filename) { |fp| |
271 |
fp.each { |line| |
277 |
fp.each { |line| |
Lines 273-286
Link Here
|
273 |
line = "@author_name = '#{@author_name}'\n" if line =~ /^\@author_name\s/ |
279 |
line = "@author_name = '#{@author_name}'\n" if line =~ /^\@author_name\s/ |
274 |
line = "@author_mail = '#{@author_mail}'\n" if line =~ /^\@author_mail\s/ |
280 |
line = "@author_mail = '#{@author_mail}'\n" if line =~ /^\@author_mail\s/ |
275 |
line = "@html_title = '#{@author_name} diary'\n" if line =~ /^\@html_title\s/ |
281 |
line = "@html_title = '#{@author_name} diary'\n" if line =~ /^\@html_title\s/ |
276 |
line = "@index_page = 'http://#{@author_host}/~#{@username}\/'" if line =~ /^\@index_page\s/ #FK |
282 |
line = "@index_page = 'http://#{@author_host}/~#{@username}\/'" if line =~ /^\@index_page\s/ |
277 |
s += line |
283 |
s += line |
278 |
} |
284 |
} |
279 |
} |
285 |
} |
280 |
s |
286 |
s |
281 |
end |
287 |
end |
282 |
|
288 |
|
283 |
def dothtaccessReplace(filename) # ¥µ¥ó¥×¥ë dot.htaccess ¤ò½ñ¤´¹¤¨¤ë¥á¥½¥Ã¥É |
289 |
def dothtaccessReplace(filename) |
284 |
s = '' |
290 |
s = '' |
285 |
File.open(filename) { |fp| |
291 |
File.open(filename) { |fp| |
286 |
fp.each { |line| |
292 |
fp.each { |line| |
Lines 297-303
Link Here
|
297 |
tdiaryinst = TdiaryInstall.new |
303 |
tdiaryinst = TdiaryInstall.new |
298 |
tdiaryinst.tdiarymaster = $OPT_TDIARYMASTER |
304 |
tdiaryinst.tdiarymaster = $OPT_TDIARYMASTER |
299 |
tdiaryinst.lang = $OPT_LANG |
305 |
tdiaryinst.lang = $OPT_LANG |
300 |
tdiaryinst.username = $OPT_USER if defined?($OPT_USER) # $OPT_NAME¤ÎÀßÄê¤è¤êÁ°¤Ç¤Ê¤¤¤È¤¤¤±¤Ê¤¤ |
306 |
tdiaryinst.username = $OPT_USER if defined?($OPT_USER) |
301 |
tdiaryinst.diarydir = $OPT_DIARYDIR if defined?($OPT_DIARYDIR) |
307 |
tdiaryinst.diarydir = $OPT_DIARYDIR if defined?($OPT_DIARYDIR) |
302 |
tdiaryinst.httpdir = $OPT_HTTPDIR if defined?($OPT_HTTPDIR) |
308 |
tdiaryinst.httpdir = $OPT_HTTPDIR if defined?($OPT_HTTPDIR) |
303 |
tdiaryinst.author_name = $OPT_NAME if defined?($OPT_NAME) |
309 |
tdiaryinst.author_name = $OPT_NAME if defined?($OPT_NAME) |