summaryrefslogtreecommitdiff
path: root/www/tdiary/files/tdiaryinst.rb.in
diff options
context:
space:
mode:
Diffstat (limited to 'www/tdiary/files/tdiaryinst.rb.in')
-rw-r--r--www/tdiary/files/tdiaryinst.rb.in111
1 files changed, 84 insertions, 27 deletions
diff --git a/www/tdiary/files/tdiaryinst.rb.in b/www/tdiary/files/tdiaryinst.rb.in
index da176f83bd40..23df82306bb4 100644
--- a/www/tdiary/files/tdiaryinst.rb.in
+++ b/www/tdiary/files/tdiaryinst.rb.in
@@ -1,8 +1,8 @@
-#!/usr/local/bin/ruby
+#!/usr/bin/env ruby
#
# tdiaryinstall.rb - tDiary user directory copy script
-# Date created: 13 July 2003
-# Whom: KAMIYA Satosi <mimoriso@anet.ne.jp>
+# Date created: 13 July 2003
+# Whom: KAMIYA Satosi <mimoriso@anet.ne.jp>
#
# $FreeBSD$
#
@@ -17,6 +17,63 @@ require 'tempfile'
$OPT_TDIARYMASTER = "@@@@PREFIX@@@@/share/examples/tdiary"
$OPT_LANG = '@@@@LANG@@@@'
+module FileUtils16
+ def FileUtils16.mkdir_p(dir, *options)
+ begin
+ FileUtils.mkdir_p(dir, *options)
+ rescue TypeError
+ optionhash = {}
+ options.each { |o| optionhash[o] = true }
+ FileUtils.mkdir_p(dir, optionhash)
+ end
+ end
+ def FileUtils16.cp(src, dest, *options)
+ begin
+ FileUtils.cp(src, dest, *options)
+ rescue TypeError
+ optionhash = {}
+ options.each { |o| optionhash[o] = true }
+ FileUtils.cp(src, dest, optionhash)
+ end
+ end
+ def FileUtils16.cp_r(src, dest, *options)
+ begin
+ FileUtils.cp_r(src, dest, *options)
+ rescue TypeError
+ optionhash = {}
+ options.each { |o| optionhash[o] = true }
+ FileUtils.cp_r(src, dest, optionhash)
+ end
+ end
+ def FileUtils16.rm(list, *options)
+ begin
+ FileUtils.rm(list, *options)
+ rescue TypeError
+ optionhash = {}
+ options.each { |o| optionhash[o] = true }
+ FileUtils.rm(list, optionhash)
+ end
+ end
+ def FileUtils16.ln_s(list, destdir, *options)
+ begin
+ FileUtils.ln_s(list, destdir, *options)
+ rescue TypeError
+ optionhash = {}
+ options.each { |o| optionhash[o] = true }
+ FileUtils.ln_s(list, destdir, optionhash)
+ end
+ end
+ def FileUtils16.chmod(mode, list, *options)
+ begin
+ FileUtils.chmod(mode, list, *options)
+ rescue TypeError
+ optionhash = {}
+ options.each { |o| optionhash[o] = true }
+ FileUtils.chmod(mode, list, optionhash)
+ end
+ end
+end
+
def usage
STDERR.print "Usage: #{File.basename($0)} [options]\n"
STDERR.print "Options:\n"
@@ -73,17 +130,17 @@ class TdiaryInstall
attr_accessor :fileutilOptions
attr_accessor :author_name
attr_accessor :author_mail
- attr_accessor :author_host
+ attr_reader :author_host #FK
def initialize # 初期値の設定
@passwd = Etc.getpwuid() # 初期値はログインユーザ
@euid = @passwd.uid
- @username = (@passwd.name) # username=(value) メソッドで再定義している
+ @username =(@passwd.name) # username=(value) メソッドで再定義している #FK
@diarydir = 'diary'
@httpdir = 'public_html'
@fileutilOptions = []
- @author_name = @passwd.gecos # F.Kimura
- @author_host = "#{`hostname`.chomp}" # F.Kimura
- @author_mail = "#{@username}@#{`hostname`.chomp}"
+ @author_name = @passwd.gecos #FK
+ @author_host = "#{`hostname`.chomp}" #FK
+ @author_mail = "#{@username}@#{`hostname`.chomp}" #FK
end
def username=(value) # username を代入する際に passwdメンバ変数も更新する
@@ -135,31 +192,31 @@ class TdiaryInstall
def prepareDirs
# インストール先ディレクトリの用意
if ! FileTest.exist?("#{@passwd.dir}/#{@diarydir}")
- FileUtils.mkdir_p("#{@passwd.dir}/#{@diarydir}", *@fileutilOptions)
+ FileUtils16.mkdir_p("#{@passwd.dir}/#{@diarydir}", *@fileutilOptions)
end
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}")
- FileUtils.mkdir_p("#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions)
+ FileUtils16.mkdir_p("#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions)
end
end
def linkBaseFile # tDiaryの配布ファイルはコピーしない
- FileUtils.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions)
- FileUtils.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions)
- FileUtils.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions)
+ FileUtils16.cp_r("#{@tdiarymaster}/plugin", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions)
+ FileUtils16.ln_s("#{@tdiarymaster}/theme", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions)
+ FileUtils16.ln_s("#{@tdiarymaster}/doc", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions)
tempfile = Tempfile.new("index.rb")
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/index'\n"
tempfile.close
- FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions)
- FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions)
+ FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions)
+ FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/index.rb", *@fileutilOptions)
tempfile = Tempfile.new("update.rb")
tempfile.write "#!/usr/local/bin/ruby\nrequire '#{@tdiarymaster}/update'\n"
tempfile.close
- FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions)
- FileUtils.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions)
+ FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions)
+ FileUtils16.chmod(0755, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/update.rb", *@fileutilOptions)
end
def copyBaseFile # tDiaryの配布ファイルをすべてコピー
- FileUtils.cp_r("#{@tdiarymaster}/", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions)
+ FileUtils16.cp_r("#{@tdiarymaster}/", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", :preserve, *@fileutilOptions)
end
def installConfig
@@ -167,31 +224,31 @@ class TdiaryInstall
tempfile = Tempfile.new("tdiary.conf-ja") # 日本語環境サンプル
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/tdiary.conf.sample")
tempfile.close
- FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", *@fileutilOptions)
+ FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-ja", *@fileutilOptions)
tempfile = Tempfile.new("tdiary.conf-en") # sample configuration for English Environment
tempfile.write tdiaryConfReplace("#{@tdiarymaster}/misc/i18n/tdiary.conf.sample-en")
tempfile.close
- FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", *@fileutilOptions)
+ FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf-en", *@fileutilOptions)
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf") # tdiary.conf がなければ設置
- FileUtils.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", *@fileutilOptions)
+ FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/#{@tdconfig}", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary.conf", *@fileutilOptions)
end
# TODO: @langの値によって plugin/00lang.en.rb コピー/削除の制御もしたい
tempfile = Tempfile.new("dot.htaccess")
tempfile.write dothtaccessReplace("#{@tdiarymaster}/dot.htaccess")
tempfile.close
- FileUtils.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", *@fileutilOptions)
+ FileUtils16.cp(tempfile.path, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", *@fileutilOptions)
if ! FileTest.exist?("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess")
- FileUtils.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess", *@fileutilOptions)
+ FileUtils16.cp("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/dot.htaccess", "#{@passwd.dir}/#{@httpdir}/#{@diarydir}/.htaccess", *@fileutilOptions)
end
end
def setPermissions # ファイルコピー・生成以外の処理
- FileUtils.chmod(0777, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC)
- FileUtils.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC)
- FileUtils.rm("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary-FreeBSD.sh", :force, *@fileutilOptions)
+ FileUtils16.chmod(0777, "#{@passwd.dir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC)
+ FileUtils16.chmod(0777, "#{@passwd.dir}/#{@httpdir}/#{@diarydir}", *@fileutilOptions) if ! defined?($OPT_SUEXEC)
+ FileUtils16.rm("#{@passwd.dir}/#{@httpdir}/#{@diarydir}/tdiary-FreeBSD.sh", :force, *@fileutilOptions)
if @euid == 0 then # superuser 権限でこのインストーラを実行している場合
# すべてのディレクトリ・ファイルに chown で所有者変更
@@ -216,7 +273,7 @@ class TdiaryInstall
line = "@author_name = '#{@author_name}'\n" if line =~ /^\@author_name\s/
line = "@author_mail = '#{@author_mail}'\n" if line =~ /^\@author_mail\s/
line = "@html_title = '#{@author_name} diary'\n" if line =~ /^\@html_title\s/
- line = "@index_page = 'http://#{@author_host}/~#{@username}\/'" if line =~ /^\@index_page\s/ # F.Kimura
+ line = "@index_page = 'http://#{@author_host}/~#{@username}\/'" if line =~ /^\@index_page\s/ #FK
s += line
}
}