Skip to content

Commit

Permalink
Adding Develop features to main (#11)
Browse files Browse the repository at this point in the history
* rm duplicates added rsync

* added bzip, pw10 theme ownership,  and consistant ADD over COPY

* adding ownership and history plugin as well as rc files

* codespace font setting

* Coder (#6)

* moar promptiness

* more compatible with lesser fonting

* add user to docker group

* corrected docker lib reference

* added dockerinfo to tasks

* better separation of build env

* Testing with badges and adding notes

* Testing with badges and adding notes

* changed workflow names

* changed from app to dev container name

* fixed indent filure

* indenting

* versioning test

* removed bad version test

* added Docker test tasks

* added docker test tasks

* added example bash script to basic-test network

* Added test_net and docs
  • Loading branch information
growlf authored Feb 9, 2024
1 parent ed4d507 commit dd6d833
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,8 @@ ADD --chown=1000:1000 src/.p10k.zsh /home/$USERNAME/.p10k.zsh
ADD --chown=1000:1000 --chmod=+x src/tasks.py .
ADD --chown=1000:1000 --chmod=+x https://private-sw-downloads.s3.amazonaws.com/archfx_broker/preflight/broker_preflight.sh .

ADD --chown=1000:1000 --chmod=+x src/test_net.sh .
ADD --chown=1000:1000 src/nodes.list .

# Set default command
CMD ["/bin/zsh"]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ Using `tcpdump` can either be done from within a shell of the toolbox container,

docker run --rm -it --net=host ghcr.io/growlf/toolbox sudo tcpdump

### Invoke Command
### Running scripts and commands

You can also run arbitrary commands and scripts directly from the commandline like so:

docker compose run --rm -it app1 ./test_net.sh

## Invoke

This image implements [Python Invoke](https://www.pyinvoke.org/), for managing shell-oriented subprocesses and organizing executable Python code into CLI-invokable tasks. There are a few basic tasks defined as examples already.

Expand Down
6 changes: 6 additions & 0 deletions src/nodes.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
127.0.0.1
1.1.1.1
8.8.8.8
google.com
microsoft.com
failed.ip.does.not.exist
62 changes: 62 additions & 0 deletions src/test_net.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# File with nodes to test, one address per line
NODES_FILE=./nodes.list

# Test for color support
# check if stdout is a terminal...
if test -t 1; then

# see if it supports colors...
ncolors=$(tput colors)

if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi

# Show the date this script was run
date

# Get the primary interface IP and device name
ip4=$(/sbin/ip route get 8.8.8.8 | awk '/src/ { print $7 }')
dev=$(/sbin/ip route get 8.8.8.8 | awk '/src/ { print $5 }')
echo "Host IP address on $dev: $ip4"

# Get external IP address
external=$(dig @resolver4.opendns.com myip.opendns.com +short)
echo "Public IP address: $external"

# Get and test acces to the default gateway
default_gateway=$(/sbin/ip route | awk '/default/ { print $3 }')
ping -c 1 "$default_gateway" > /dev/null
if [ $? -eq 0 ]; then
echo "- node $default_gateway (default gateway) is ${green}accessible${normal}"
else
echo "ERROR: default gateway ($default_gateway) is ${red}${bold}unreachable${normal}"
exit 1
fi

# Loop over supplied node addresses list if it exists
if test -f ${NODES_FILE}; then
cat ${NODES_FILE} | while read output
do
ping -c 1 "$output" > /dev/null
if [ $? -eq 0 ]; then
echo "- node $output is ${green}accessible${normal}"
else
echo "- node $output is ${red}${bold}unreachable${normal}"
fi
done
fi

0 comments on commit dd6d833

Please sign in to comment.