| Login |
S M T W T F S
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
GrooveCafe
by ipod-groove
カテゴリ
検索
リンク
最近のコメント
今更ですが、更にも..
by msb at 10:36
wwwwww
by ipod-groove at 10:01
うお!更新された!..
by nakamuland at 10:00
あわわ。お2人とも..
by ipod-groove at 05:54
更にもう一人 (^-^)/
by iklaxon at 01:04
いるよ
by tomo at 21:46
>鍵さん あ、そ..
by ipod-groove at 01:50
おっ!やはり買われ..
by Norick at 09:51
お久しぶりです。私..
by Being! at 10:36
TETSUさん。 返事..
by ipod-groove at 06:33
場違いに書き込みし..
by TETSU at 01:15
どーも。Norickさん..
by ipod-groove at 12:50
最近のトラックバック
Apple TVのサイズは
from 欲望の塊 returns
AppleTVで快適リビ..
from 林囓(リンカジ)Switch time to Mac !
Mac mini の後継はA..
from Mac Enhancer 2
Apple TV到着
from 林囓(リンカジ)Switch time to Mac !
Mac OS X 10.4.9 Up..
from Make my day
iTunes 7.1 & Quick..
from Make my day
iTunesとQuickTime..
from せうの日記
漢たるもの・・・・..
from 開業したて整形外科院長の野望(無謀)日記。
以前の記事

GrooveType










Apacheのコントローラをつくる。その9
続きです。。

せっかくなので、hostconfigを書き換えて、自動起動する設定も施してみました。

とりあえず、InterfaceBuilderでボタンを配置して、表示を Start Apache2 At Bootなどとします。

img

さて、これにスクリプトを割り当てていくのですが。。。
まず最初に、Inspectorウインドウで、Applescriptでコントロールする名前を、switch
としました。
img

んで、このボタン用のApplescriptを新しく作ります。
新しいスクリプトはswitch.applescriptにしました。
imgimg

そして、switch.actionscriptは、こんな感じで、hostconfigを書き換えるスクリプトを書きました。
CODE:
on clicked theObject
if state of theObject is 1 then
try
--do shell script "grep APACHE2= /Users/u_ichi/Desktop/hostconfig" with administrator privileges
do shell script "grep APACHE2= /etc/hostconfig" with administrator privileges
do shell script "cp /etc/hostconfig /etc/hostconfig.bak" with administrator privileges
do shell script "sed -e s/APACHE2=-NO-/APACHE2=-YES-/ /etc/hostconfig.bak > /etc/hostconfig" with administrator privileges
--display dialog "ON"
on error
do shell script "cp /etc/hostconfig /etc/hostconfig.bak" with administrator privileges
do shell script "echo APACHE2=-YES- | tee -a /etc/hostconfig" with administrator privileges
end try

else
try
do shell script "grep APACHE2= /etc/hostconfig" with administrator privileges
do shell script "cp /etc/hostconfig /etc/hostconfig.bak" with administrator privileges
do shell script "sed -e s/APACHE2=-YES-/APACHE2=-NO-/ /etc/hostconfig.bak > /etc/hostconfig" with administrator privileges
--display dialog "OFF"
on error
do shell script "cp /etc/hostconfig /etc/hostconfig.bak" with administrator privileges
do shell script "echo APACHE2=-NO- | tee -a /etchostconfig" with administrator privileges
end try

end if
end clicked

img

そして、アプリケーションが起動したときに、switchの状態を設定しなければならないので、起動時に実行されるwindow.applescriptのほうにも以下を付け加えます。
CODE:
try
do shell script "grep APACHE2=-YES- /etc/hostconfig"
set state of button "switch" of window "mainwindow" to "1"
on error

end try

img

テストしてみます。
img
うまくいったようです。

一応、作ったヤツをココにおいておきます。

※ こちらのApache2.3+PHP5 とあわせて使えます。

※/usr/local/apache2 にインストールしたApacheなら、他のバージョンのApacheでも使えます。


by ipod-groove | permalink | 2006-11-24 04:40 | Xcode | Comments(0)
Project name :GrooveType by GrooveCafe™
new server