add myip
authorAJ ONeal <aj@therootcompany.com>
Fri, 3 Jul 2020 08:31:49 +0000 (08:31 +0000)
committerAJ ONeal <aj@therootcompany.com>
Fri, 3 Jul 2020 08:31:49 +0000 (08:31 +0000)
myip/README.md [new file with mode: 0644]
myip/install.ps1 [new file with mode: 0644]
myip/install.sh [new file with mode: 0644]
myip/myip.ps1 [new file with mode: 0644]
myip/myip.sh [new file with mode: 0644]
vps-myip/README.md
vps-utils/install.sh

diff --git a/myip/README.md b/myip/README.md
new file mode 100644 (file)
index 0000000..c8652e1
--- /dev/null
@@ -0,0 +1,60 @@
+---
+title: My IP
+homepage: https://webinstall.dev/myip
+tagline: |
+  My IP answers the question "what's my IP address?"
+description: |
+  `myip` will contact ipify.org to tell you your IP addresses:
+
+    1. `api.ipify.org` for your IPv4 or A address
+    2. `api6.ipify.org` for your IPv6 or AAAA address
+---
+
+Example output:
+
+```txt
+IPv4 (A)   : 136.36.196.101
+IPv6 (AAAA): 2605:a601:a919:9800:f8be:f2c4:9ad7:9763
+```
+
+### What is an IP address?
+
+An IP or Internet Protocol address is basically the phone number of your
+computer or server.
+
+Whenever you visit a domain - such as https://google.com - the `google.com` part
+is _resolved_ to the IP address using, quite literally, the internet's Contacts
+list, known as DNS.
+
+### How to get your IP address?
+
+Due to how complex networking can be, the most reliable way to get your IP
+address is basically to "make a call" to another server and ask it to tell you
+what shows up on the "called id", as it were.
+
+_IPify_ is such a service.
+
+You likely have an IPv4 or A address as well as an IPv6 or AAAA address.
+
+To find out your IPv4 or A address:
+
+```bash
+curl -s https://api.ipify.org
+```
+
+To find out your IPv6 or AAAA address:
+
+```bash
+curl -s https://api6.ipify.org
+```
+
+To find out either address:
+
+```bash
+curl -s https://api46.ipify.org
+```
+
+You can also use the `ifconfig`, `ip`, or `ipconfig` commands to figure this
+out, but they may give you incorrect information if the network setup is complex
+(as is the case... most of the time - home and business networks, cloud
+networks, etc).
diff --git a/myip/install.ps1 b/myip/install.ps1
new file mode 100644 (file)
index 0000000..a6a8e18
--- /dev/null
@@ -0,0 +1,7 @@
+#!/usr/bin/env pwsh
+
+& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_HOST/packages/myip/myip.ps1" -o "$Env:USERPROFILE\.local\bin\myip.ps1.part"
+Remove-Item -Path "$Env:USERPROFILE\.local\bin\myip.ps1" -Recurse -ErrorAction Ignore
+& move "$Env:USERPROFILE\.local\bin\myip.ps1.part" "$Env:USERPROFILE\.local\bin\myip.ps1"
+Set-Content -Path "$Env:USERPROFILE\.local\bin\myip.bat" -Value "@echo off`r`npushd %USERPROFILE%`r`npowershell -ExecutionPolicy Bypass .local\bin\myip.ps1 %1`r`npopd"
+& "$Env:USERPROFILE\.local\bin\myip.bat"
diff --git a/myip/install.sh b/myip/install.sh
new file mode 100644 (file)
index 0000000..2965145
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    rm -f "$HOME/.local/bin/myip"
+    webi_download  "$WEBI_HOST/packages/myip/myip.sh" "$HOME/.local/bin/myip"
+    chmod a+x "$HOME/.local/bin/myip"
+
+    "$HOME/.local/bin/myip"
+}
diff --git a/myip/myip.ps1 b/myip/myip.ps1
new file mode 100644 (file)
index 0000000..0d3c744
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env pwsh
+
+$ipv4 = curl.exe -sf https://api.ipify.org
+
+IF(!($ipv4 -eq $null -or $ipv4 -eq ""))
+{
+    echo "IPv4 (A)   : $ipv4"
+}
+
+$ipv6 = curl.exe -sf https://api6.ipify.org
+
+IF(!($ipv6 -eq $null -or $ipv6 -eq ""))
+{
+    echo "IPv6 (AAAA): $ipv6"
+}
diff --git a/myip/myip.sh b/myip/myip.sh
new file mode 100644 (file)
index 0000000..aa6980c
--- /dev/null
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    ipv4=$(curl -s https://api.ipify.org)
+    ipv6=$(curl -s https://api6.ipify.org)
+
+    if [ -n "$ipv4" ]; then
+        echo "IPv4 (A)   : $ipv4"
+    fi
+
+    if [ -n "$ipv6" ] && [ "ipv6" != "ipv4" ]; then
+        echo "IPv6 (AAAA): $ipv6"
+    fi
+}
index 2c8fac87c5798709a807ddcefeca368902bece94..f707e4c711e9da6d1bb6c429585605b9282db963 100644 (file)
@@ -3,10 +3,7 @@ title: VPS My IP
 homepage: https://webinstall.dev/vps-myip
 tagline: |
   VPS My IP answers the question "what's my IP address?"
-linux: true
 description: |
-  Creates permanent swap space that will be activated on each boot.
-
   `vps-myip` will contact ipify.org to tell you your IP addresses:
 
     1. `api.ipify.org` for your IPv4 or A address
index b8c6658a93df1522e8b7fb627dda27d2c87a4bd7..029807bd6ac4a92365d7e5cacdd3c1b81725aaa6 100644 (file)
@@ -1,9 +1,11 @@
 {
     rm -f "$HOME/.local/bin/vps-myip" "$HOME/.local/bin/vps-addswap" "$HOME/.local/bin/cap-net-bind"
-    #webi_download  "$WEBI_HOST/packages/vps-utils/" "$HOME/.local/bin/"
-    webi_download  "$WEBI_HOST/packages/vps-utils/cap-net-bind.sh" "$HOME/.local/bin/cap-net-bind"
-    webi_download  "$WEBI_HOST/packages/vps-utils/vps-myip.sh" "$HOME/.local/bin/vps-myip"
-    webi_download  "$WEBI_HOST/packages/vps-utils/vps-addswap.sh" "$HOME/.local/bin/vps-addswap"
-    chmod a+x "$HOME/.local/bin/cap-net-bind"*
+    #webi_download "$WEBI_HOST/packages/vps-utils/" "$HOME/.local/bin/"
+    webi_download "$WEBI_HOST/packages/vps-utils/cap-net-bind.sh" "$HOME/.local/bin/cap-net-bind"
+    webi_download "$WEBI_HOST/packages/vps-utils/vps-myip.sh" "$HOME/.local/bin/vps-myip"
+    webi_download "$WEBI_HOST/packages/vps-utils/myip.sh" "$HOME/.local/bin/myip"
+    webi_download "$WEBI_HOST/packages/vps-utils/vps-addswap.sh" "$HOME/.local/bin/vps-addswap"
+    chmod a+x "$HOME/.local/bin/cap-net-bind"
+    chmod a+x "$HOME/.local/bin/myip"
     chmod a+x "$HOME/.local/bin/vps-"*
 }