0xddfc2e10…3e91sent to0x165cd37b…5e14·#16,015,376·view on Etherscan
https://github.com/Floflis/online.git
---------------------------------------------------------------------------------------------------------------------------
/media/daniell/B/git/Floflis/Utilities/online/README.md ---->
---------------------------------------------------------------------------------------------------------------------------
# online
Utility to check if online or offline. Install and just type `online` in the Witchcraft/Terminal
----
# Usage
```sh
if online -s; then
echo "✅ Its online"
else
echo "❌ Its offline"
fi
```
# Installing
## Easy (option 1)
Open the Withcraft/Terminal/Prompt and type + press `[ENTER]`:
```sh
curl --proto '=https' --tlsv1.3 -sSf https://raw.githubusercontent.com/Floflis/online/main/install.sh | sh
```
## Locally (option 2)
If you don't trust downloading+executing a script, you can do it locally.
Open terminal and type following by pressing `[ENTER]`:
### Floflis, Floflis-based distros such as UniOS and any other that uses [nu shell](https://github.com/nushell/nushell):
```nu
git clone https://github.com/Floflis/online.git ; cd online
```
After reviewing the code of install.sh:
```nu
chmod +x install.sh ; sh ./install.sh
```
### Any other *nix distro (Ubuntu/Arch/MacOS/etc):
```sh
git clone https://github.com/Floflis/online.git && cd online
```
After reviewing the code of install.sh:
```sh
chmod +x install.sh && sh ./install.sh
```
----
# How to use
Open the Witchcraft/Prompt/Terminal and type:
`online`
For programatic use, head to [Usage](#usage).
---------------------------------------------------------------------------------------------------------------------------
<---- /media/daniell/B/git/Floflis/Utilities/online/README.md
---------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
/media/daniell/B/git/Floflis/Utilities/online/install.sh ---->
---------------------------------------------------------------------------------------------------------------------------
#!/bin/sh
echo "Installing online..."
sudo cp -f online /usr/bin/online
installfail(){
echo "Installation has failed."
exit 1
}
if [ -f /usr/bin/online ];then
echo "- Turning online into an executable..."
sudo chmod +x /usr/bin/online
if online babyisalive; then echo "Done! Running 'online' command as example to use it:" && (online &);exit 0; else installfail; fi
else
installfail
fi
---------------------------------------------------------------------------------------------------------------------------
<---- /media/daniell/B/git/Floflis/Utilities/online/install.sh
---------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
/media/daniell/B/git/Floflis/Utilities/online/online ---->
---------------------------------------------------------------------------------------------------------------------------
#!/bin/sh -e
offline=""
if nc -zw1 facebook.com 443 2>/dev/null; then
step_one="y"
else
if nc -zw1 twitter.com 443 2>/dev/null; then
step_two="y"
else
if nc -zw1 google.com 443 2>/dev/null; then
step_three="y"
else
if nc -zw1 plasmmer.com 443 2>/dev/null; then
step_four="y"
else
offline="y"
fi
fi
fi
fi
if [ "$1" != "" ]; then
if [ "$1" = "-s" ] || [ "$1" = "-q" ] || [ "$1" = "--silent" ] || [ "$1" = "--quiet" ]; then
if [ "$step_one" = "y" ]; then exit 0; fi
if [ "$step_two" = "y" ]; then exit 0; fi
if [ "$step_three" = "y" ]; then exit 0; fi
if [ "$step_four" = "y" ]; then exit 0; fi
if [ "$offline" = "y" ]; then exit 1; fi
fi
else
if [ "$step_one" = "y" ]; then echo "Facebook is online."; fi
if [ "$step_two" = "y" ]; then echo "Facebook is offline 🤷♀️";echo "But as expected, Twitter is online."; fi
if [ "$step_three" = "y" ]; then echo "Facebook and Twitter are offline.";echo "But Google still exist and I dunno why."; fi
if [ "$step_four" = "y" ]; then echo "Facebook, Twitter and Google are offline; did they moved into web3?";echo "But yes, you are online in the classical web 2.0"; fi
if [ "$offline" = "y" ]; then echo "You are offline.";exit 1; else echo "You are online.";exit 0; fi
fi
if [ "$1" = "babyisalive" ]; then
exit 0
fi
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "Use these commands after/together with 'online' command."
echo "Available flags:"
echo " --silent, -s Only output an exit code"
echo " --help, -h Shows all available commands"
# echo " --version, -v Shows info about OS name, version and build version"
fi
---------------------------------------------------------------------------------------------------------------------------
<---- /media/daniell/B/git/Floflis/Utilities/online/online
---------------------------------------------------------------------------------------------------------------------------