Skip to content

Commit 01aa6fa

Browse files
committed
scheduled rebootが設定できていなかった問題の対応
SD-CardをoffにしてもSambaが動いている場合がある問題の対応
1 parent 6448229 commit 01aa6fa

File tree

16 files changed

+87
-31
lines changed

16 files changed

+87
-31
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ sshは物理的にSD-Cardへアクセスして公開鍵を書かないとlogin
4141

4242
## 使用法
4343

44-
https://github.com/mnakada/atomcam_tools/releases/tag/v1.0RC4
44+
https://github.com/mnakada/atomcam_tools/releases/tag/v1.0RC5
4545
からatomcam_tools.zipをダウンロードし、適当なツールで解凍します。
46-
<img src="https://github.com/bakueikozo/atomcam_tools/blob/main/images/extract.png">
46+
<img src="https://github.com/mnakada/atomcam_tools/blob/main/images/extract.png">
4747

4848
解凍されて出てきたすべてのファイルを、ATOMCam2で使用可能なmicroSDカードのルートフォルダに保存します
4949
保存したmicroSDカードをATOMCam2に入れて電源を入れます
@@ -158,10 +158,18 @@ WebHookを受け取るURLを指定します。今のところ実験的な実装
158158

159159
動体検知での録画が終了した時に通知URLに type: uploadVideoFinish をpostします。
160160

161+
##### - 動体検知録画転送
162+
163+
動体検知での録画が終了した時に通知URLに mime:video/mp4で録画ファイル をpostします。
164+
161165
##### - 動体検知静止画保存
162166

163167
動体検知での静止画保存完了時に通知URLに type: uploadPictureFinishをpostします。
164168

169+
##### - 動体検知静止画転送
170+
171+
動体検知での静止画保存完了時に通知URLに mime:image/jpegで静止画ファイルをpostします。
172+
165173
##### - 定常録画保存
166174

167175
1分間の定常録画が終了するたびに通知URLに type: recordEventをpostします。

atomcam_configs/busybox.config

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Automatically generated make config: don't edit
33
# Busybox version: 1.24.1
4-
# Sun Oct 17 13:49:01 2021
4+
# Sun Nov 14 14:53:07 2021
55
#
66
CONFIG_HAVE_DOT_CONFIG=y
77

@@ -869,9 +869,9 @@ CONFIG_TCPSVD=y
869869
CONFIG_TELNET=y
870870
CONFIG_FEATURE_TELNET_TTYPE=y
871871
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
872-
CONFIG_TELNETD=y
873-
CONFIG_FEATURE_TELNETD_STANDALONE=y
874-
CONFIG_FEATURE_TELNETD_INETD_WAIT=y
872+
# CONFIG_TELNETD is not set
873+
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
874+
# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
875875
CONFIG_TFTP=y
876876
CONFIG_TFTPD=y
877877

atomcam_configs/overlay_rootfs/etc/init.d/S05crond

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
start() {
77
printf "Starting crond: "
8-
start-stop-daemon -b -S -q -m -p /var/run/crond.pid --exec /usr/sbin/crond -- -l 4
8+
TZ=JST-9 start-stop-daemon -b -S -q -m -p /var/run/crond.pid --exec /usr/sbin/crond -- -l 4
99
echo "OK"
1010
}
1111

atomcam_configs/overlay_rootfs/etc/init.d/S58rtspserver

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# rtsp server
44
#
55
HACK_INI=/media/mmc/hack.ini
6+
touch $HACK_INI
67
RTSPSERVER=$(awk -F "=" '/RTSPSERVER *=/ {print $2}' $HACK_INI)
78

89
case "$1" in

atomcam_configs/overlay_rootfs/etc/init.d/S91smb

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
mkdir -p /var/log/samba
55

66
HACK_INI=/media/mmc/hack.ini
7+
touch $HACK_INI
78
STORAGE_SDCARD_PUBLISH=$(awk -F "=" '/STORAGE_SDCARD_PUBLISH *=/ {print $2}' $HACK_INI)
89

910
start() {

atomcam_configs/overlay_rootfs/etc/logrotate.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ compress
22

33
include /etc/logrotate.d
44

5-
/var/log/messages /var/log/autonight.log /var/log/videocapture.log /var/log/lighttpd-access.log {
5+
/var/log/messages /var/log/lighttpd-access.log /var/log/lighttpd-error.log {
66
rotate 7
77
daily
88
delaycompress

atomcam_configs/overlay_rootfs/scripts/atom_init.sh

+8
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ chmod 777 /tmp/log
3939
LD_PRELOAD=/tmp/system/modules/libcallback.so /system/bin/iCamera_app >> /tmp/log/atom.log 2>&1 &
4040

4141
/system/bin/dongle_app >> /tmp/log/dongle.log &
42+
43+
(
44+
while sleep 3600
45+
do
46+
TZ=JST-9 date >> /media/mmc/atomhack.log
47+
free >> /media/mmc/atomhack.log
48+
done
49+
) &

atomcam_configs/overlay_rootfs/scripts/webcmd.sh

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ do
1717
reboot
1818
cmd=""
1919
fi
20+
if [ "$cmd" = "scheduleReboot" ]; then
21+
cat << EOF | crontab -
22+
*/15 * * * * /usr/sbin/logrotate /etc/logrotate.conf
23+
${params} /scripts/reboot.sh
24+
EOF
25+
fi
2026
if [ "$cmd" = "setwebhook" ]; then
2127
kill -9 `pidof webhook.sh`
2228
/scripts/webhook.sh &

atomcam_configs/overlay_rootfs/scripts/webhook.sh

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
#!/bin/sh
22

33
HACK_INI=/media/mmc/hack.ini
4+
touch $HACK_INI
5+
touch /tmp/log/atom.log
46
tail -F /tmp/log/atom.log | TZ=JST-9 awk '
57
BEGIN {
68
FS = "=";
79
while(getline < HACK_INI) {
810
ENV[$1]=$2;
911
}
10-
if(ENV["WEBHOOK"] != "on") exit;
11-
if(ENV["WEBHOOK_URL"] == "") exit;
12+
}
13+
14+
/__NTP Set SysTime To/ {
15+
gsub(/^.*__NTP Set SysTime To /, "");
16+
gsub(/__.*$/, "000");
17+
print strftime("Reboot Time : %Y/%m/%d %H:%M:%S") >> "/media/mmc/atomhack.log";
18+
fflush("/media/mmc/atomhack.log");
19+
}
20+
21+
{
22+
if(ENV["WEBHOOK"] != "on") next;
23+
if(ENV["WEBHOOK_URL"] == "") next;
1224
}
1325
1426
/alarm_uploadNotify/ {
@@ -37,12 +49,6 @@ BEGIN {
3749
/time_lapse_stop_job/ {
3850
if(ENV["WEBHOOK_TIMELAPSE_FINISH"] == "on") Post("timelapseFinish");
3951
}
40-
/__NTP Set SysTime To/ {
41-
gsub(/^.*__NTP Set SysTime To /, "");
42-
gsub(/__.*$/, "000");
43-
print strftime("Reboot Time : %Y/%m/%d %H:%M:%S") >> "/media/mmc/atomhack.log";
44-
fflush("/media/mmc/atomhack.log");
45-
}
4652
4753
function Post(event, data) {
4854
if(data == "") {

atomcam_configs/overlay_rootfs/var/www/cgi-bin/hack_ini.cgi

-14
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ if [ "$REQUEST_METHOD" = "POST" ]; then
2020
}
2121
' > /media/mmc/hack.ini
2222

23-
REBOOT_SCHEDULE = `awk '/REBOOT_SCHEDULE *=/ { gsub(/^REBOOT_SCHEDULE *=/, ''); print; }' /media/mmc/hack.ini`
24-
awk '
25-
/\/scripts\/reboot\.sh/ {
26-
next;
27-
}
28-
{
29-
print;
30-
}
31-
END {
32-
if(REBOOT_SCHEDULE != "") print REBOOT_SCHEDULE " /scripts/reboot.sh";
33-
}
34-
' -v REBOOT_SCHEDULE="$REBOOT_SCHEDULE" /var/spool/cron/crontabs/root > /var/spool/cron/crontabs/root.new
35-
busybox mv /var/spool/cron/crontabs/root.new /var/spool/cron/crontabs/root
36-
3723
awk '
3824
BEGIN {
3925
FS=";";

atomcam_configs/scripts/rebuild_rootfs

+20-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,24 @@ cp -a staging/lib/* target/lib/
99
cp -a staging/usr/lib/* target/usr/lib/
1010
rm -f build/.root
1111
find . -name ".stamp_target_installed*" -print | xargs rm -f
12-
cd ..
12+
13+
# build libcallback.so
14+
PATH=$PATH:/openmiko/build/mips-gcc472-glibc216-64bit/bin
15+
cd /src/atomcam_configs/libcallback
16+
mips-linux-uclibc-gnu-gcc -fPIC -shared -o libcallback.so filesnooper.c setlinebuf.c -ldl
17+
mkdir -p /src/atomcam_configs/overlay_rootfs/lib/modules/
18+
cp libcallback.so /src/atomcam_configs/overlay_rootfs/lib/modules/
19+
20+
# build webpage
21+
PATH=$PATH:/root/.nvm/versions/node/v16.10.0/bin
22+
cd /src/atomcam_configs/web
23+
npm install -g npm
24+
npm install
25+
./node_modules/.bin/webpack --mode production --progress
26+
cp -pr frontend/* /src/atomcam_configs/overlay_rootfs/var/www
27+
28+
29+
cd /openmiko/build/buildroot-2016.02
1330
make
31+
cp /openmiko/build/buildroot-2016.02/output/images/rootfs.ext2 /src
32+
cp /openmiko/build/buildroot-2016.02/output/images/uImage.lzma /src

atomcam_configs/web/source/vue/Setting.vue

+4
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@
572572
str += `DelFlags=1;`;
573573
}
574574
this.config.RECORDING_LOCAL_SCHEDULE_LIST = str;
575+
if(this.config.SDCARD !== "on") this.config.STORAGE_SDCARD_PUBLISH = "off";
575576
576577
str = parseInt(this.reboot.time.slice(-2)) + ' ';
577578
str += parseInt(this.reboot.time.slice(0, 2)) + ' * * ';
@@ -600,6 +601,9 @@
600601
if(Object.keys(this.config).some(prop => (prop.search(/WEBHOOK/) === 0) && (this.config[prop] !== this.oldConfig[prop]))) {
601602
execCmds.push('setwebhook');
602603
}
604+
if(this.config.REBOOT_SCHEDULE !== this.oldConfig.REBOOT_SCHEDULE) {
605+
execCmds.push(`scheduleReboot ${this.config.REBOOT_SCHEDULE}`);
606+
}
603607
if(this.config.HOSTNAME !== this.oldConfig.HOSTNAME) {
604608
execCmds.push(`hostname ${this.config.HOSTNAME}`);
605609
if(window.location.host === `${this.oldConfig.HOSTNAME}.local`) {

atomcam_tools.zip

3.6 MB
Binary file not shown.

images/extract.png

192 KB
Loading

rebuild_rootfs.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
cp -pr atomcam_configs openmiko
6+
cd openmiko
7+
cp -pr atomcam_configs/overlay_initramfs/* initramfs_skeleton
8+
9+
if ! docker ps | grep openmiko_builder_1 ; then
10+
docker-compose up -d
11+
fi
12+
docker-compose exec builder /src/atomcam_configs/scripts/rebuild_rootfs
13+
14+
mv uImage.lzma ../factory_t31_ZMC6tiIDQN
15+
mv rootfs.ext2 ../rootfs_hack.ext2
16+
cd ..
17+
zip -ry atomcam_tools.zip factory_t31_ZMC6tiIDQN rootfs_hack.ext2 hostname authorized_keys

0 commit comments

Comments
 (0)