preload
Jun 12

首先, 先變成管理者模式

# sudo -s

在 /Library -> Preferences -> SystemConfiguration 建立 com.apple.RemoteAccessServers.plist 檔案

# vi /Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>ActiveServers</key>
        <array>
                <string>com.apple.ppp.l2tp</string>
        </array>
        <key>Servers</key>
        <dict>
                <key>com.apple.ppp.l2tp</key>
                <dict>
                        <key>DNS</key>
                        <dict>
                                <key>OfferedSearchDomains</key>
                                <array/>
                                <key>OfferedServerAddresses</key>
                                <array>
                                        <string>168.95.1.1</string>
                                        <string>168.95.192.1</string>
                                </array>
                        </dict>
                        <key>IPv4</key>
                        <dict>
                                <key>ConfigMethod</key>
                                <string>Manual</string>
                                <key>DestAddressRanges</key>
                                <array>
                                        <string>192.168.x.101</string>
                                        <string>192.168.x.120</string>
                                </array>
                        </dict>
                        <key>Interface</key>
                        <dict>
                                <key>SubType</key>
                                <string>L2TP</string>
                                <key>Type</key>
                                <string>PPP</string>
                        </dict>
                        <key>L2TP</key>
                        <dict>
                                <key>IPSecSharedSecret</key>
                                <string>com.apple.ppp.l2tp</string>
                                <key>IPSecSharedSecretEncryption</key>
                                <string>Keychain</string>
                                <key>Transport</key>
                                <string>IPSec</string>
                        </dict>
                        <key>PPP</key>
                        <dict>
                                <key>AuthenticatorProtocol</key>
                                <array>
                                        <string>MSCHAP2</string>
                                </array>
                                <key>LCPEchoEnabled</key>
                                <integer>1</integer>
                                <key>LCPEchoFailure</key>
                                <integer>5</integer>
                                <key>LCPEchoInterval</key>
                                <integer>60</integer>
                                <key>Logfile</key>
                                <string>/var/log/ppp/vpnd.log</string>
                                <key>VerboseLogging</key>
                                <integer>1</integer>
                        </dict>
                        <key>Server</key>
                        <dict>
                                <key>Logfile</key>
                                <string>/var/log/ppp/vpnd.log</string>
                                <key>MaximumSessions</key>
                                <integer>128</integer>
                                <key>VerboseLogging</key>
                                <integer>1</integer>
                        </dict>
                </dict>
        </dict>
</dict>
</plist>

記得把 OfferedServerAddresses裡面的值改成你要指定的dns server位址. 還有把 DestAddressRanges 內的值改成你要發放的 IP 位址

指定 root:wheel 到 com.apple.RemoteAccessServers.plist檔案

# chown root:wheel /Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist

建立好vpn的log檔案

# touch /var/log/ppp/vpnd.log

設定 secret 密碼到 system keychian

security add-generic-password -a com.apple.ppp.l2tp -s com.apple.net.racoon -p “TOP_SECRET” /Library/Keychains/System.keychain

打開 Utilities -> Keychain Access 程式 右上方 搜尋 racoon

點選”Access Control” Tab

打勾”Allow all applications to access this item”

設定撥號進來的帳號密碼 :

# vi /etc/ppp/chap-secrets

1
"YOUR_ACCOUNT" * "YOUR_PASSWORD" *

# vi /etc/ppp/users.plist

1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
        <dict>
                <key>Password</key>
                <string>YOUR_PASSWORD</string>
                <key>User</key>
                <string>YOUR_ACCOUNT</string>
        </dict>
</array>
</plist>

記得將 YOUR_ACCOUNT & YOUR_PASSWORD 改成你要設定的帳號密碼.

然後啟動vpn

# vpnd

這樣vpn就能運作了

如果你要讓vpn每次開機都啟動, 就要設定 /etc/hostconfig 檔案. 在檔案的最末端加入下列設定

VPNSERVERS=-YES-

Tagged with:
Apr 10

難得有軟體我一試用就直接買了. 它有個免費版本可以用 Clock Radio Free ✓. 這個版本其實已經算不錯用了. 只是想說要支持一下這麼好用的軟體我就花0.99美金買了 . 有人問說這兩個版本有什麼不同. 我認為唯一的差別是可以播放手機裡面的 Music Library. 其他都看起來相同. 它內建的網路音樂頻道滿豐富. 不多說.直接截圖 :


這是我愛聽的網路廣播頻道
SKY.FM Solo Piano


可以播放iPhone內的Music Library. 還有專輯封面喔


可以調整亮暗


最暗可以按到這種程度.不如按一下睡眠按鈕 :P


這軟體的缺點就是不能顯示中文.有點殘念阿.

Tagged with:
Jan 24

一切還沒完成. 還在努力中.

so far, the pTunes Widget is not finished yet. it’s still under construction.

相關閱讀 : pTunes (Preview)

Tagged with:
Jan 14

在蘋果裡面網路設定很好用. 蘋果可以按照你不同地點給予不同網路環境設定profile. 例如, 在家裡撥接ADSL然後撥VPN回公司, 在辦公室用固定ip. 在會議室設定無線網路…etc 不同環境都會有不同的 profile. 甚至, 我在辦公室還有不同 profile. 例如, 上班用固定ip. 然後, 有些特殊情況要用另外一組 ip. 這時候 Location profile 就很好用.

就在 System Preferences (系統偏好) -> Network (網路) -> Location 下拉就可以編輯不同的 profile. 當你編輯好不同情境的 profile 後, 你就可以在蘋果那 選 Location.

當然用滑鼠選比較快. 但是如果要遠端執行切換 profile. 那就要靠 scselect (Select system configuration “location”) 指令來完成

例如, 我要選 Home 那就用下列指令 :

HOST:~ username$ scselect Home
CurrentSet updated to A3F0DE9C-C708-43FE-9D1D-F9230BB31C61 (Home)

如果有不懂. 歡迎留言交流. 我相信我沒有寫很仔細. :$

Tagged with:
Dec 01

如何在終端機打開圖形界面的應用程式?

一般而言, 打開應用程式要透過 Finder 進到 Applications 慢慢找某特定的應用程式. 然後點兩下執行它. 雖然, 常用的應用程式大部份都會依個人偏好放在 Dock 上方便執行. 但是, 總是會有些程式放在 Dock 上. 所以透過 Finder 尋找應用程式然後執行. 某種程度而言算是有點瑣碎. 對有些重度使用 Terminal 的使用者會認為, 如果能用某指令就能打開圖形界面的應用程式那是最好不過的. 尤其透過遠端登入要打開某個程式.那更是方便. 因為遠端沒辦法直接對某應用程式直接執行.

至於, 該怎麼遠端或是透過終端機打開圖形界面應用程式? 簡單來說就使用 open 這個指令. 先大概看一下基本的說明如下 :

$ open
Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b ] [-a ] [filenames] [--args arguments]
Help: Open opens files from a shell.
      By default, opens each file using the default application for that file.
      If the file is in the form of a URL, the file will be opened as a URL.
Options:
      -a                Opens with the specified application.
      -b                Opens with the specified application bundle identifier.
      -e                Opens with TextEdit.
      -t                Opens with default text editor.
      -f                Reads input from standard input and opens with TextEdit.
      -R, --reveal      Selects in the Finder instead of opening.
      -W, --wait-apps   Blocks until the used applications are closed (even if they were already running).
          --args        All remaining arguments are passed in argv to the application's main() function instead of opened.
      -n, --new         Open a new instance of the application even if one is already running.
      -g, --background  Does not bring the application to the foreground.
      -h, --header      Searches header file locations for headers matching the given filenames, and opens them.

上面的內容就稍微自己看一下吧 : )

就示範幾個範例, 讓你參考.
開啓計算機

open -a Calculator

開啓 photoshop

open -a Adobe\ Photoshop\ CS4

用 Smultron 打開桌面上的 README.txt 檔案

open -a Smultron ~/Desktop/README.txt

打開某個網址

open http://liho.tw/

打開某張圖

open sexy.jpg

當然你可以把這些指令編輯道 .profile 裡面. 以方便日後開啓程式.

alias photoshop="open -a Adobe\ Photoshop\ CS4"

之後打 photoshop 就可以開啓photoshop.

遠端開啓的話, 也是一樣的方式. 只是記得在 System Preferences 開啓 Remote Login 的選項. 讓你自己能從遠端登入開啓圖形應用程式.

Tagged with:
Sep 18

必須先安裝 Xcode. 先直接印 SetFile 指令的說明檔

# /Developer/Tools/SetFile
Usage: SetFile [option...] file...
    -a attributes     # attributes (lowercase = 0, uppercase = 1)*
    -c creator        # file creator
    -d date           # creation date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
    -m date           # modification date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
        -P                                # perform action on symlink instead of following it
    -t type           # file type

    Note: The following attributes may be used with the -a option:
        A   Alias file
        B   Bundle
        C   Custom icon*
        D   Desktop*
        E   Hidden extension*
        I   Inited*
        M   Shared (can run multiple times)
        N   No INIT resources
        L   Locked
        S   System (name locked)
        T   Stationery
        V   Invisible*
        Z   Busy*

    Note: Items marked with an asterisk (*) are allowed with folders
    Note: Period (.) represents the current date and time.
    Note: [yy]yy < 100 assumes 21st century, e.g. 20yy

假設我不想在 Finder 看到硬碟的 /opt 目錄.
我就使用下列命令即可 :

# /Developer/Tools/SetFile -a V /opt
Tagged with:
Sep 12

早上在床上看完 Apple Special Event – September 2009.

看到 iTune LP 這裡就覺得想笑. 可能是陳唐山曾經說過撲中國的”LP”讓我餘音繞樑久久不能忘記.

裡面的 Home Sharing 我認為比較實用. 他可以連5台電腦. 直接對別台電腦的 iTunes 音樂及影集複製到本機的 iTunes. 以往我都是手動自己整理不同台電腦的 iTunes Library. 這個功能出來後, 我覺得很實用. 其他的感覺上對我來說都沒什麼用處. 台灣一直都沒有 Music, Movies TV Store 這點讓我滿遺憾的.想要花錢買正版的數位音樂與影片都不能買.

最後的 “One more thing…”

其實也沒什麼梗. 弄個 iPod nano 可以攝影. 很不夠意思. 要不然就把 iPod Touch 也弄個能攝影. 這樣才有點誠意. 當時我以為他要講蘋果平板電腦. 沒想到講這個雞毛蒜皮. Orz

大致上, 這個 Keynote 應該是看看 Steve Jobs 還能在台上講講話.這應該就算是對 Apple 人來說滿欣慰的. 希望他能健康. 也希望他能帶給蘋果更多新產品.

Tagged with:
Sep 03


這是第一次被蘋果推薦


第一次在蘋果Dashboard下載排行第一名

hohoho~~開心.自己先截圖下來. 按這裡查看前 50 名

Tagged with:
Aug 02


台灣


我愛台灣

如果你想改變你的開機畫面. 可以使用 BootXChanger 軟體改變. 可以按這裡下載 BootXChanger 1.0.2 版本.


BootXChanger

使用方式很簡單只要將圖片拉入.按 Apply 就可以了. 這裡也有中文化. 雖然我覺得不是那麼必要.


當然你也可以像我一樣把蘋果改成台灣. :P 按這裡下載.

Tagged with:
Jun 11

To delete a user from the command line in 10.5:

1. Boot into single user mode. Hold Command-s at startup.
開機進入單人模式. 在開啟電腦後馬上按 Command-s.

2. Check the filesystem:
檢查檔案系統
# /sbin/fsck -fy

3. If no remaining errors, mount the filesystem:
如果沒有任何錯誤, 就掛載檔案系統
# /sbin/mount -uw /

4. Start up directory services:
啟動目錄服務
# launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
Note that single user mode said to use com.apple.DirectoryServicesLocal.plist, but that didn’t work — this did.

5. Find what groups the user belongs to:
找出該使用者所屬群組
# dscl . -list /groups GroupMembership | grep username
– repeat for each group except for the user’s own group.

6. Remove the group corresponding to the username:
移除使用者對應的群組
# dscl . delete /groups/username
(this may not be necessary — you may get an error that the group doesn’t exist; you can ignore it and go on).

7. Remove the user account:
移除使用者帳戶
# dscl . delete /users/username

8. At this point, you may wish to remove or archive the user folder in /Users.
在此,你也許想移除在 /Users 內的使用者目錄.

9. You may wish to remove the .AppleSetupDone file in /var/db to cause the Setup Assistant to run when next booted.
你也許想移除在 /var/db 目錄內 .AppleSetupDone 檔案. 這樣下次開幾就會出現設定幫手(Setup Assistant).

10. All done? Type reboot to reboot the system or shutdown -h now to shut down the system.
都設定好了? 打 reboot 重新啟動電腦或是下 shutdown -h now 關機.

From : Delete users accounts from command line in 10.5

不見得用得到.但是先紀錄下來.

Tagged with: