Redirect google Chrome to localhost when offline

Asked

Viewed 74 times

-1

I have a system on top of a Raspberry that needs to work online. A Raspberry that opens directly a page on Chromium. What I’m trying to do is this scprit I did.

#!/bin/bash

wget -q --spider https://v4.permitt.com.br
if [[ $? -eq 0 ]]; then
if [ -e /home/condoseg/offline ]; then
sudo rm -rf /home/condoseg/offline
killall chromium-browser-v7
DISPLAY=:0 chromium-browser --args --incognito --disable-web-security --kiosk --allow-running-insecure-content --user-data-dir="/home/condoseg" --use-fake-ui-for-media-stream https://v4.permitt.com.br &
fi
else
if [ ! -e /home/condoseg/offline ]; then
killall chromium-browser
DISPLAY=:0 chromium-browser --args --incognito --disable-web-security --kiosk --allow-running-insecure-content --use-fake-ui-for-media-stream --user-data-dir="/home/condoseg" http://localhost/novoindex.html &
touch /home/condoseg/offline
fi
fi

It identifies when the computer has internet access, and when it is not, redirects to a page on the localhost. And vice versa. I’ve already managed to do so when it’s offline it redirects to the page I created inside the localhost, but when the computer has internet again, I’d like it to go back to the system home page.

1 answer

0

It seems to me that he lacked only a little logic in his script, as he takes the test only once. Place inside a loop with a true condition to continue endlessly checking.

Example to rotate every 3 minutes:

while :
do
   seu script
done
sleep 180

Browser other questions tagged

You are not signed in. Login or sign up in order to post.