RasPBXをインストールしてみた

# RasPBXをインストールしてみた

## RasPBX？
RasPBX = Raspbian(Jessie) + Asterisk + FreePBX
 
## アーカイブをダウンロード
[Downloads | Asterisk for Raspberry Pi](http://www.raspberry-asterisk.org/downloads/)から最新のアーカイブをダウンロード
[raspbx-17-10-2015.zip](http://www.raspberry-asterisk.org/download/raspbx-17-10-2015.zip)

## RasPBXのイメージをSDカードに書き込み


```shell-session
MacOSX$ diskutil list
/dev/disk5
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.0 GB     disk5
   1:                 DOS_FAT_32                         8.0 GB     disk5s1
```

```shell-session
MacOSX$ sudo diskutil unmountDisk /dev/disk5
Password:
Unmount of all volumes on disk5 was successful
```

```shell-session
MacOSX$ sudo dd bs=1m if=~/Downloads/raspbx-17-10-2015/raspbx-17-10-2015.img of=/dev/disk5
3724+0 records in
3724+0 records out
3904897024 bytes transferred in 4645.506549 secs (840575 bytes/sec)
```

## RasPBXを起動する
sshでRasPBXのコンソールに接続する

```shell-session
MacOSX$ ssh root@raspbx.local
Warning: the RSA host key for 'raspbx.local' differs from the key for the IP address '192.168.*.*'
Offending key for IP in /Users/user/.ssh/known_hosts:10
Matching host key in /Users/user/.ssh/known_hosts:12
Are you sure you want to continue connecting (yes/no)? yes
root@raspbx.local's password: 

Welcome to RasPBX - Asterisk for Raspberry Pi

RasPBX is based on Debian. The programs included with the Debian GNU/Linux
system are free software; the exact distribution terms for each program are
described in the individual files in /usr/share/doc/*/copyright.

RasPBX comes with ABSOLUTELY NO WARRANTY, to the extent permitted by 
applicable law.

List of RasPBX specific commands:
----------------------------------------------------------------------------- 
raspbx-upgrade      Keep your system up to date with the latest add-ons and
                    security fixes
configure-timezone  Set timezone for both system and PHP
install-fax         Install HylaFAX                          
add-fax-extension   Add additional fax extension for use with HylaFAX
install-fail2ban    Install Fail2Ban for additional security
install-dongle      Install GSM/3G calling capability with chan_dongle
raspbx-backup       Backup your complete system to an image file

root@raspbx:~# 
```

rootアカウントのパスワードは「raspberry」

## 最初に起動した時にやっておくこと
### パーティションの拡張
ちなみにJessieベースのRasPBXはraspi-configコマンドを使ったパーティションの拡張は正しく動作しないようです

#### 起動直後はこんな感じ

```shell-session
root@raspbx:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root        3644624 1638828   1802696  48% /
devtmpfs          242608       0    242608   0% /dev
tmpfs             246880       0    246880   0% /dev/shm
tmpfs             246880    8768    238112   4% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             246880       0    246880   0% /sys/fs/cgroup
/dev/mmcblk0p1     76186   37980     38206  50% /boot
```

#### こんな流れでパーティションの拡張をしていく
パーティションを一旦削除して、最大容量でパーティションを作りなおす感じでしょうか

```shell-session
root@raspbx:~# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 7.4 GiB, 7985954816 bytes, 15597568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000ee283

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1        2048  155647  153600   75M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      157696 7626751 7469056  3.6G 83 Linux


Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (155648-15597567, default 155648): 157696
Last sector, +sectors or +size{K,M,G,T,P} (157696-15597567, default 15597567): 

Created a new partition 2 of type 'Linux' and of size 7.4 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 7.4 GiB, 7985954816 bytes, 15597568 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000ee283

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        2048   155647   153600   75M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      157696 15597567 15439872  7.4G 83 Linux


Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
```

```shell-session
root@raspbx:~# reboot
```

```shell-session
root@raspbx:~# resize2fs /dev/mmcblk0p2
```

#### パーティションの拡張後はこんな感じ

```shell-session
root@raspbx:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root        7570984 1640348   5570788  23% /
devtmpfs          242608       0    242608   0% /dev
tmpfs             246880       0    246880   0% /dev/shm
tmpfs             246880    8736    238144   4% /run
tmpfs               5120       4      5116   1% /run/lock
tmpfs             246880       0    246880   0% /sys/fs/cgroup
/dev/mmcblk0p1     76186   37980     38206  50% /boot
```

### パスワードを変更しておく

```shell-session
root@raspbx:~# passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
```

### いろいろとアップデートしておく

```shell-session
root@raspbx:~# apt-get update
Reading package lists... Done

root@raspbx:~# apt-get upgrade
Do you want to continue? [Y/n] y

root@raspbx:~# rpi-update

root@raspbx:~# raspbx-upgrade
```

### タイムゾーンを変更

```shell-session
root@raspbx:~# configure-timezone 

Current default time zone: 'Asia/Tokyo'
Local time is now:      Sat Jan  2 16:45:30 JST 2016.
Universal Time is now:  Sat Jan  2 07:45:30 UTC 2016.

Setting PHP to system timezone: Asia/Tokyo
```

### ロケールの設定

```shell-session
root@raspbx:~# dpkg-reconfigure locales
Generating locales (this might take a while)...
  en_GB.ISO-8859-1... done
  en_GB.ISO-8859-15... done
  en_GB.UTF-8... done
  ja_JP.UTF-8... done
Generation complete.
```

## ブラウザでアクセス
ポータル[http://raspbx.local/](http://raspbx.local/)にブラウザでアクセス

ユーザー名：admin
パスワード：admin