Sunday, January 31, 2016

SoftPerfect RAM Disk new version detect

This is one of my favorite must have application and now it is a member of my detect collection.

SoftPerfect RAM Disk latest version are always located under this link:
https://www.softperfect.com/download/freeware/ramdisk_setup.exe

I this scenario i desided to create a triple check if the link is good.

At first i save all information what is related to this url
wget -S --spider -o output.log "https://www.softperfect.com/download/freeware/ramdisk_setup.exe"
Then i check the http status code:
grep -A99 "^Resolving" output.log | grep "HTTP.*200 OK"
if [ $? -eq 0 ]; then
echo status code is good
else
echo not good status code
fi
I look if there IS such thing as Content-Length
grep -A99 "^Resolving" output.log | grep "Content-Length" 
if [ $? -eq 0 ]; then
echo detected content
else
echo content not found
fi
At the end i calculate if the content is fair enought to be called a content:
contentlength=$(grep -A99 "^Resolving" output.log | grep "Content-Length" | sed "s/^.*: //")
if [ $contentlength -gt 2048000 ]; then
echo content is at least 2 megabytes
else
echo this content is not fair enought
fi
Complete project is located here:
https://github.com/catonrug/softperfect-ram-disk-detect/blob/master/check.sh

Now i understand that i can rebuild these project for lower bandwidth usage:
Skype detect
TeamViewer detect
Flash Player detect

Saturday, January 30, 2016

VMware, Operating System not found


This can happen if you after vmware machine clone if your machine has multiple disks.

Select "Force BIOS setup":

Now swap SCSI drives, save settings:

Celebrate!

Dropbox new version detect

My fourteenth project for offline installer detection.

This time it is Dropbox.

To detect latest offline installer i use link:
https://www.dropbox.com/download?full=1&plat=win
And this link is debugged with wget spider.
wget -S --spider -o output.log "https://www.dropbox.com/download?full=1&plat=win"
And here is how i get the current active version version:
grep -A99 "^Resolving" output.log | sed "s/https/\nhttps/g" | sed "s/exe/exe\n/g" | grep "^https.*exe$" | head -1
The whole project is hosted under:
https://github.com/catonrug/dropbox-detect/blob/master/check.sh

I have made a huge mistake by not quoting the url in wget command in previous thirtheen projects :o
http://www.catonrug.net/search/label/detect

Friday, January 29, 2016

Create CentOS 7 Base Software Channel, Spacewalk

Open [Channels] section, go for [Manage Software Channels] and click [Create]

Write down:
Channel Name:
CentOS 7 Base x86_64
Channel Label:
centos-7-base-x86_64
Architecture:
x86_64
Channel Summary:
centos-7-base-x86_64

Scroll down the page and enter:
GPG key URL:
http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7
GPG key ID:
F4A80EB5
GPG key Fingerprint:
6341 AB27 53D7 8A78 A7C2  7BB1 24C6 A8A7 F4A8 0EB5
Note. This data came from:
curl http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-7 > /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 /var/www/html/pub/RPM-GPG-KEY-CentOS-7
gpg --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
pub  4096R/F4A80EB5 2014-06-23 CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>
      Key fingerprint = 6341 AB27 53D7 8A78 A7C2  7BB1 24C6 A8A7 F4A8 0EB5
Click [Create Channel] at the end

Now again Open [Channels] section, go for [Manage Software Channels],
go for [Manage Repositories], click [Create Repository]

Fill down:
Repository Label:
centos-7-base-x86_64
Repository URL:
http://centos.koyanet.lv/centos/7/os/x86_64
Click [Create Repository]

Now we have to create a connection between base channel and repository:
Go for [Channels], open [Manage Software Channels], click on YOUR base channel:

Go for [Repositories] tab, check YOUR repository and click [Update Repositories]:

Open up the command line and type:
spacewalk-repo-sync -c centos-7-base-x86_64
If you are planing to use kickstart future the use:
spacewalk-repo-sync -c centos-7-base-x86_64 --sync-kickstart
Continue with centos-7-updates-x86_64

ActivePresenter new version detect

This is my twelfth project for offline installer detect.

This time it is ActivePresenter.
I love this software for just one simple reason - video capture with loseless queality

This time i faced very new problem with wget spider.
If i put wrong url for query then it still get possitive result which is wrong in my scenario.
I solved the issue with grep -A99 which means show 99 lines after match
wget -S --spider -o output.log http://atomisystems.com/apdownloads/latest/ActivePresenter_setup.exe
grep -A99 "^Resolving" output.log | grep "http.*ActivePresenter.*exe" > /dev/null
if [ $? -eq 0 ]; then
echo link retrieves exe file
else
echo the url is broken
fi
Here is the project:
https://github.com/catonrug/activepresenter-detect/blob/master/check.sh

Thursday, January 28, 2016

PDFCreator new version detect

Welcome to my eleventh project of detecting latest offline installer. This time it is PDFCreator.

In this project i used same spider method to detect installer:
wget -S --spider -o output.log http://download.pdfforge.org/download/pdfcreator/PDFCreator-stable?download
As an huge improvement i create a detection rule if the page still retrieves any exe installer:
grep "http.*PDFCreator.*exe" output.log > /dev/null
if [ $? -eq 0 ]; then
echo installer exist
else
echo send email to administrator
fi
The whole application can be found:
https://github.com/catonrug/pdfcreator-detect/blob/master/check.sh

Create CentOS 7 child channel, Spacewalk

Create a new Channel:

Fill the fields!

Channel Name:
spacewalk-client-2-5-rhel-7-x86_64
Channel Label:
spacewalk-client-2-5-rhel-7-x86_64
Parent Channel:
CentOS 7 Base x86_64
Architecture:
x86_64
Channel Summary:
spacewalk-client-2-5-rhel-7-x86_64

Scroll down the page and enter:
GPG key URL:
http://yum.spacewalkproject.org/RPM-GPG-KEY-spacewalk-2015
GPG key ID:
B8002DE1
GPG key Fingerprint:
A5FC 508C DD3C C46D 3C3B  4612 DCC9 81CD B800 2DE1
This is the same key from:
curl http://yum.spacewalkproject.org/RPM-GPG-KEY-spacewalk-2015 > /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2015
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2015 /var/www/html/pub/RPM-GPG-KEY-spacewalk-2015
gpg --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2015
pub  1024D/B8002DE1 2015-04-17 Spacewalk <spacewalk-devel@redhat.com>
      Key fingerprint = A5FC 508C DD3C C46D 3C3B  4612 DCC9 81CD B800 2DE1
Click [Create Channel] at the end

Open [Channels] section, go for [Manage Software Channels],
go for [Manage Repositories], click [Create Repository]

Fill down:
Repository Label:
spacewalk-client-2-5-rhel-7-x86_64
Repository URL:
http://yum.spacewalkproject.org/2.5-client/RHEL/7/x86_64
Click [Create Repository]

Now open your child channel:

Assing child repository to child channel and press [Update Repositories] button:

Now at the command line execute:
spacewalk-repo-sync -c spacewalk-client-2-5-rhel-7-x86_64

Office 2002 / XP patches, slipstream, 10.6871.6870

%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0MAINSP3ff.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0OWC10.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0SNAPVIEW.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0CDO10.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0Works432.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0FM20.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0MSCONV.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0VBE6.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0OUTLOOK.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0MSPUB.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0USP10.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0GPFILT.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0OLKINTL.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0WINWORD.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0SHARED.msp" /qb
%systemroot%\system32\msiexec.exe /a "%~dp0PROPLUS.MSI" /p "%~dp0EXCEL.msp" /qb
Service pack 3:
http://download.microsoft.com/download/9/1/F/91FFC6B2-0745-470B-8DD3-1285B85DB12B/OfficeXpSp3-kb832671-fullfile-enu.exe
Use Internet Explorer and go to http://catalog.update.microsoft.com/
Search for updates:
KB947320
KB955440
KB956464
KB957646
KB974556
KB975008
KB976380
KB980371
KB2284692
KB2288608
KB2289162
KB2293422
KB2328360
KB2509461
KB2541003
Or download this list:
http://download.windowsupdate.com/msdownload/update/software/secu/2010/12/gpfilt_2169bd9ba131cc64070494052ebd11c07a94c229.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2010/12/mspub_b0c50f8d10570feb5ef5cab0bc28ea0a342741b9.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2010/09/usp10_8439a627974f1ad9a34c9742c20ae88109ae9dcc.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2009/11/msconv_a43a00e0d889bb6da72eb7569d15251f8ae19fbd.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2010/04/vbe6_1b380133af898cf956d8b39992761eac3f86137f.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2008/07/snapview_8905434a3f5f1e48fa909daddfe1baf1a3ca2ec6.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2010/06/outlook_e7edf234f537004e5fa07c0f0b7a8b3659a4b4bd.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2010/09/winword_bd3b0b18163e52e2b7edb499ebcfcca7414c5253.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2009/08/owc10_57d5689f99443813055bca3a58eca2df2ab5d048.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2010/09/olkintl_7cd8bcd6188724e60c9482b84f10f0d71dec5fe6.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2011/06/excel_6b6c723f3a4be24058b0b8e73f671f5cbd1854bb.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2011/03/shared_9a730caaf3cd5a3187388bd94356e1f368b3bc5a.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2009/05/works432_a5a3a5b0b7a5af7e0367224dbc2803bfdc10561c.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2009/10/fm20_4de9593922deb147c9f44bf4a8dc13021dad4f12.cab
http://download.windowsupdate.com/msdownload/update/software/secu/2008/10/cdo10_61fbcbecc6f2f6802f05fd55cfc193e8dfb2b9cc.cab
Use 7-zip to extract each file!

Some automations can be found:
https://github.com/catonrug/slipstream-patches-into-office-xp-installation/archive/master.zip

Wednesday, January 27, 2016

Detect new K-Lite Codec Pack version

My tenth project is to detect K-Lite Codec Pack version.

I have implemented this by searching for an torrent file on www.codecguide.com. By analysing torrent file it is possible to found url of file which is hosted via http. This version must be the current. I hope.

The main problem is that this file is hosted only a few days after every new release which means that you have hurry up to grab the file.

The things i learn:

check if the files size is good before do any further things

size=$(curl -o /dev/null -s -w %{size_download} $url)
if [ $size -gt 99999 ]; then
echo it looks like real file
else
echo file size is to small
fi
To detect file version i used pestr utility
pestr $tmp/$filename | grep -m1 -A1 "ProductVersion" | grep -v "ProductVersion"
pestr can be installed following:
Show windows File, Product Version under linux, pev

Complete code can be found:
https://github.com/catonrug/k-lite-codec-pack-detect/blob/master/check.sh

Tuesday, January 26, 2016

Detect new TeamViewer version via command line

I have created my eight project to periodically check for new offline installer.
Projects that i have already made before:
Detect new JRE versions for windows
Detect new Flash Player version
Detect new Skype offline installer for windows
Detect new Silverlight x64 x86 version
Detect new Adobe Reader msi installers, msp patches
Detect new Acrobat Reader DC patches
Use Raspberry Pi to detect new Raspbian version

Teamviewer latest versions is always under link:
https://downloadeu2.teamviewer.com/download/TeamViewer_Setup.exe

So i download this link and i finally can use my extra knowleadge to
detect windows binary version under linux.

This is the main idea:
#!/bin/sh

#set application name based on directory name
appname=$(pwd | sed "s/^.*\///g")

#set temp directory in variable based on application name
tmp=$(echo ./tmp/$appname)

#create temp directory
if [ ! -d "$tmp" ]; then
  mkdir -p "$tmp"
fi

#check if database directory has prepared
if [ ! -d "./db" ]; then
  mkdir -p "./db"
fi

#set database variable
db=$(echo ./db/$appname.db)

#if database file do not exist then create one
if [ ! -f "$db" ]; then
  touch "$db"
fi

#set url
url=$(echo https://downloadeu2.teamviewer.com/download/TeamViewer_Setup.exe)

#calculate filename
filename=$(echo $url | sed "s/^.*\///g")

#download file
wget $url -O $tmp/$filename -q

echo creating sha1 checksum of file..
sha1=$(sha1sum $tmp/$filename | sed "s/\s.*//g")
echo

#check if this checksum is in database
grep "$sha1" $db > /dev/null
if [ $? -ne 0 ]
then
echo new TeamViewer version detected!
echo

echo creating md5 checksum of file..
md5=$(md5sum $tmp/$filename | sed "s/\s.*//g")
echo

echo "$md5">> $db
echo "$sha1">> $db

#detect exact verison of TeamViewer
version=$(pestr $tmp/$filename | grep -m1 -A1 "ProductVersion" | grep -v "ProductVersion")

echo $version

fi
Here is whole program:
https://github.com/catonrug/teamviewer-detect/blob/master/check.sh

Set Office XP Name and Initials, command line


reg add "HKCU\Software\Microsoft\Office\10.0\Common\UserInfo" /v UserInitials /t REG_BINARY /d 69000000 /f
reg add "HKCU\Software\Microsoft\Office\10.0\Common\UserInfo" /v UserName /t REG_BINARY /d 6e000000 /f
reg add "HKCU\Software\Microsoft\Office\10.0\Common" /v UserData /t REG_DWORD /d 1 /f

Monday, January 25, 2016

Excel XP macros security settings, reg add



High settings:
reg add "HKCU\Software\Microsoft\Office\10.0\Excel\Security" /v Level /t REG_DWORD /d 3 /f
Medium settings:
reg add "HKCU\Software\Microsoft\Office\10.0\Excel\Security" /v Level /t REG_DWORD /d 2 /f
Low settings:
reg add "HKCU\Software\Microsoft\Office\10.0\Excel\Security" /v Level /t REG_DWORD /d 1 /f

Install Windows XP drivers via RunOnce script

For Windows XP installation I have usually integrated some RunOnce command:

This will look up RunOnce directory inside CD root.

And finally it executes RunOnce.bat:

content of RunOnce.bat:
@echo off
set d=%systemdrive%\swsetup
set path=%path%;%~dp0
setlocal EnableDelayedExpansion
dir /b "%~dp0*.7z" > nul 2>&1
if !errorlevel!==0 (
echo Drivers
if not exist "%d%" md "%d%"
xcopy /i /c /r /y "%~dp0dpinst.xml" "%d%" > nul 2>&1
xcopy /i /c /r /y "%~dp0dpinst_x64.exe" "%d%" > nul 2>&1
xcopy /i /c /r /y "%~dp0dpinst_x86.exe" "%d%" > nul 2>&1
xcopy /i /c /r /y "%~dp0installdrv.cmd" "%d%" > nul 2>&1
for /f %%a in ('dir /b "%~dp0*.7z"') do (
7z x "%~dp0%%a" -o"%d%\%%a" -y > nul 2>&1
)
"%d%\installdrv.cmd"
) else "%~dp0installdrv.cmd"
endlocal
RunOnce.bat creates a c:\swsetup and copy all necessary files to install drivers.
RunOnce.bat will look for every 7z archive and extract it to c:\swsetup.

Now installdrv.cmd will read dpinst.xml configuration file and install drivers.

Content of installdrv.cmd:
@echo off
if exist "%SystemRoot%\SysWOW64" (goto :x64) else (goto :x86)

:x86
"%~dp0dpinst_x86.exe"
goto Finish

:x64
"%~dp0dpinst_x64.exe"
goto Finish

:Finish

shutdown -s -t 180
Content of dpinst.xml:
<?xml version="1.0" ?>
<dpinst>

<search>
<subDirectory>*</subDirectory>
</search>
<enableNotListedLanguages/>
<suppressEulaPage/>
<suppressAddRemovePrograms/>
<quietInstall/>

<!-- Only install drivers for online hardware -->
<scanHardware/>

<!-- No driver signature required -->
<legacyMode/>

</dpinst>
All project files are located:
https://github.com/catonrug/winxp-install-drivers-runonce/archive/master.zip

ImportError: cannot import name IncompleteRead

ImportError: cannot import name IncompleteRead
This can happen when you have installed python-requests

Please check if it is true:
sudo dpkg -l | grep python-requests
To solve this situation use:
sudo apt-get remove python-pip
sudo easy_install pip

Sunday, January 24, 2016

Deluge Flexget config.yml, Raspberry Pi

Before moving to Flexget plugin Deluge Daemon must be installed.

To work with this tutorial you need to make sure this link retrieve something:
https://kat.cr/tv/?rss=1
Make sure the deluge daemon is running before move to the next step:
ps x|grep [d]eluge
This should report:
  540 ?        Sl   330:52 /usr/bin/python /usr/bin/deluged -d
  580 ?        S     11:18 /usr/bin/python /usr/bin/deluge-web
if everything look fine then move to the root account:
sudo su
Update system:
apt-get update -y && apt-get upgrade -y
Install python pip module:
apt-get install python-pip
Make sure python setup tools is has latest version:
pip install --upgrade setuptools
Now install Flexget. This will take 10 minutes or something:
pip install flexget
Check if the flexget is really installed. This command takes quite a minute to complete
flexget -V
Quit out from root account.
exit
Create Downloads directory:
mkdir -p ~/Downloads
Make flexget configuration directory:
mkdir -p ~/.config/flexget
now create flexget configuration file:
cat > ~/.config/flexget/config.yml << EOF
#define some teplates
templates:
  #this is just a profile name
  webdl:
    #series is a plugins name
    series:
      #series plugin has settings and it must be set
      settings:
        #tv is just a settings profile
        tv:
          #lets take only 720p or 1080p WEB-DL files
          #and never take those which is encoded with x265 hevc codec
          quality: 720p+ webdl !h265
          #set default downloads destination
          set:
            #the Downloads root path must be created
            #series_name will be created automatically
            path: /home/pi/Downloads/{{series_name}}
          #if the 720p file has already downloaded and if 1080p came out
          #then download the best
          upgrade: yes
      #lets take tv settings and define some shows we are interested
      tv:
        - The Big Bang Theory
        - Brooklyn Nine-Nine
        - Mr. Robot
    #we will use deluge daemon to work with magnets
    deluge:
      #how long you seed the file when it is removed from torrent client
      ratio: 0.01
      removeatratio: yes
tasks:
  #this is task name
  kickass:
    priority: 10
    rss: 'https://kat.cr/tv/?rss=1'
    #lets take our template and work with just exactly this rss feed
    template: webdl
  bigbang:
    priority: 20
    rss: 'https://kat.cr/usearch/big%20bang%20theory%20category%3Atv/?rss=1'
    #lets take our template and work with just exactly this rss feed
    template: webdl
  brooklyn:
    priority: 30
    rss: 'https://kat.cr/usearch/brooklyn%20nine%20category%3Atv/?rss=1'
    #lets take our template and work with just exactly this rss feed
    template: webdl
  mrrobot:
    priority: 40
    rss: 'https://kat.cr/usearch/mr%20robot%20category%3Atv/?rss=1'
    #lets take our template and work with just exactly this rss feed
    template: webdl
EOF
There are a lot of life changing options about quality:
http://flexget.com/wiki/Plugins/quality

Lets understand some files related to flexget.
Take a look in flexget configuration direcotry:
ls -1 ~/.config/flexget
There is only one configuration file.
config.yml
Check if the configuration file is well formated:
flexget check
This should totaly return:
2016-01-31 15:09 VERBOSE  manager                       Creating new database /home/pi/.config/flexget/db-config.sqlite ...
2016-01-31 15:09 VERBOSE  check                         Pre-checked 21 configuration lines
2016-01-31 15:09 VERBOSE  check                         Checking config file `/home/pi/.config/flexget/config.yml`
2016-01-31 15:09 VERBOSE  check                         Config passed check.
Take a look again in flexget configuration directory:
ls -1 ~/.config/flexget
This will report all files:
config.yml
db-config.sqlite
flexget.log
To execute task run:
flexget execute
Normaly this will output:
2016-01-31 15:11 VERBOSE  task_queue                    There are 1 tasks to execute. Shutdown will commence when they have completed.
2016-01-31 15:11 VERBOSE  details       kickass         Produced 25 entries.
2016-01-31 15:11 VERBOSE  details       kickass         Summary - Accepted: 0 (Rejected: 0 Undecided: 25 Failed: 0)
You may worry about:

Summary - Accepted: 0 (Rejected: 0 Undecided: 25 Failed: 0)

This meens that your feed just do not have your series inside it in this hour in this second.

Lets schedule flexget to do this check automatically. Open crontab configuration:
crontab -e
Lets check every 1 hour:
55 * * * * /usr/local/bin/flexget -c ~/.config/flexget/config.yml execute
Other error codes related to Flexget:

The key `presets` is not valid here.

You must rename preset[s] to template[s]

Title looks like series but cannot find any series numbering.

This happens when you try to download movies with tv series template.

If you want to check for latest flexget version then move to the root acount and run:
pip install --upgrade flexget

Use Raspberry Pi to detect new Raspbian version

My seventh project - detect new Raspbian version. Here are the basics idea:
#set application name based on directory name
appname=$(pwd | sed "s/^.*\///g")

#set temp directory in variable based on application name
tmp=$(echo ../tmp/$appname)

#create temp directory
if [ ! -d "$tmp" ]; then
  mkdir -p "$tmp"
fi

#check if database directory has prepared 
if [ ! -d "../db" ]; then
  mkdir -p "../db"
fi

#set database variable
db=$(echo ../db/$appname.db)

#if database file do not exist then create one
if [ ! -f "$db" ]; then
  touch "$db"
fi

#search for all links which ends with "latest"
linklist=$(wget -qO- https://www.raspberrypi.org/downloads/raspbian/ | \
sed "s/\d034/\n/g" | \
grep "http.*latest$" | \
sed '$alast line')

printf %s "$linklist" | while IFS= read -r line
do {

#use spider mode to output all information abaout request
#do not download anything
wget -S --spider -o $tmp/output.log $line

#take the first link which starts with http and ends with zip
url=$(sed "s/http/\nhttp/g" $tmp/output.log | \
sed "s/zip/zip\n/g" | \
grep "^http.*zip$" | head -1)

#calculate exact filename of link
filename=$(echo $url | sed "s/^.*\///g")

#check if this link is in database
grep "$url" $db > /dev/null
if [ $? -ne 0 ]
then
echo new version detected!
echo $url
echo "$url">> $db
echo
fi

} done

#clean and remove whole temp direcotry
rm $tmp -rf > /dev/null
Full code can be found:
https://github.com/catonrug/detect-raspbian/blob/master/check.sh

Saturday, January 23, 2016

Download HTML, parse JavaScript, wget -qO-

I like to use wget -qO- to output html into screen, but sometimes the content do not satisfy me cause the content is javascript generated.

This is quite a workaround:

Install Python Mechanize:
apt-get install python-mechanize python-requests
To install parsejs on raspberry execute
cat > /usr/bin/parsejs << EOF
#!/usr/bin/python
from mechanize import Browser
import sys
import requests
br = Browser()

br.set_handle_robots( False )
br.addheaders = [('User-agent', 'Firefox')]

try:
        r = br.open(sys.argv[1])
        html = r.read()
        print html
except
        print("url do not exist")
EOF
chmod 755 /usr/bin/parsejs
Or:
curl https://raw.githubusercontent.com/catonrug/parsejs/master/parsejs > /usr/bin/parsejs
chmod 755 /usr/bin/parsejs
Or:
curl https://goo.gl/QVUNhV > /usr/bin/parsejs
chmod 755 /usr/bin/parsejs
Now you can execute:
parsejs https://www.sitename.com/

Friday, January 22, 2016

Detect new Adobe Reader msi installers, msp patches

I have created my fifth project for new version detection.
The first fourth projects was:
JRE Windows installer Detect,
Flash Player Detect,
Skype offline exe installer Detect,
Silverlight Detect.

Now i am searching all Adobe Reader available patches and msi installers for english version.

As an input source i take adobe ftp server wich i hope always hosts all latest installers and patches.

In this scenarion i created 4 loops:
1. Look for major version (11, 10)
   |
   2. Search all minor versions and patches (11.0.00, 11.0.01, ..)
      |
      3.1 Look for english msi installer in every directory
      3.2 Look for none MUI patch file msp
At the end i substitute ftp link with http cause http link provides highter speed.

All the code is located here:
https://github.com/catonrug/adobe-reader-detect/blob/master/check.sh

Set up static IP address for Raspbian Jessie

When you check the content of /etc/network/interfaces
head -5 /etc/network/interfaces
You can see:
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
This config file already has some setup:
# grep -v "^$\|^#" /etc/dhcpcd.conf
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
require dhcp_server_identifier
slaac private
nohook lookup-hostname
To configure static IP address add the folowing lines at the end of /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.1.XX/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

All Subnet Mask codes

/30 255.255.255.252
/29 255.255.255.248
/28 255.255.255.240
/27 255.255.255.224
/26 255.255.255.192
/25 255.255.255.128
/24 255.255.255.0
/23 255.255.254.0
/22 255.255.252.0
/21 255.255.248.0
/20 255.255.240.0
/19 255.255.224.0
/18 255.255.192.0
/17 255.255.128.0
/16 255.255.0.0
After reboot you can see active gateway in:
route -n
DNS you can see in file:
cat /etc/resolv.conf
Related:
https://www.aelius.com/njh/subnet_sheet.html

Thursday, January 21, 2016

Manually monitor website from linux command line

Every of this example retrieve numeric value:

curl return request time

curl -o /dev/null -s -w %{time_total} https://www.google.com/

curl size of html

curl -o /dev/null -s -w %{size_download} https://www.google.com/

curl return status code

curl -o /dev/null -s -w %{http_code} https://www.google.com/
For additional commands install nmap:
apt-get install nmap -y

Check if http host is down

nmap -p 80 www.google.com | grep "Host seems down" | wc -l

Check if https host is down

nmap -p 443 www.google.com | grep "Host seems down" | wc -l

Show windows File, Product Version under linux, pev

This is totally brilliant stuff!

I can read windows exe installer file atributes from linux shell. Even on Raspberry Pi!

Move to the root account:
sudo su
Install pcre library or otherwise you will get:

pestr.c:26:18: fatal error: pcre.h: No such file or directory

apt-get install libpcre3-dev -y
Install libssl-dev or you will get:

pehash.c:23:25: fatal error: openssl/evp.h: No such file or directory

apt-get install libssl-dev -y
Download pev source:
wget http://sourceforge.net/projects/pev/files/pev-0.70/pev-0.70.tar.gz/download -O pev.tar.gz
Extract archive:
tar -vzxf pev.tar.gz
Move to the direcotry where source files is havin' a good time:
cd pev
Compile:
make
Install binaries:
make install
Now you are able to use these commands:
readpe rva2ofs ofs2rva pehash pesec pescan pepack pestr pedis peres
Lets test with this file:
wget http://download.microsoft.com/download/5/3/D/53D3880B-25F8-4714-A4AC-E463A492F96E/41212.00/Silverlight.exe -OSilverlight.exe
Find File Version with command:
pestr Silverlight.exe | grep -m1 -A1 "FileVersion" | grep -v "FileVersion"
Find Product Version:
pestr Silverlight.exe | grep -m1 -A1 "ProductVersion" | grep -v "ProductVersion"
I believe if the version ends with zero then zero number is trucated from result..
OR my example do not work at all :)

Related:
http://pev.sourceforge.net/doc/manual/en_us/

Wednesday, January 20, 2016

Detect new Skype offline installer for windows

Hello my friendly friends.
I have created third application new version check "Skype detect"

My first project was Winows Java Runtime Environment Detect
My second project was Flash Player Detect

This project was pretty much copy and paste from "Flash Detect".

What did i learn:
You can wget file additional information like real link without even downloading file:
wget -S --spider http://www.skype.com/go/getskype-full -o output.log
url=$(sed "s/http/\nhttp/g" output.log | sed "s/exe/exe\n/g" | grep "http.*exe" | head -1)
echo $url
Information about skype version you can found by extracting archive and look into file .rsrc/0/MANIFEST/1
wget http://www.skype.com/go/getskype-full -OSkypeSetupFull.exe
7z x SkypeSetupFull.exe -y > /dev/null
version=$(sed "s/<dependency>/\n<dependency>\n/g" .rsrc/0/MANIFEST/1 | \
sed "s/<\/assembly>/\n<\/assembly>\n/g" | \
sed "/<dependency>/,/<\/assembly>/d" | \
sed "s/\d034/\n/g" | \
grep "^[0-9]*.\.[0-9]*.\.[0-9]*.\.[0-9]")
echo $version
Here is complete program:
https://github.com/catonrug/skype-detect/blob/master/check.sh

Tuesday, January 19, 2016

Separate time schedule, calculate math, linux shell

I have multiple raspberry pi's and my goal is to send periodical activity email so i can know that this raspberry is alive.

I want to use same image for every device.
It would be nice if somehow we can schedule this email to send in different time intervals for each raspberry pi.

Since my pi's do not have same IP address i will take fourth IP octet to calculate in which minute should send this email.

In this scenario i work with python email sending using less secure google account:
mkdir -p /var/zabbix/alertscripts/
wget https://gist.githubusercontent.com/superdaigo/3754055/raw/e28b4b65110b790e4c3e4891ea36b39cd8fcf8e0/zabbix-alert-smtp.sh -O/var/zabbix/alertscripts/zabbix-alert-smtp.py -q
sed -i "s/your.account@gmail.com/name.surname@gmail.com/" /var/zabbix/alertscripts/zabbix-alert-smtp.py
sed -i "s/your mail password/yoursecretpassword/" /var/zabbix/alertscripts/zabbix-alert-smtp.py
sed -i "s/Zabbix Alert/Alehandro/" /var/zabbix/alertscripts/zabbix-alert-smtp.py
At first i will seperate fourth octet from IP address:
fourth=$(ifconfig | grep "inet.*addr.*Bcast.*Mask" | sed "s/  Bcast.*$//g" | sed "s/^.*\.//g")
Since schedule will hapen in 1 hour interval i will devide this number with 60 seconds
exactminute=$(expr $fourth % 60)
% means arithmetic remainder of $fourth divided by 60

Now i shedule task:
echo "`echo $exactminute` * * * * root /var/zabbix/alertscripts/zabbix-alert-smtp.py emailaddress@gmail.com \"$(hostname)\" \"$(uptime)\"">> /etc/crontab
This project nicely works together with:
Set dynamic hostname for Raspbian image

Install Zabbix Agent for AIX

Dowload zabbix Agent AIX version archive.
Extract archive and go inside content.
There will be direcotries like:
bin
conf
sbin

Install Zabbix Agent

#create zabbix group
mkgroup zabbix

#create zabbix user and at it to zabbix group
mkuser pgrp='zabbix' groups='zabbix' zabbix

#make configuration direcotry
mkdir /etc/zabbix

#make log directory
mkdir /var/log/zabbix/

#log directory belongs to user zabbix and group zabbix
chown -R zabbix:zabbix /var/log/zabbix/

#make configuration direcotry
mkdir -p /usr/local/etc/

#create direoctory for zabbix process file
mkdir -p /var/run/zabbix/

#process files directory belong to zabbix
chown -R zabbix:zabbix /var/run/zabbix/

#install zabbix_get and zabbix_sender binary 
cp bin/zabbix_* /bin/

#install zabbix_agent and zabbix_agentd binary
cp sbin/zabbix_agent* /sbin/

#copy configuration files
cp -r conf/zabbix_agent* /etc/zabbix/

#link configiguration file
ln -s /etc/zabbix/zabbix_agentd.conf /usr/local/etc/zabbix_agentd.conf

#backup original configuration file
mv /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_bck

#create your own configuration file
cat > /etc/zabbix/zabbix_agentd.conf << EOF
DebugLevel=3
EnableRemoteCommands=1
Hostname=hostname.goes.here
LogFile=/var/log/zabbix/zabbix_agentd.log
PidFile=/var/run/zabbix/zabbix_agentd.pid
Server=x.y.z.w
EOF

#start zabbix agent
zabbix_agentd

Check if zabbix is installed to boot at startup

lsitab zabbix

Set Zabbix Agent to boot at startup

mkitab "zabbix:2:once:/sbin/zabbix_agentd >/dev/null 2>&1"
For debugging purpose use:
#check procesees
ps aux|grep [z]abbix

#kill zabbix agent by process
kill 12345

#clear zabbix agent log
> /var/log/zabbix/zabbix_agentd.log

#start zabbix agent
zabbix_agentd

#check if process exists
ps aux|grep [z]abbix

#check log
cat /var/log/zabbix/zabbix_agentd.log

Monday, January 18, 2016

Clone SD Card without unallocated space

I am using Raspberry Pi to clone another raspbian operating system card.

The things i do is:

Check if usb flash drive is mounted:
sudo fdisk -l
This will report the Raspberry Pi system disk /dev/mmcblk0 and flash drive /dev/sda:
Disk /dev/mmcblk0: 64.4 GB, 64423460864 bytes
4 heads, 16 sectors/track, 1966048 cylinders, total 125827072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000981cb

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            8192      122879       57344    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          122880   125827071    62852096   83  Linux

Disk /dev/sda: 8026 MB, 8026849280 bytes
247 heads, 62 sectors/track, 1023 cylinders, total 15677440 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb3c5e39a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            8192      131071       61440    c  W95 FAT32 (LBA)
/dev/sda2          131072     3276799     1572864   83  Linux
So we need to know 3 thigs:
SD card destination which is /dev/sda
The Units size which is 512
The end sector of second partition which is 3276799

Now we create magical command:
sudo dd if=/dev/sda of=/home/pi/backup.img bs=512 count=3276799
And 10 minutes later output will be something like this:
3276799+0 records in
3276799+0 records out
1677721088 bytes (1.7 GB) copied, 569.322 s, 2.9 MB/s
And this is how we backup Raspbian operating system like a Pro :)

Create writable network share, windows, command line

If the share already exist i need to remove it first:
net share "C:\temp" /DELETE /Y
Create new share and let Authenticated Users to write to it:
if not exist "C:\temp" md "C:\temp"
net share temp="C:\temp" /GRANT:"Authenticated Users",CHANGE
Other options:
net share /?

Sunday, January 17, 2016

Detect new Flash Player version via linux shell

I have completed my second transparent and automated project - "Flash Player Detect"
It is a linux script which will detect new flash player offline installer for windows. This script is supposed to run on Raspberry Pi.

The first project was JRE Detect and all the basics is cloned from there.

Here are the code:
https://github.com/catonrug/flash-player-detect/blob/master/check.sh

In this scene i learn:

Store multiple lines in variable with sh

#!/bin/sh
linklist=$(cat <<EOF
http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ax.exe
http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe
extra line
EOF
)

Store multiple lines in variable with bash

#!/bin/bash
linklist=$'http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player_ax.exe\n'
linklist+=$'http://fpdownload.macromedia.com/pub/flashplayer/latest/help/install_flash_player.exe\n'
echo "$linklist"
echo "$linklist" is not the same as echo $linklist

If you want so substitue with an variable you have to use escape quote:
newfilename=$(echo $filename | sed "s/\.exe/_`echo $version`\.exe/")
To extract file with 7z in specific directory use -o:
7z x $tmp/$filename -y -o$tmp > /dev/null
To force script work in his very own direcotry:
cd `dirname \$0`

Saturday, January 16, 2016

Save into HEX, restore from, VNC server silent install

I wanna save VNC server password so i can completely create an unattended VNC installation script. VNC server keeps password file encrypted and it can not be echo. It is not plain text. It is some very garbage value. It is possible to create a backup using HEX editor and then of course the hex numbers will be readable with human eye. In this case it is possible restore file content by using HEX content as source.

Make sure xxd command is installed:
sudo apt-get install hexedit
Create a plain hex backup of file:
xxd -p ~/.vnc/passwd > ~/plain.hex
Restore with:
xxd -p -r ~/plain.hex ~/.vnc/test
Check the diferrence:
md5sum ~/.vnc/passwd
md5sum ~/.vnc/test
rm ~/.vnc/test
Talking about VNC server and passwd file.. It always needs exactly these permisions:
sudo chmod 600 /home/pi/.vnc/passwd
Otherwise nothing will work at all!

This is very life changing stuff!

KDE4 auto login, CentOS 7, Kickstart, Spacewalk

I use these package groups to install KDE.
@ Base
@ X Window System
@ KDE (K Desktop Environment)
For automatic graphical interface use:
boot-straight-into-graphical-interface
sed -i "s/^id:3:initdefault:/id:5:initdefault:/" /etc/inittab
To automatically login user into KDE you have to create a non administrative user.
This goes to kickstart after script:
auto-login-gabriels
adduser gabriels
sed -i "s/^.*AutoLoginEnable=.*$/AutoLoginEnable=true/" /etc/kde/kdm/kdmrc
sed -i "s/^.*AutoLoginUser=.*$/AutoLoginUser=gabriels/" /etc/kde/kdm/kdmrc
In graphicical interface you can do this:
Opening [System Settings], Go to [Advanced] tab, Open [Login Manager]
Go to [Convenience] tab, Click on [Enable Auto-Login] checkbox,
Choose non administrative user

Friday, January 15, 2016

Stuck in Cobbler profile list, CentOS

I have booted into Cobbler list by when i select profile and hit [Enter] then nothing happens. Only screen blanks for second and it returns to very same cobbler menu screen.

Turns out it can be easily solved by disabling SE linux:
setenforce 0
sed -i "s/^SELINUX=.*$/SELINUX=disabled/" /etc/selinux/config
Another better way to check what actually block the thing:
yum install policycoreutils-python -y
Check SELinux blocked policies:
audit2allow -a | grep -v "===\|^$" | sed -e '/#!!!!/,+1d'
This will probably report:
allow tftpd_t spacewalk_data_t:file read;
Install missing policies:
audit2allow -a -M local && semodule -i local.pp
Execute again profile:

Run again:
audit2allow -a | grep -v "===\|^$" | sed -e '/#!!!!/,+1d'
This will report:
allow tftpd_t spacewalk_data_t:file open;
Install missing policies:
audit2allow -a -M local && semodule -i local.pp
Execute again Cobbler profile. Now it totaly hangs!

Run again:
audit2allow -a | grep -v "===\|^$" | sed -e '/#!!!!/,+1d'
This will report:
allow tftpd_t spacewalk_data_t:file getattr;
Install missing policies:
audit2allow -a -M local && semodule -i local.pp
Hard reboot client and run again cobbler profile.
Works.
Done.

At the end we needed to install these:
allow tftpd_t spacewalk_data_t:file read;
allow tftpd_t spacewalk_data_t:file open;
allow tftpd_t spacewalk_data_t:file getattr;

Thursday, January 14, 2016

CentOS 5, 6, 7 Kickstart Groups, yum groupinstall

For CentOS 7 you can found groups with:
file=$(curl http://mirror.centos.org/centos/7/os/x86_64/repodata/ -s | sed "s/\d034/\n/g" | grep "comps.xml$" | sed "s/^/http:\/\/mirror.centos.org\/centos\/7\/os\/x86_64\/repodata\//")
curl $file > comps7.xml
grep "<name>" comps7.xml | grep -v Support | sed "s/<name>\|<\/name>//g" | sed "s/^[ \t]*//" | sort | uniq
This will output list:
Additional Development
Anaconda Tools
Applications
Backup Client
Backup Server
Base
Basic Web Server
Common NetworkManager submodules
Compatibility Libraries
Compute Node
Conflicts (Client)
Conflicts (ComputeNode)
Conflicts (Server)
Conflicts (Workstation)
Console Internet Tools
Core
Databases
Debugging Tools
Desktop Debugging and Performance Tools
Desktops
Development
Development and Creative Workstation
Development Tools
Directory Client
Directory Server
DNS Name Server
Emacs
E-mail Server
File and Print Server
File and Storage Server
Fonts
FTP Server
GNOME
GNOME Applications
GNOME Desktop
Graphical Administration Tools
Graphics Creation Tools
Guest Agents
Guest Desktop Agents
Hardware Monitoring Utilities
High Availability
Identity Management Server
Infrastructure Server
Input Methods
Internet Applications
Internet Browser
Java Platform
KDE
KDE Applications
KDE Plasma Workspaces
Large Systems Performance
Legacy UNIX Compatibility
Legacy X Window System Compatibility
Load Balancer
Mainframe Access
MariaDB Database Client
MariaDB Database Server
Minimal Install
Multimedia
Network File System Client
Network Infrastructure Server
Networking Tools
Office Suite and Productivity
Performance Tools
Perl for Web
Platform Development
PostgreSQL Database Client
PostgreSQL Database Server
Printing Client
Print Server
Python
Remote Desktop Clients
Remote Management for Linux
Resilient Storage
Security Tools
Servers
Server with GUI
System
System Administration Tools
System Management
Technical Writing
Virtualization
Virtualization Client
Virtualization Host
Virtualization Hypervisor
Virtualization Platform
Virtualization Tools
Web Server
Web Services
Web Servlet Engine
X Window System
For CentOS 6 you can found groups with:
file=$(curl http://mirror.centos.org/centos/6/os/x86_64/repodata/ -s | sed "s/\d034/\n/g" | grep "comps.xml$" | sed "s/^/http:\/\/mirror.centos.org\/centos\/6\/os\/x86_64\/repodata\//")
curl $file > comps6.xml
grep "<name>" comps6.xml | grep -v Support | sed "s/<name>\|<\/name>//g" | sed "s/^[ \t]*//" | sort | uniq
This will output list:
Additional Development
Applications
Backup Client
Backup Server
Base
Base System
Basic legacy X Window System compatibility
CIFS file server
Client management tools
Compatibility libraries
Conflicts (Client)
Conflicts (ComputeNode)
Conflicts (Server)
Conflicts (Workstation)
Console internet tools
Core
Databases
Debugging Tools
Desktop
Desktop Debugging and Performance Tools
Desktop Platform
Desktop Platform Development
Desktops
Development
Development tools
Directory Client
Directory Server
Eclipse
Emacs
E-mail server
FCoE Storage Client
Fonts
FTP server
General Purpose Desktop
Graphical Administration Tools
Graphics Creation Tools
Guest Agents
Hardware monitoring utilities
High Availability
High Availability Management
Identity Management Server
Input Methods
Internet Applications
Internet Browser
iSCSI Storage Client
Java Platform
KDE Desktop
Languages
Large Systems Performance
Legacy UNIX compatibility
Legacy X Window System compatibility
Load Balancer
Mainframe Access
MySQL Database client
MySQL Database server
Network file system client
Network Infrastructure Server
Networking Tools
Network Storage Server
NFS file server
Office Suite and Productivity
Performance Tools
PostgreSQL Database client
PostgreSQL Database server
Printing client
Print Server
Remote Desktop Clients
Resilient Storage
Scalable Filesystems
Scientific support
Security Tools
Server Platform
Server Platform Development
Server Policy
Servers
Smart card support
Storage Availability Tools
System administration tools
System Management
Technical Writing
TeX support
TurboGears application framework
Virtualization
Virtualization Client
Virtualization Platform
Virtualization Tools
Web-Based Enterprise Management
Web Server
Web Services
Web Servlet Engine
Workstation Policy
X Window System
For CentOS 5 you can found groups with:
curl http://mirror.centos.org/centos/5/os/i386/repodata/comps.xml > comps5.xml
grep "<name>" comps5.xml | grep -v Support | sed "s/<name>\|<\/name>//g" | sed "s/^[ \t]*//" | sort | uniq
This will output list:
Administration Tools
Applications
Authoring and Publishing
Base
Base System
Clustering
Cluster Storage
Conflicts
Core
Desktop Environments
Development
Development Libraries
Development Tools
DNS Name Server
Eclipse
Editors
Engineering and Scientific
FTP Server
Games and Entertainment
GNOME Desktop Environment
GNOME Software Development
Graphical Internet
Graphics
HyperV
Java
Java Development
KDE (K Desktop Environment)
KDE Software Development
Languages
Legacy Network Server
Legacy Software Development
Mail Server
Miscellaneous Included Packages
MySQL Database
Network Servers
News Server
Office/Productivity
OpenFabrics Enterprise Distribution
PostgreSQL Database
Ruby
Server Configuration Tools
Servers
Sound and Video
System Tools
Text-based Internet
Virtualization
Web Server
Windows File Server
Xen
X Software Development
X Window System

Extend Raspberry Pi main partition a little bit longer

Take 2015-11-21-raspbian-jessie-lite.img and push to SD card.

After booting into operatation system you can look at the situation by runing:
df -h
This will report:
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.3G  931M  262M  79% /
devtmpfs        214M     0  214M   0% /dev
tmpfs           218M     0  218M   0% /dev/shm
tmpfs           218M  8.4M  209M   4% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           218M     0  218M   0% /sys/fs/cgroup
/dev/mmcblk0p1   60M   20M   41M  34% /boot
As you can see the main partition is just about 1.3Gb.

What if we let it to be a little, little bit longer?

This is possible!

Let's open SD cards master boot record for editing:
sudo fdisk /dev/mmcblk0
This will output:
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):
Lets print the situation of master boot record:
p
This will output:
Disk /dev/mmcblk0: 7.5 GiB, 8026849280 bytes, 15677440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb3c5e39a

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1        8192  131071  122880   60M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      131072 2848767 2717696  1.3G 83 Linux
write down the start sector of second partition which in this case is:
131072
Lets delete the information about how long should be second partition:

Press d to delete partition

Write 2 to delete second partition

Press n to create new partition

Write p for primary

Partition number set 2

Enter 131072 as the first block of second partition and press enter

In next step we will say that the size of partition will be 1536M which stands for 1.5Gb.
Write down +1536M and hit enter.

Press w to write changes

So the output of all this will be:
Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-15677439, default 2048): 131072
Last sector, +sectors or +size{K,M,G,T,P} (131072-15677439, default 15677439): +1536M

Created a new partition 2 of type 'Linux' and of size 1.5 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
Now restart system:
sudo reboot
After restart lets check again the situation:
df -h
This will output pretty much the same. WTFloppy?
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.3G  929M  263M  78% /
devtmpfs        214M     0  214M   0% /dev
tmpfs           218M     0  218M   0% /dev/shm
tmpfs           218M  4.4M  213M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           218M     0  218M   0% /sys/fs/cgroup
/dev/mmcblk0p1   60M   20M   41M  34% /boot
Well actually you have to make the system know that there is a better place to live:
sudo resize2fs /dev/mmcblk0p2
This will output:
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/mmcblk0p2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p2 is now 393216 (4k) blocks long.
Lets check the situation:
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       1.5G  929M  465M  67% /
devtmpfs        214M     0  214M   0% /dev
tmpfs           218M     0  218M   0% /dev/shm
tmpfs           218M  4.4M  213M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           218M     0  218M   0% /sys/fs/cgroup
/dev/mmcblk0p1   60M   20M   41M  34% /boot
Yeah! 1.5Gb! And the dream comes true :)

CentOS 5 kickstart, groupinstall, startx, autologin

Install GNOME Desktop Environment

Add to [Software] -> [Package Groups]
@ Base
@ X Window System
@ GNOME Desktop Environment

Install KDE (K Desktop Environment)

Add to [Software] -> [Package Groups]
@ Base
@ X Window System
@ KDE (K Desktop Environment)

boot-right-into-graphical-interface

Add to [Script] -> [Kickstart Scripts]:
sed -i "s/^id:3:initdefault:/id:5:initdefault:/" /etc/inittab

create-none-administrative-user

Add to [Script] -> [Kickstart Scripts]:
adduser test

auto-log-on-none-administrative-user

Add to [Script] -> [Kickstart Scripts]:
sed -i "s/\[daemon\]/\[daemon\]\nAutomaticLoginEnable=true\nAutomaticLogin=test/" /etc/gdm/custom.conf

auto-system-update

Add to [Script] -> [Kickstart Scripts]:
yum update -y
Reladed:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/s1-kickstart2-packageselection.html

Wednesday, January 13, 2016

Create CentOS 5 base channel, assign repository

Go for [Channels] -> [Manage Software Channels], Click [Create Channel]:

Channel Name:
CentOS 5 Base i386
Channel Label:
centos-5-base-i386
Architecture:
IA-32
Channel Summary
CentOS 5 Base i386
Execute at the command line:
curl http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 > /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 /var/www/html/pub/RPM-GPG-KEY-CentOS-5
gpg --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
This will create content which is needed to use in next steps:
pub  1024D/E8562897 2007-01-06 CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>
      Key fingerprint = 473D 66D5 2122 71FD 51CC  17B1 A8A4 47DC E856 2897
sub  1024g/1E9EA3B6 2007-01-06 [expires: 2017-01-03]
GPG key URL:
http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
GPG key ID
E8562897
GPG key Fingerprint:
473D 66D5 2122 71FD 51CC  17B1 A8A4 47DC E856 2897
Click [Create Channel]

Go for [Channels] -> [Manage Software Channels] -> [Manage Repositories], Click [Create Repository]:
Repository Label
CentOS 5 Base i386
Repository URL
http://mirror.centos.org/centos/5/os/i386/
Click [Create Repository]

Go for [Channels] -> [Manage Software Channels], Open "CentOS 5 Base i386"

For for [Repositories] tab, set checkbox into "CentOS 5 Base i386" repository

Click [Update Repository]

Execute at the command line:
spacewalk-repo-sync -c centos-5-base-i386
If you want to install CentOS 5 in futeure via Kickstart then execute:
spacewalk-repo-sync -c centos-5-base-i386--sync-kickstart

Multiple kernels, grub, free space /boot, CentOS


In this scenario you have to run yum remove and some base number of your kernel:
Now type:
yum remove kernel-2.6.32
This will output:
Loaded plugins: fastestmirror
Setting up Remove Process
Skipping the running kernel: kernel-2.6.32-573.12.1.el6.x86_64
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:2.6.32-504.el6 will be erased
---> Package kernel.x86_64 0:2.6.32-573.8.1.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================
 Package        Arch           Version                      Repository                                        Size
===================================================================================================================
Removing:
 kernel         x86_64         2.6.32-504.el6               @anaconda-CentOS-201410241409.x86_64/6.6         124 M
 kernel         x86_64         2.6.32-573.8.1.el6           @updates                                         126 M

Transaction Summary
===================================================================================================================
Remove        2 Package(s)

Installed size: 250 M
If you look very closely you can see that only two oldest kernels will be removed.

Tuesday, January 12, 2016

Create CentOS 6 kickstart profile, Spacewalk

OK. Then.

If the Base Channel exists and you have successfully added Spacewalk Client child channel then you are ready to go with Kickstart profile creation!

Go for "Systems", Open "Kickstart" menu and select "Profiles". Hit [Create Kickstart Profile]:

Enter Kickstart Label, set Base Chanel and Kickstartable Tree.
In this step you can also fase the problem No Kickstartable Channels found. No Trees were found for the selected channel.

Leave default download location:

Enter root password:

In next step you can face the problem The following packages are not available in any of the channels associated to this kickstart profile: pyOpenSSL, rhnlib, libxml2-python, libxml2, spacewalk-koan*. In order for all kickstart functionality to work correctly, these packages should be present in at least one channel associated to this profile.

If you do not face this problem then you are done!
There are lot of sections now, but you are ready to start PXE boot right now!

Just boot the network and you can see your newly created profile
"CentOS-6-Base-X86_64":

Monday, January 11, 2016

Create CentOS 6 Child Channel, Spacewalk

Create a new Channel:

Fill the fields!

Channel Name:
spacewalk-client-2-5-rhel-6-x86_64
Channel Label:
spacewalk-client-2-5-rhel-6-x86_64
Parent Channel:
CentOS 6 Base x86_64
Architecture:
x86_64
Channel Summary:
spacewalk-client-2-5-rhel-6-x86_64

Scroll down the page and enter:
GPG key URL:
http://yum.spacewalkproject.org/RPM-GPG-KEY-spacewalk-2015
GPG key ID:
B8002DE1
GPG key Fingerprint:
A5FC 508C DD3C C46D 3C3B  4612 DCC9 81CD B800 2DE1
This is the same key from:
curl http://yum.spacewalkproject.org/RPM-GPG-KEY-spacewalk-2015 > /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2015
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2015 /var/www/html/pub/RPM-GPG-KEY-spacewalk-2015
gpg --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-spacewalk-2015
pub  1024D/B8002DE1 2015-04-17 Spacewalk <spacewalk-devel@redhat.com>
      Key fingerprint = A5FC 508C DD3C C46D 3C3B  4612 DCC9 81CD B800 2DE1
Click [Create Channel] at the end

Open [Channels] section, go for [Manage Software Channels],
go for [Manage Repositories], click [Create Repository]

Fill down:
Repository Label:
spacewalk-client-2-5-rhel-6-x86_64
Repository URL:
http://yum.spacewalkproject.org/2.5-client/RHEL/6/x86_64
Click [Create Repository]

Now open your child channel:

Assing child repository to child channel and press [Update Repositories] button:

Now at the command line execute:
spacewalk-repo-sync -c spacewalk-client-2-5-rhel-6-x86_64
Now try again to manage kickstart profile!

Backup Mikrotik RouterOS Configuration

To create a backup of RouterOS configuration do the following steps:

Open [Files] section and press [Backup]

Write down name of backup and click [Backup]. I preffer do not encrypt anything.

Now the backup is located in router internal storage. But you can download it locally:

To restore backup you have to click on backup which you are interested:

And go for [Restore]: