次回インストール時に困らないためのメモ
SDカードの準備
- Download Raspbian for Raspberry Piから落としたイメージをbalenaEtcherで焼く。
/boot/ssh
を作る。
/boot/wpa_supplicant.conf
にWifi設定を書き込む。
/boot/wpa_supplicant.conf
country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="foo"
psk=bar
}
network={
ssid="baz"
psk=qux
priority=1
}
本編
ssh pi@raspberrypi.local
で繋がる。デフォルトのパスワードはraspberry
適当なタイミングでssh-keygen -t ed25519
してGitHubに登録しておく。
初期設定
passwd
sudo apt update && sudo apt upgrade
echo "NTP=ntp.nict.jp" | sudo tee -a /etc/systemd/timesyncd.conf
curl -s https://github.com/ebith.keys | tee -a ~/.ssh/authorized_keys
sudo tee -a /etc/ssh/sshd_config << EOM > /dev/null
PasswordAuthentication no
PermitRootLogin no
EOM
sudo tee -a /etc/dhcpcd.conf << EOM > /dev/null
interface wlan0
static ip_address=192.168.0.81/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
EOM
sudo raspi-config
raspi-config
- 2: N1 Hostname
- 4: I1 Change Locale
- 4: I2 Change Timezone
- 7: A3 Memory Split
いつもの環境をつくる
母艦からscpで常用ツールのARMv6バイナリを送りつけておく。peco, ghq, exaとか。
sudo apt install git zsh vim tmux gawk
sudo update-alternatives --config editor
chsh -s /bin/zsh
sudo ln -s /usr/share/doc/git/contrib/diff-highlight/diff-highlight /usr/local/bin/diff-highlight
sudo chmod 755 /usr/local/bin/diff-highlight
~/bin/ghq get ebith/dotfiles
cd ~/.ghq/github.com/ebith/dotfiles && ./create_link.py .config .vim .gitconfig .zshenv .zshrc .tmux.conf .yarnrc
mkdir -p ~/.vimlocal/{backup,swap,undo}
curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh
exec zsh -l
zplug install
exec zsh -l
cd && rm .bash_history .bash_logout .bashrc .profile
Mackerel
Latest release · mackerelio/mackerel-agent
sudo mkdir /etc/mackerel-agent/
wget https://github.com/mackerelio/mackerel-agent/releases/download/v0.59.1/mackerel-agent_linux_arm.tar.gz
tar xvf mackerel-agent_linux_arm.tar.gz
mv mackerel-agent_linux_arm/mackerel-agent ~/bin/mackerel-agent
sudo ~/bin/mackerel-agent init -apikey="xxxxxxxx"
wget https://raw.githubusercontent.com/mackerelio/mackerel-agent/master/packaging/deb-systemd/debian/mackerel-agent.service
sed -ie "s/ExecStart=\/usr\/bin\/mackerel-agent/ExecStart=\/home\/pi\/bin\/mackerel-agent/" mackerel-agent.service
sudo mv mackerel-agent.service /etc/systemd/system/network-online.target.wants/mackerel-agent.service
sudo systemctl daemon-reload
sudo systemctl start mackerel-agent
CPU温度の監視を追加する
sudo apt install bc
wget https://raw.githubusercontent.com/ymyzk/mackerel-plugins/master/raspberrypi/temp.sh
chmod 755 temp.sh
mv temp.sh ~/bin/temp.sh
sudo tee -a /etc/mackerel-agent/mackerel-agent.conf << EOM > /dev/null
[plugin.metrics.temp]
command = "/home/pi/bin/temp.sh"
EOM
sudo systemctl restart mackerel-agent
Node.js
1 or Zero
ダウンロード | Node.js
wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-armv6l.tar.xz
tar xvf node-v10.15.3-linux-armv6l.tar.xz
sudo cp -r node-v10.15.3-linux-armv6l/* /usr/local/
2以降
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install nodejs
yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install --no-install-recommends yarn
pigpio
sudo apt install pigpio
sudo systemctl enable pigpiod
sudo systemctl start pigpiod
pigsコマンドでsocket connect failedする
"socket connect failed" but only if starting pigpiod via systemctl · Issue #203 · joan2937/pigpio
sudo sed -ie 's/pigpiod -l$/pigpiod -l -n 127.0.0.1/g' /lib/systemd/system/pigpiod.service
sudo systemctl daemon-reload
sudo systemctl restart pigpiod