Wednesday, August 5, 2020

apt-mirror fix to download installer files

Here are the changes I had to make to be able to download complete Ubuntu repository with X86_64 installer (netboot) directory contents. The apt-mirror was also failing for in18n directory as some files with extensions xz needed to be downloaded - that is fixed as well. Pay attention to less than symbol "<"

root@dhcp2064-29:~# diff /usr/bin/apt-mirror /usr/bin/apt-mirror.ori
> 
423,430d451
<             add_url_to_download( $url . $_ . "/cnf/Commands-" . $arch . ".xz" );            
<             add_url_to_download( $url . $_ . "/installer-amd64/current/legacy-images/netboot/" . "boot.img.gz" );            
<             add_url_to_download( $url . $_ . "/installer-amd64/current/legacy-images/netboot/" . "ldlinux.c32" );            
<             add_url_to_download( $url . $_ . "/installer-amd64/current/legacy-images/netboot/" . "mini.iso" );            
<             add_url_to_download( $url . $_ . "/installer-amd64/current/legacy-images/netboot/" . "netboot.tar.gz" );            
<             add_url_to_download( $url . $_ . "/installer-amd64/current/legacy-images/netboot/" . "pxelinux.0" );            
<             add_url_to_download( $url . $_ . "/installer-amd64/current/legacy-images/netboot/ubuntu-installer/amd64/" . "initrd.gz" );            
<             add_url_to_download( $url . $_ . "/installer-amd64/current/legacy-images/netboot/ubuntu-installer/amd64/" . "linux" );            
466,467c487
<     #$uri =~ s/^([^@]+)?@?// if $uri =~ /@/;
<     $uri =~ s/^([^@]+)?@?// if (split '/',$uri)[0] =~ /@/;
---
>     $uri =~ s/^([^@]+)?@?// if $uri =~ /@/;
503c523
<                     if ( $filename =~ m{^$component/i18n/Translation-[^./]*\.(bz2|xz)$} )
---
>                     if ( $filename =~ m{^$component/i18n/Translation-[^./]*\.bz2$} )
1046d1065
< 

Wednesday, January 8, 2020

AWK with if-else loop example

Bash script with AWK example - in this example, if the line contains one type of keywords, I wanted to add something in the end of same line and if the line contained something else, I wanted to add some other text.
cat /tmp/file1 |  \
 awk '{ 
  if ($0~"RHEL" || $0~"rhel" || $0~"CENT" || $0~"cent") 
            print $0 " --os-family \"Redhat\""
  if ($0~"Ubuntu" || $0~"UBUN" || $0~"ubun")
            print $0 " --os-family \"Debian\""
 };' > /tmp/file2

Monday, September 17, 2018

AWS EC2 Instance (advance section script) with webserver and availability zone info

The use of this script requires basic knowledge of AWS and shell scripting. This is the script I normally use when I want to test something in my personal account and let the instance be powered off after 2 hours.

This script will bring up EC2 instance with following :

* updated packages,
* HTTPD service installed and started,
* Also run a job at startup to Poweroff instance after 2 hours (refer 7200)

(Note: Poweroff is kept only for those who need instance only for practicing and/or limited time and to save costs. In case of production use, comment out poweroff statement)

#!/bin/bash
yum update -y
yum install httpd24 -y
service httpd start
chkconfig httpd on
echo "Hello, this is a test instance from `curl http://169.254.169.254/latest/meta-data/placement/availability-zone`" > /var/www/html/index.html

echo "# This will bring up instance only for below mentioned seconds" >> /etc/rc.local
echo "(sleep 7200; poweroff) &" >> /etc/rc.local

Wednesday, April 5, 2017

Kickstart troubleshooting

This is to see if a server which need to be kickstarted is able to get initial files from TFTP server (which runs on port 69).
[root@kickstarter pxelinux.cfg]# tcpdump -i eth0 port 69
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
11:30:19.077306 IP srv-9000.ah-esp-encap > kickstarter.domain.com.tftp:  41 RRQ "linux-install/pxelinux.0" octet tsize 0
11:30:19.106252 IP srv-9000.acp-port > kickstarter.domain.com.tftp:  46 RRQ "linux-install/pxelinux.0" octet blksize 1456
11:30:19.183548 IP srv-9000.40769 > kickstarter.domain.com.tftp:  77 RRQ "linux-install/pxelinux.cfg/01-c4-34-6b-b9-16-70" octet tsize 0 blksize 1440
11:30:19.213799 IP srv-9000.40770 > kickstarter.domain.com.tftp:  65 RRQ "linux-install/pxelinux.cfg/0A4461FA" octet tsize 0 blksize 1440
11:30:19.242361 IP srv-9000.40771 > kickstarter.domain.com.tftp:  63 RRQ "linux-install/rhel-as-7u1/vmlinuz" octet tsize 0 blksize 1440
11:30:35.973742 IP srv-9000.40772 > kickstarter.domain.com.tftp:  66 RRQ "linux-install/rhel-as-7u1/initrd.img" octet tsize 0 blksize 1440
^C
6 packets captured
38 packets received by filter
1 packets dropped by kernel

Monday, February 27, 2017

Annoying GUI Pop-up in VNC and how to disable it?

# ls -l /etc/xdg/autostart/gpk-update-icon.desktop
-rw-r--r-- 1 root root 7115 Feb 16 16:04 /etc/xdg/autostart/gpk-update-icon.desktop
Append below line in above mentioned file:
X-GNOME-Autostart-enabled=false

Once done, restart server and the pop-up shown above should be gone.