Raspberry Pi chkconfig & motionデータバックアップ(scp)

そんな設定です。

メモリ節約の一つとして、コンソール端末のみ有効とし、tty2からtty6 を無効化します。 [shell gutter="false"] [root@ms03 ~]# pico /etc/inittab

/sbin/getty invocations for the runlevels.

#

The "id" field MUST be the same as the last

characters of the device (after "tty").

#

Format:

:::

#

Note that on most Debian systems tty7 is used by the X Window System,

so if you want to add more getty's go ahead but skip tty7 if you run X.

#

コンソールは使用可能とするのでtty1は生かし、tty2~tty6をコメント行に変更

1:2345:respawn:/sbin/getty --noclear 38400 tty1

2:23:respawn:/sbin/getty 38400 tty2

3:23:respawn:/sbin/getty 38400 tty3

4:23:respawn:/sbin/getty 38400 tty4

5:23:respawn:/sbin/getty 38400 tty5

6:23:respawn:/sbin/getty 38400 tty6

[/shell]

chkconfigインストール & ディスプレイは使わないので以下設定 [shell] apt-get update apt-get install chkconfig chkconfig dbus off chkconfig triggerhappy off chkconfig alsa-utils off chkconfig lightdm off chkconfig motd off chkconfig plymouth off chkconfig ntp off [/shell]

参考 https://hirooka.pro/?p=4818

[shell] root@raspberrypi:~# chkconfig dbus off insserv: warning: script 'mathkernel' missing LSB tags and overrides insserv: warning: script 'zabbix-agent' missing LSB tags and overrides root@raspberrypi:~# chkconfig triggerhappy off insserv: warning: script 'mathkernel' missing LSB tags and overrides insserv: warning: script 'zabbix-agent' missing LSB tags and overrides root@raspberrypi:~# chkconfig alsa-utils off insserv: warning: script 'mathkernel' missing LSB tags and overrides insserv: warning: script 'zabbix-agent' missing LSB tags and overrides root@raspberrypi:~# chkconfig lightdm off insserv: warning: script 'mathkernel' missing LSB tags and overrides insserv: warning: script 'zabbix-agent' missing LSB tags and overrides root@raspberrypi:~# chkconfig motd off insserv: warning: script 'mathkernel' missing LSB tags and overrides insserv: warning: script 'zabbix-agent' missing LSB tags and overrides root@raspberrypi:~# chkconfig plymouth off insserv: warning: script 'mathkernel' missing LSB tags and overrides insserv: warning: script 'zabbix-agent' missing LSB tags and overrides root@raspberrypi:~# chkconfig ntp off insserv: warning: script 'mathkernel' missing LSB tags and overrides insserv: warning: script 'zabbix-agent' missing LSB tags and overrides [/shell]

設定するとワーニングがでる

mathkernel のワーニング対応. insserv: warning: script 'mathkernel' missing LSB tags and overrides

mathkernel の起動スクリプトを開き, [shell gutter="false"]
sudo vi /etc/init.d/mathkernel [/shell]

!/bin/sh

の下に以下を追記しておきます. [shell gutter="false"]

BEGIN INIT INFO

Provides: mathkernel

Required-Start: $local_fs

Required-Stop: $local_fs

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: mathkernel

END INIT INFO

[/shell]

zabbix-agentはこんな感じで [shell gutter="false"]

!/bin/sh

BEGIN INIT INFO

Provides: zabbix-agent

Required-Start: $remote_fs $netw

Required-Stop: $remote_fs

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Start zabbix-age

END INIT INFO

Zabbix agent start/stop script.

#

Copyright (C) 2001-2014 Zabbix SIA

[/shell]

motion移行バッチ sakuraで既に鍵認証で登録している状態 [shell]

!/bin/bash

set -eu cd /tmp/ && tar zcvf /root/motion.tar.gz.$(date -d '1 days ago' +%Y%m%d) motion scp /root/motion.tar.gz. sakura:~/ rm -f /root/motion.tar.gz. rm -f /tmp/motion/* service motion restart [/shell]

cronで回す為にPATHを確認 [shell]

!/bin/sh

printenv > /tmp/env [/shell] crontabで回した時と違ったのでcrontabにPATHを通す rootユーザで上のPATH確認シェルで出てきたものをそのままcrontabに書く

[shell gutter="false"] MAIL=/var/mail/root USER=root SHLVL=1 HOME=/root OLDPWD=/var/log LOGNAME=root _=/bin/sh TERM=screen-256color PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin LANG=en_GB.UTF-8 SHELL=/bin/bash PWD=/root [/shell]

[shell gutter="false"][/shell] 0 0 * * * sh /root/motion.sh [shell][/shell]

これでPATHが通るので問題なく起動するのを確認してcronを設定する。