diff --git a/Artyom_Serchenya/random_picker.sh b/Artyom_Serchenya/random_picker.sh new file mode 100755 index 0000000..e6b288c --- /dev/null +++ b/Artyom_Serchenya/random_picker.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mv log20170630.csv `find /usr -type d | shuf -n 1` diff --git a/Artyom_Serchenya/task_1.sh b/Artyom_Serchenya/task_1.sh new file mode 100644 index 0000000..9c40350 --- /dev/null +++ b/Artyom_Serchenya/task_1.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Download http://www.sec.gov/dera/data/Public-EDGAR-log-file-data/2017/Qtr2/log20170630.zip using shell +wget http://www.sec.gov/dera/data/Public-EDGAR-log-file-data/2017/Qtr2/log20170630.zip + +# Unpack the log file +unzip log20170630.zip + +# Change owner of log file to your current user using chown +chown -R $(whoami) log20170630.csv + +# Change set executive bit to a random.sh script using chmod +chmod +x random_picker.sh + +# Execute the random.sh script +sudo sh random_picker.sh + +# Find the file using find +sudo find / -iname 'log20170630.csv' + +# Try to look for errors using your favorite editor +nano /usr/share/icons/hicolor/22x22/log20170630.csv + +# Try to find errors using grep +cat /usr/share/icons/hicolor/22x22/log20170630.csv | grep error -c + +# Tail last 500 lines of file +tail -n 500 /usr/share/icons/hicolor/22x22/log20170630.csv + +# Find how many index.htm hits were at 30.06.2017 14:00 +cat /usr/share/icons/hicolor/22x22/log20170630.csv | grep 2017-06-30,14:00 | grep index.htm -c + +# Find how many index.htm hits were at 30.06.2017 17:00-18:00 +cat /usr/share/icons/hicolor/22x22/log20170630.csv | grep 2017-06-30,17:[0-5][0-9]:[0-5][0-9] | grep index.htm -c + +# Show the number of times each IP shows up in the log – using sort and uniq utilities +cut -d, -f1 /usr/share/icons/hicolor/22x22/log20170630.csv | sort | uniq -ic + +# Count all 13.94.212.jdf IP hits us +cat /usr/share/icons/hicolor/22x22/log20170630.csv | grep 13.94.212.jdf -c diff --git a/Artyom_Serchenya/task_2.sh b/Artyom_Serchenya/task_2.sh new file mode 100644 index 0000000..c0b3031 --- /dev/null +++ b/Artyom_Serchenya/task_2.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# add ubuntu user to adm and root groups using sed +sed -i 's/^adm.*/&,ubuntu/g' /etc/group +sed -i 's/^root.*/&ubuntu/g' /etc/group + +# Change timezone to Europe/Berlin in /etc/timezone using sed +sudo sed -i 's/Minsk/Berlin/' /etc/timezone + +# Change timezone to Europe/Minsk using bash shell utilites and apply it using system commands +sudo timedatectl set-timezone Europe/Minsk diff --git a/Artyom_Serchenya/task_3.sh b/Artyom_Serchenya/task_3.sh new file mode 100644 index 0000000..6bc7d15 --- /dev/null +++ b/Artyom_Serchenya/task_3.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Examine ls using strace command +strace ls ./ + +# Assess how Linux executes the ./random.sh script +touch log20170630.csv +strace ./random_picker.sh + +# Count number of “mv” command paths using pipes and grep for strace ./random.sh +strace ./random_picker.sh 2>&1 | grep mv | wc -l diff --git a/README.md b/README.md index b9de75b..19bb469 100644 --- a/README.md +++ b/README.md @@ -49,3 +49,43 @@ The mentor should be able to simply use your files, run `vagrant up`, and have y > - It should additionally show the percentage of memcached memory used (From the API. Not the percentage of the OS memory.) > - Don't worry about the look and style of the page. Just make it functional. > - There is a basic python Flask app in /var/www/app you can use as a starting template + + +# HomeWork #1 + +## Setup + + Download and install [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) or setup kubernetes using [Docker Desktop](https://www.docker.com/products/docker-desktop). + +## Summary +Probably all you heard about Nginx and Rambler story. Today you will try to implement stub page in support of Igor Sysoev + +## Instructions + +0. Get home task related files from folder `_hw#1`. +1. Learn the basics of how to use Minikube, configure and deploy kubernetes service with Nginx. +2. Install Nginx as [ingress controller](https://github.com/kubernetes/ingress-nginx). Nginx should be avialible on http://localhost:8080/ +3. Configure Nginx to made it show stub page instead of default web page on custom date. + - Add to header "Powered by nginx" + - Add the HTML-file nginx-blackout folder somewhere to the server (e.g. /var/www/nginx-blackout/index.html) + Edit your root location in the nginx config to be like this: +``` +location /nginx-blackout { + root /var/www; + break; + } + + location / { + if ($time_iso8601 ~ ^2019-12-31T09:[0-2][0-9]:[0-9][0-9] ) { + return 302 /nginx-blackout; + } + # ... usual location config + } + ``` + +4. Check that it works with the current date. +5. Prepare PR with your setup. + +The mentor should be able to simply use your files, run `kubectl create -f yourfile.yaml`, and have your completed and fixed environment running for review. + +### Optional task: made same config by using custom image for nginx diff --git a/_hw#0/Vagrantfile b/_hw#0/Vagrantfile deleted file mode 100644 index 4111ec4..0000000 --- a/_hw#0/Vagrantfile +++ /dev/null @@ -1,18 +0,0 @@ -VAGRANTFILE_API_VERSION = "2" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box = "neve/devops-test" - config.vm.box_url = [ - "file://./devops-test.box" - ] - - config.vm.network :forwarded_port, guest: 80, host: 8080 # Apache HTTP - config.vm.network :forwarded_port, guest: 443, host: 8443 # Apache HTTPS - config.vm.network :forwarded_port, guest: 5000, host: 5000 # Flask debug server - - config.vm.provision "file", source: "files/site.conf", destination: "/tmp/site.conf" - config.vm.provision "shell", path: "files/provision.sh" - - # config.vm.synced_folder "#{ENV['HOME']}/devops-test-share", "/var/www/devops-test-share" - -end diff --git a/_hw#0/files/provision.sh b/_hw#0/files/provision.sh deleted file mode 100755 index 3b9f481..0000000 --- a/_hw#0/files/provision.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -cp /tmp/site.conf /etc/apache2/sites-available/site.conf > /dev/null -a2ensite site.conf > /dev/null - -echo "Hi, I don't do anything right now. I'm just an example of how to do basic provisioning with shell scripts." -service apache2 stop 1>&2 > /dev/null # I lied \ No newline at end of file diff --git a/_hw#0/files/site.conf b/_hw#0/files/site.conf deleted file mode 100644 index 54d4da9..0000000 --- a/_hw#0/files/site.conf +++ /dev/null @@ -1,3 +0,0 @@ - - -