Git Product home page Git Product logo

hometasks_andersen's Introduction

1st bash task --- netstat_script.sh

listip=$(netstat -tunapl | awk -v name=$1 '$0~name {print $5}' | cut -d: -f1 | sort | uniq -c | sort | tail -n5 | grep -oP '(\d+\.){3}\d+')
  • Variable listip contains uniq IP adresses
  • Netstat command shows extended output about our connections
  • awk reads output from netstat and prints only IP adresses. This construction -v name=$1 '$0~name allows to use positional arguments
  • Next commands cut out ports and leave only uniq IP adresses
#This function shows organisations and adresses 
function address {
for ip in $listip ; do whois $ip | awk -F':' '/^Organization/{print $2}/^Address/{print $2; print "";}' ; done
}
#This function shows count of connections of each organizatio
function count {
for ip in $listip ; do whois $ip | awk -F':' '/^Organization/{print $2}' >> output ;done
cat output | sort | uniq -c | awk -F'    ' '{print $3, "has", $2, "connections" }' 
rm output
}

3rd bash task --- github_script.sh

The script can take GitHub repository URL as argument, e.g:
./github_script.sh https://github.com/curl/curl

If it called without any arguments, then https://github.com/orkestral/venom is used by default.

#Download JSON file with pull requests info 
curl   -H "Accept: application/vnd.github.v3+json"   https://api.github.com/repos/orkestral/venom/pulls > ./test.json

jq command allows to get requiring part of json file.

Сonstruction [ -z "$(jq '.[].number' test.json)" ] returns true if string length from .[].number == 0. If true runs printf command , else runs remaining part.

jq '.[].user.login' test.json | sort | uniq -c | awk '{if ($1 > 1) print $2}' shows users that have more than 1 pull request.

Next if conidition if [ -z "$(jq '.[].labels[].name' test.json)" ]; then checks if there are PRs with labels also using -z key

# `sed 's/\"//g'` cuts out the quotes
jq '.[] | .user.login + " " + .labels[].name' test.json | sed 's/\"//g' | sort | uniq -c | awk '{print "User", $2 , "has", $1, "PR with label"  }'

This command gets logins and labels names in 2 column and print number of labels for each user

jq '.[] | (.number|tostring) + " " +  .user.login' test.json | sed 's/\"//g' | sort | awk '{print "User" , $2, "with PR number" , $1}'

This command shows sorted PR numbers with users logins

Ansible task

Structure of ansible role

│   play.yml
│   hosts.yml    
│
└───roles
     └───flask
          └───defaults
          │      main.yml   
          └───files
          │      flaskapp.py
          └───handlers
          │      main.yml
          └───tasks  
          │      main.yml
          └───templates 
                 pyton_flask.service.j2
                 sshd_config.j2  

To start ansible role need to launch playbook play.yml with command ansible-playbook play.yml -i hosts.yml.

hometasks_andersen's People

Contributors

mataras avatar vkutas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.