Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pfzim committed Sep 14, 2024
1 parent a41cb5d commit bca8fc7
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions bot/bot.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"system_name" : "XBMC",
"network_interface" : "wlan0",
"admins_chats" : [
"000000000",
"123456789"
Expand Down
2 changes: 1 addition & 1 deletion bot/bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function http_save($url, $path)
}
elseif(!empty($update['message']['text']) && $update['message']['text'] == '/ping')
{
$output = system('ip -json -6 addr show end0 scope global | jq -r \'.[0].addr_info[0].local\'');
$output = system('ip -json -6 addr show '.$config['network_interface'].' scope global | jq -r \'.[0].addr_info[0].local\'');
$temp = round(intval(system('cat /sys/class/thermal/thermal_zone0/temp'))/1000, 1);

$response = array(
Expand Down
2 changes: 1 addition & 1 deletion etc/cron.d/xbmc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
@reboot xbmc php -f /home/xbmc/bot/bot.php -- --boot
*/1 * * * * xbmc php -f /home/xbmc/bot/bot.php
0 */6 * * * xbmc /usr/sbin/rotate-byspace.sh -p /mnt/data/motion/bydays -s 30; /usr/sbin/move_by_dates.sh -s /mnt/data/motion -d /mnt/data/motion/bydays
*/15 * * * * xbmc /opt/motion/check_hdd.sh
*/15 * * * * xbmc /opt/motion/checks.sh
20 changes: 19 additions & 1 deletion etc/sudoers.d/xbmc
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
ALL ALL=NOPASSWD: /usr/bin/systemctl poweroff,/usr/bin/systemctl halt,/usr/bin/systemctl reboot,/usr/bin/poweroff,/usr/bin/systemctl shutdown,/usr/bin/shutdown,/usr/bin/reboot,/usr/bin/systemctl start motion,/usr/bin/systemctl stop motion,/usr/bin/systemctl show motion -p ActiveState,/opt/motion/on_cam_enable.sh *,/opt/motion/on_cam_disable.sh *,/opt/motion/on_snapshot.sh,/opt/motion/on_cam_record_disable.sh *,/opt/motion/on_cam_record_enable.sh *,/opt/motion/on_send_sms.sh *,/opt/motion/on_flag_set.sh *,/opt/motion/on_flag_clear.sh *,/usr/bin/fsck *
ALL ALL=NOPASSWD: /usr/bin/systemctl shutdown
ALL ALL=NOPASSWD: /usr/bin/systemctl poweroff
ALL ALL=NOPASSWD: /usr/bin/systemctl reboot
ALL ALL=NOPASSWD: /usr/bin/systemctl halt
ALL ALL=NOPASSWD: /usr/bin/shutdown
ALL ALL=NOPASSWD: /usr/bin/poweroff
ALL ALL=NOPASSWD: /usr/bin/reboot
ALL ALL=NOPASSWD: /usr/bin/systemctl start motion
ALL ALL=NOPASSWD: /usr/bin/systemctl stop motion
ALL ALL=NOPASSWD: /usr/bin/systemctl show motion -p ActiveState
ALL ALL=NOPASSWD: /opt/motion/on_cam_enable.sh *
ALL ALL=NOPASSWD: /opt/motion/on_cam_disable.sh *
ALL ALL=NOPASSWD: /opt/motion/on_snapshot.sh
ALL ALL=NOPASSWD: /opt/motion/on_cam_record_disable.sh *
ALL ALL=NOPASSWD: /opt/motion/on_cam_record_enable.sh *
ALL ALL=NOPASSWD: /opt/motion/on_send_sms.sh *
ALL ALL=NOPASSWD: /opt/motion/on_flag_set.sh *
ALL ALL=NOPASSWD: /opt/motion/on_flag_clear.sh *
ALL ALL=NOPASSWD: /usr/bin/fsck *
15 changes: 15 additions & 0 deletions motion/check_hdd.sh → motion/checks.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ if [ ! -e /opt/motion/flags/flag_check_zigbee.disabled ] ; then
fi
fi

if [ ! -e /opt/motion/flags/flag_check_internet.disabled ] ; then
cnt=`cat /tmp/no_internet.count` || cnt=0

if ! ping -c 1 8.8.8.8 >/dev/null 2>&1 ; then
if ! ping -c 1 77.88.8.8 >/dev/null 2>&1 ; then
cnt=$((cnt + 1))
if [ $cnt -gt 3 ] ; then
reboot
else
echo $cnt > /tmp/no_internet.count
fi
fi
fi
fi

if [ ! -e /opt/motion/flags/flag_check_hdd.disabled ] ; then
filecontent=`cat /mnt/data/mounted`

Expand Down
8 changes: 8 additions & 0 deletions motion/on_ups_event.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# ./on_ups_event.sh message_text

/opt/motion/send_event.sh -f -i ups_event "${1}"

/opt/motion/send_snapshot_rtsp.sh "rtsp://10.1.1.1/?user=admin&password=password&channel=1&stream=0"
/opt/motion/send_snapshot_rtsp.sh "rtsp://10.1.1.2/?user=admin&password=password&channel=1&stream=0"

0 comments on commit bca8fc7

Please sign in to comment.