テーマをTwenty Twelveに変更

投稿日: Leave a comment

WordPress 3.5beta1のアナウンスの下の方にTwenty Twelveのリリースについて触れられていたので、インストールしてテーマを変更してみた。

インストール

ダッシュボードの外観→テーマを開き、「テーマのインストール」タブを開く。

twentytwelveで検索すると出てくるのでインストールを押す。

子テーマの作成

そのまま、このテーマを適用してもいいけど、いじるときに元のファイルを触りたくないので、子テーマを作って変更するところだけファイルを用意するようにする。

ウェブからはできないので、サーバにログイン

%cd www/snapshots/wp-content/themes/
%mkdir snapshots2012
%vi style.css
%vi functions.php

style.cssには親テーマを定義するコメント行を書く。

/*
Theme Name:     Snapshots 2012
Description:    Child theme for the Twenty Twelve theme
Author:         s.ueda
Author URI:     http://aperire.sakura.ne.jp/snapshots/
Template:       twentytwelve
Version:        1.0.0
*/

functions.phpには、どのスタイルシートを呼ぶのかを書く。

<?php
// load stylesheet
if ( !is_admin() ) {
    wp_enqueue_style(
        'twentytwelve-style',
        get_template_directory_uri() . '/style.css',
        array(),
        date('YmdHis', filemtime(get_template_directory() . '/style.css'))
        );
    wp_enqueue_style(
        'snapshots2012-style',
        get_stylesheet_uri(),
        array('twentytwelve-style'),
        date('YmdHis', filemtime(get_stylesheet_directory() . '/style.css'))
        );
}

少しカスタマイズ

そのままだと記事のタイトル付近に日付が出なくて少しさみしいのでcontent.phpをいじって日時を出すようにしてみた。

%diff -uN twentytwelve/content.php snapshots2012/content.php
--- twentytwelve/content.php    2012-10-16 21:11:10.000000000 +0900
+++ snapshots2012/content.php   2012-10-16 22:48:41.000000000 +0900
@@ -5,6 +5,8 @@
  * @package WordPress
  * @subpackage Twenty_Twelve
  * @since Twenty Twelve 1.0
+ *
+ * modified by s.ueda
  */
 ?>

@@ -18,10 +20,12 @@
                        <?php the_post_thumbnail(); ?>
                        <?php if ( is_single() ) : ?>
                        <h1 class="entry-title"<>?php the_title(); ?></h1>
+                       <p><?php the_time('Y/m/d H:i') ?></p>
                        <?php else : ?>
                        <h1 class="entry-title">
                                <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
                        </h1>
+                       <p><?php the_time('Y/m/d H:i') ?></p>
                        <?php endif; // is_single() ?>
                        <?php if ( comments_open() ) : ?>
                                <div class="comments-link">

 その他

ついでにTwitterのウィジェットを変更して、ヘッダーのメニュー構成も少し変えてみた。

FreeBSD 9.xのネットワーク設定

投稿日: Leave a comment

FreeBSD-9.0Rのネットワーク設定が8.xと違っていて少し手こずったので忘れないように書いておく。ちなみに、先日入れた9.1RC2でも同じ。

NICはIntel PRO/1000なので em0。DHCPは使わない。

IPv4

IPアドレスとデフォルトルータ

/etc/rc.conf:
ifconfig_em0="inet 192.168.100.3 netmask 255.255.255.0"
defaultrouter="192.168.100.1"

IPv6

RAを受け取る設定。
8.3Rでは ipv6_enable=”YES” と ipv6_network_interfaces=”em0″ と書いたら自動的に設定してくれていた。ifconfigコマンドのみで設定できるようになったのはシンプルでいい。

/etc/rc.conf:
ifconfig_em0_ipv6="inet6 accept_rtadv"

エイリアスをつける (長いアドレスはさすがに覚えられない)

/etc/rc.conf:
ifconfig_em0_alias0="inet6 2001:240:xxxx:xxxx::3 prefixlen 64"

テンポラリアドレスをつけて、通信時はこのテンポラリアドレスをなるべく使うように指定。

/etc/sysctl.conf:
net.inet6.ip6.use_tempaddr=1
net.inet6.ip6.prefer_tempaddr=1

DNS

DHCPを使わないのでresolv.confにDNSサーバのアドレスを書く。

/etc/resolv.conf:
nameserver 192.168.100.2
nameserver 192.168.100.1

 

これで、ifconfig em0の結果はこんな感じになる。

% ifconfig em0
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
        ether 00:19:d1:xx:xx:xx
        inet 192.168.100.3 netmask 0xffffff00 broadcast 192.168.100.255
        inet6 fe80::219:d1ff:fexx:xxxx%em0 prefixlen 64 scopeid 0x1
        inet6 2001:240:xxxx:xxxx::3 prefixlen 64
        inet6 2001:240:xxxx:xxxx:219:d1ff:fexx:xxxx prefixlen 64 autoconf
        inet6 2001:240:xxxx:xxxx:6cb1:4cd2:ec24:e946 prefixlen 64 autoconf temporary
        nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
        media: Ethernet autoselect (1000baseT )
        status: active

FreeBSD 9.1RC2 on ZFS

投稿日: Leave a comment

zfsなファイルシステムにFreeBSD 9.1RC2を入れたのでその記録。

手順は「Installing FreeBSD 9.0-RELEASE Root on ZFS using GPT」がベース。途中、ちょっと変えたので念のためすべてのメモを残しておく。

一応前提 (参考にしたページと違っているところ)。

  • HDD 1個、ada0として認識。これにzfsパーティション1つにしてインストール。
  • スワップ領域はパーティションではなくファイルで領域を確保する。

1. ブート

余っていた2GBのmicroSDカードをUSBのカードリーダに挿してPC接続。これに、”FreeBSD-9.1-RC2-amd64-memstick.img”を書き込んで、このSDカードから起動。

書き込みは、ChkFlshというフラッシュメモリをチェックしたりフォーマットしたりするツールを使用。他にもいろいろツールはあるはず。

2. インストーラ開始

9.0Rから採用されたbsdinstallでインストールを開始。途中のパーティションを設定するところで、”shell”を選択する。

3.パーティション作成

たぶん、一つ目の肝。今回はディスク1個なので、ミラーは組まない。最初のzpool createのところ、なぜか -f をつけないとエラーがでてだめだった(赤字のところ)。
# virtualbox上で同じことをしたら -f は無くても大丈夫だった。(2012/10/28)

# gpart create -s gpt ada0
# gpart add -s 64K -t freebsd-boot -l boot0 ada0
# gpart add -t freebsd-zfs -l disk0 ada0
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0

# zpool create -f -o altroot=/mnt zroot /dev/gpt/disk0
# zfs create zroot/tmp
# chmod 1777 /mnt/tmp
# zfs create zroot/usr
# zfs create zroot/var
# zfs create zroot/home
# exit

exitと打つとインストーラに戻る。

4.インストール実行

いつも通りのインストールをする。コピーするファイルやらネットワークの設定やら、アカウント作成やら。

インストールが終わると、Shellを立ち上げるよう促されるけど、そこはexitですぐ抜ける。

5. Live CDオプションでrootログイン

後半の肝。次回のブート時にちゃんとzfsが見えるように設定する。

# echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf
# echo 'zfs_load="YES"' >> /mnt/boot/loader.conf
# echo 'vfs.root.mountfrom="zfs:zroot"' >> /mnt/boot/loader.conf
# zfs unmount -a
# zpool export zroot
# zpool import -o cachefile=/tmp/zpool.cache -o altroot=/mnt zroot

# zfs set mountpoint=/ zroot
# cp /tmp/zpool.cache /mnt/boot/zfs/
# zfs unmount -a
# zpool set bootfs=zroot zroot
# zpool set cachefile='' zroot
# zfs set mountpoint=legacy zroot
# zfs set mountpoint=/tmp zroot/tmp
# zfs set mountpoint=/usr zroot/usr
# zfs set mountpoint=/var zroot/var
# zfs set mountpoint=/home zroot/home

最後のmountpointを設定するところはエラーが出るけど無視する。

6. 再起動してswapファイルを作る

無事再起動したらrootでログインしてswapファイルを作る。

# dd if=/dev/zero of=/swapfile bs=1m count=4096
# chmod 600 /swapfile
# echo 'swapfile="/swapfile"' >> /etc/rc.conf
# /etc/rc.d/addswap start

これで4GBのスワップ領域が有効になる。topコマンドあたりで確認可能。