Friday, June 25, 2021

Azure Agent - Configure As a Service Linux or Standalone or Nohup &

https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops


#Configure it as a linux process and using nohup &

./run.sh 

ps -ef --sort=start_time |grep -E 'Agent|run.sh'

--------------------------------------------------------------------------------------------------------

#Configure Listener as a service in Linux, It actually, starts 3 Services 

sudo ./svc.sh install    #Creates a symlink under /etc/systemctl/system

sudo ./svc.sh start

sudo ./svc.sh status

sudo ./svc.sh uninstall  #Uninstall Service(SystemD) ,You should stop before you uninstall.

ps -ef --sort=start_time |grep -E 'Agent|runsvc'


ps -ef --sort=start_time |grep -E 'vsts|Agent|run.sh'

sudo systemctl is-active 'vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service'

sudo systemctl is-enabled 'vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service'

sudo systemctl status 'vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service'


#Configure Listener as a service in Linux, It actually, starts 3 Services 

Loaded: loaded (/etc/systemd/system/vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service; enabled; vendor preset: enabled)

   Active: active (running) since Sat 2021-06-26 04:12:27 UTC; 17min ago

 Main PID: 27333 (runsvc.sh)

    Tasks: 21 (limit: 4915)

   CGroup: /system.slice/vsts.agent.GenpactDigitalEngineering.eks\x2ddev.dev.service

           ├─27333 /bin/bash /home/eks/agent/runsvc.sh

           ├─27336 ./externals/node/bin/node ./bin/AgentService.js

           └─27356 /home/eks/agent/bin/Agent.Listener run --startuptype service


Remove and re-configure an agent (Not Service) The Whole Agent

To remove the agent:

1) Stop and uninstall the service as explained above.

2) Remove the agent.            [As it appears in Agent Pool]

./config.sh remove  [Enter your credentials.]


After you've removed the agent, you can configure it again.

Thursday, June 24, 2021

AWS : S3API vs S3

aws s3api create-bucket --bucket my-bucket --region us-east-1

aws s3 mb s3://myeucentral1bucket --region eu-central-1

aws s3 sync s3://DOC-EXAMPLE-BUCKET-SOURCE s3://DOC-EXAMPLE-BUCKET-TARGET

--------------------------------------------------

aws s3api create-bucket --bucket cca-product-dev-s3bucket --region us-east-1 --acl public-read

aws s3 sync s3://cca-product-s3-bucket s3://cca-product-dev-s3bucket --dryrun

--------------------------------------------------

https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html

https://aws.amazon.com/blogs/developer/leveraging-the-s3-and-s3api-commands/

https://aws.amazon.com/premiumsupport/knowledge-center/move-objects-s3-bucket/

https://stackoverflow.com/questions/27932345/downloading-folders-from-aws-s3-cp-or-sync

difference b/w Linux Operators : | || && & > >> ;

https://unix.stackexchange.com/questions/159489/is-there-a-difference-between-and-and

https://unix.stackexchange.com/questions/89386/what-is-symbol-and-in-unix-linux




  • > redirects output to a file, overwriting the file.

  • >> redirects output to a file appending the redirected output at the end

  • ;: commands separated by a ; are executed sequentially. The shell waits for each command to terminate in turn.

  • &&: command after && is executed if, and only if, command before && returns an exit status of zero. You can think of it as AND operator.

  • |: a pipe. In expression command1 | command2 The standard output of command1 is connected via a pipe to the standard input of command2.

There are more similar control operators, worth to mention:

  • ||: command after || is executed if, and only if, command before || returns a non-zero exit status. You can think of it as OR operator. Please note, that | and || are completely different animals.

  • &: the shell executes the command terminated by & in the background, does not wait for the command to finish and immediately returns exit code 0. Once again, & has nothing to do with &&.

  • |&: a shorthand for 2>&1 | i.e. both standard output and standard error of command1 are connected to command2's standard input through the pipe.

Additionally if you use zsh then you can also start command with &| or &!. In this case job is immediately disowned, after startup it does not have a place in the job table.

Linux : Difference between >> and >

 > redirects output to a file, overwriting the file.

>> redirects output to a file appending the redirected output at the end


https://unix.stackexchange.com/questions/89386/what-is-symbol-and-in-unix-linux

FSTAB Format

https://www.thegeekdiary.com/understanding-the-configuration-file-for-mounting-file-systems-etc-fstab/

https://askubuntu.com/questions/9939/what-do-the-last-two-fields-in-fstab-mean

chmod octet 777 vs -R ugo+rwx ??? Difference

 chmod -R 777 /efs  is not safer

chmod -R ugo+rwx /efs is safer - Does not override SETUID AND SETGID BITS - Just Appends permissions

https://unix.stackexchange.com/questions/296675/is-chmod-r-ugorwx-safer-than-chmod-r-777


sudo tee -a

Append text when using sudo

echo '104.20.186.5 www.cyberciti.biz' | sudo tee -a /etc/hosts

Persist firewal changes iptables redhat 7 across restart ?

Persist iptables redhat 7 ?


https://access.redhat.com/webassets/avalon/d/Red_Hat_Enterprise_Linux-7-Security_Guide-en-US/images/eee9192950e07b21f5c95b3ced63ae09/RHEL_Security-Guide_453350_0717_ECE_firewalld-comparison-rhel7.png

https://www.thegeekdiary.com/centos-rhel-how-to-make-iptable-rules-persist-across-reboots/

[IMPORTANT]

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/sec-using_firewalls#sec-Getting_started_with_firewalld


https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

https://serverfault.com/questions/708728/iptables-not-starting-upon-reboot

https://www.tecmint.com/linux-firewall-iptables-interview-questions-and-answers/    [IMP]

https://www.digitalocean.com/community/tutorials/how-to-configure-a-linux-service-to-start-automatically-after-a-crash-or-reboot-part-1-practical-examples

https://linuxconfig.org/how-to-change-a-runlevel-on-rhel-7-linux-system


Typically the location of iptables configuration lies at ‘/etc/sysconfig/iptables‘ whereas firewalld configuration lies at ‘/etc/firewalld/‘, which is a set of XML files.


EDIT

/etc/firewalld/zones/public.xml


sudo systemctl status firewalld

sudo /sbin/service iptables status

sudo /sbin/service iptables save

sudo less /etc/sysconfig/iptables

sudo iptables -S

sudo iptables -A IN_public_allow -p tcp -m tcp --dport 27017 -m conntrack --ctstate NEW,UNTRACKED -j ACCEPT


-A IN_public_allow -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW,UNTRACKED -j ACCEPT

-A IN_public_allow -p tcp -m tcp --dport 8080 -m conntrack --ctstate NEW,UNTRACKED -j ACCEPT



  <service name="ssh"/>

  <service name="dhcpv6-client"/>

  <port protocol="tcp" port="8080"/>

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass