Moved scripts to the overlay folder to be used as packages
All scripts have been moved to the overlay folder in the top level directory Overlay is now instantiated per configuration to make use of the host variable
This commit is contained in:
18
overlay/scripts/commands/icanhazip.nix
Normal file
18
overlay/scripts/commands/icanhazip.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "icanhazip";
|
||||
runtimeInputs = with pkgs; [ iproute2 curl gawk coreutils ];
|
||||
text = ''
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Public IP: $(curl -s icanhazip.com -4)"
|
||||
ip route | awk '/default/ {print "Default Gateway: " $3} /src/ {print "Local IP: " $9}' | head -n 2
|
||||
else case $1 in
|
||||
"-p" ) echo "Public IP: $(curl -s icanhazip.com -4)";;
|
||||
"-d" ) ip route | awk '/default/ {print $3}';;
|
||||
"-l" ) ip route | awk '/src/ {print $9}';;
|
||||
* ) echo "Options: -p, -d or -l for public ip, default gateway, and local ip respectively"; echo "i.e. icanhazip -p"
|
||||
esac
|
||||
fi
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user