DietPi + jessie

* minibianが更新停滞しているのと、Ubuntu Snappy CoreがRPi1に対応していない。
* DietPiはminibianより小さく、そしてdietpi-コマンドが利用しやすい。
* /var/log がtmpfsのため体感早い

## download

* [Find out more about DietPi | SourceForge.net](http://sourceforge.net/projects/dietpi/files/Raspberry%20Pi%20%28All%20Models%29/DietPi_RPi.7z/download)
  * [Fuzon • View topic - Download DietPi image | Getting started](http://fuzon.co.uk/phpbb/viewtopic.php?f=8&t=9)
  * [Fourdee/DietPi · GitHub](https://github.com/Fourdee/DietPi)
  * [changelog](https://raw.githubusercontent.com/Fourdee/DietPi/master/CHANGELOG.txt)
  * user:pass = root:dietpi

### SDカードに書き込み起動

* 初回OS起動に2分かかる。
* ssh接続しEnter押すと最新バージョンに更新される。

![スクリーンショット_2015-08-15_11-28-42.png](https://qiita-image-store.s3.amazonaws.com/0/25728/05495d4f-3f25-0965-8394-509c7d800e88.png)

* USBメモリやUSBHDDを接続している場合は「YES」を選択。(後から変更できません。)

![スクリーンショット_2015-08-15_11-31-28.png](https://qiita-image-store.s3.amazonaws.com/0/25728/aa24de89-ef56-6f7f-c5f5-1ef9607fcb2a.png)

* 「y」でformat実施。

![スクリーンショット_2015-08-15_11-32-19.png](https://qiita-image-store.s3.amazonaws.com/0/25728/85365f8c-bd1c-cbb6-96b5-f448675cd14a.png)

### dietpi-software

* 「3 SSH Server」＞「OpenSSH」を選択。(Dropbearだとscpができない)
    * 「Go Start Install」
    * OSが再起動されます。

### dietpi-config

* Ethernet設定

![スクリーンショット_2015-08-15_11-39-13.png](https://qiita-image-store.s3.amazonaws.com/0/25728/9bffc2e0-7e1f-6ec5-6b46-33eb0144c72c.png)

# wheesyからjessieに更新

* [DietPi Debian Jessie release. · Issue #39 · Fourdee/DietPi · GitHub](https://github.com/Fourdee/DietPi/issues/39) 自己責任でJessieに上げるのもできる。

```diff:/etc/apt/sources.list
- deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
+ deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
```

```diff:/etc/apt/sources.list.d/collabora.list
- deb http://raspberrypi.collabora.com wheezy rpi
```

```diff:/etc/apt/sources.list.d/raspi.list
- deb http://archive.raspberrypi.org/debian/ wheezy main
+ deb http://archive.raspberrypi.org/debian/ jessie main
```

```bash:
yes N | apt-get dist-upgrade -y
reboot
```

# 諸設定

## sshd

```diff:/etc/ssh/sshd_config
- PasswordAuthentication yes
+ PasswordAuthentication no
```

```bash:
/etc/init.d/ssh restart
```

## インストール

```bash:
apt-get install -y \
  screen vim nkf w3m git tig ranger tightvncserver fonts-takao \
  telnet postfix mutt mailutils \
  man-db manpages-ja manpages-ja-dev sudo ack-grep logwatch \
  openjdk-7-jre python-pip python-dev \
  ruby ruby-dev gem bundler rails \
  nodejs \
  autossh keychain \
  fswebcam sharutils
```

```bash:
pip install ansible
pip install markupsafe
```

## postfix

* [main.cf (DietPi用)](http://qiita.com/tukiyo3/items/45f6af17e6f7306940c2#maincf-dietpi%E7%94%A8) 参照

## 環境設定

```bash:
dpkg-reconfigure tzdata
```

## LANG

```diff:/etc/locale.gen
- # ja_JP.UTF-8 UTF-8
+ ja_JP.UTF-8 UTF-8
```

```bash:
locale-gen
```

```bash:~/.bashrc
LANG="ja_JP.UTF-8"
```

### 空き容量の確保

```bash:
apt-get clean
```

## owncloud

* [isv:ownCloud:community / owncloud](https://software.opensuse.org/download/package?project=isv:ownCloud:community&package=owncloud)

```bash:jessie用
wget http://download.opensuse.org/repositories/isv:ownCloud:community/Debian_8.0/Release.key
apt-key add - < Release.key
#
echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/Debian_8.0/ /' >> /etc/apt/sources.list.d/owncloud.list 
#
apt-get update
apt-get install -y owncloud
```


* http://server-ip/owncloud にアクセスすると表示されるが、変更したい。

```diff:/etc/apache2/conf.d/owncloud.conf
- Alias /owncloud /usr/share/owncloud
+ Alias /owncloud4.0.4 /usr/share/owncloud
```

```bash:
sudo /etc/init.d/apache2 restart
mkdir /mnt/usb_1/owncloud
```

* http://server-ip/owncloud にアクセスして表示できないことを確認。
* [513MB制限変更](http://qiita.com/tukiyo3/items/9895bf2c4be3f94e7d35#513mb%E5%88%B6%E9%99%90)

### mysql

* [DietPi/dietpi-software at master · Fourdee/DietPi · GitHub](https://github.com/Fourdee/DietPi/blob/master/dietpi/dietpi-software)
* root : raspberry (もしくはdietpi)
* `create database owncloud;`

## logwatch

* [logwatchに感動した - Qiita](http://qiita.com/tukiyo3/items/b06dafd5cb54ad4f3d3e)

```bash:
mkdir -p /var/cache/logwatch
/etc/cron.daily/00logwatch
```

## puppetmaster

* [linux - Puppet on a Debian Wheezy machine Unmet Dependencies: Facter - Stack Overflow](http://stackoverflow.com/questions/25125039/puppet-on-a-debian-wheezy-machine-unmet-dependencies-facter)

```bash:
wget http://apt.puppetlabs.com/puppetlabs-release-jessie.deb
dpkg -i puppetlabs-release-jessie.deb
apt-get update
```

```bash:
apt-get install puppetmaster-passenger
```

* [Configuring a Puppet Master Server with Passenger and Apache — Documentation — Puppet Labs](https://docs.puppetlabs.com/guides/passenger.html)