Spacewalk – Bootstrap Script

Spacewalk is a tool for managing linux-servers. Its a very powerful tool which will make your life easyer especally if you have to manage large amounts of servers.

Spacewalk has two ways to add systems to the manager.

The first way is that you install a fresh server and add him to the system. You can add the nescessary steps in the post-install-script.

The second way is to add existing servers to the system. And this is the use case that i have mostly.

So, lets have a look at the nescessary steps we need:

  • Import the SSL-Key of the spacewalk-server
  • Import GPG-keys of non-official repositorys
  • Install the rhn-setup package which provides the binary that makes the regisitration to the spacewalk-server
  • registration to the spacewalk-server
  • Install spacewalk-related packages (for use of remote-commands, executing tasks, controlling package-manager…)
  • disable local repositorys
  • enable remote-commands
  • enable and start osad (task-engine)

I added this to a script and im providing it via the spacewalk-server. Clients can download it from the web interface.

So here is my little script:

cat bootstrap.sh
#!/bin/bash

#import ssl cert from spacewalk

rpm -Uvh http://spacewalk-url/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm

#import gpg key for spacewalk-client-repo

rpm --import http://spacewalk-url/pub/gpg/RPM-GPG-KEY-spacewalk-2.9-client

#import gpg key for epel repo

rpm --import http://spacewalk-url/pub/gpg/RPM-GPG-KEY-EPEL-7

#install nescessary packages

yum -y install rhn-setup

#register client on spacewalk-server

rhnreg_ks --serverUrl=https://spacewalk-url/XMLRPC --sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT --activationkey=1-activationkey

#install spacewalk related packages

yum -y install osad rhncfg-actions rhncfg rhncfg-client yum-rhn-plugin fping screen perl-Frontier-RPC perl-Text-Unidecode

#disable centos original repos

sed -i '/\[base\]/ a enabled=0' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/\[updates\]/ a enabled=0' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/\[extras\]/ a enabled=0' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/epel.repo

#activate remote commands and osa-service

rhn-actions-control --enable-all

systemctl enable osad

systemctl start osad

Linux – Getting Band-in-a-Box 2012 work with wine

Hi,

i just wanted to use Band-in-a-Box 2012 on my Linux Laptop especially with wine because installing it in a virtual machine has a bunch of disadvantages.

For example because you have to load (and unload) a complete OS and in my case get my USB Audio Interface work IN the virtual machine.

So wine is the better option. But my past experiences with wine were not really good 😀

To simplify the complete process, i used Playonlinux. Playonlinux is a “framework” for wine installations.

Its script based, so if you use one of the scripts from the library, it chooses automaticly the best working  wine version, installs additional librarys and so on.

The downside is, that there is no script for BandinaBox 😀

Not cool, but also not dramatic. I used some informations from forums and also winehq.

So how we begin? (please excuse if the instructions are not 100% suitable, but i use it in german language, so the option names may differ a bit)

Prerequirements:

what do you need?:

  • working Playonlinux Installation
  • timidity++ package
  • A File from a working Windows Computer (doesnt matter which version), named “gm.dls”
  • You can find this file here: c:\windows\system32\drivers\gm.dls (or load it from my dropbox account: gm.dls)

Installation:

  • Start Playonlinux, and click install new software.
  • Then you choose  Install a program what is not listed.
  • Choose Install a program in a new virtual drive
  • Give it a name
  • Choose install some librarys
  • Choose 32bit windows installation
  • Choose the “POL_Install_wmp9” library
  • Choose the Installation File, for BiaB2012: bandinabox_realband_2012_full.exe
  • Get through the installation.
  • Things you need to consider: Do the complete installation (its imported), as starter choose “bbw.exe”

Configuration:

So, you got it installed but it wont start.

  • You have to copy the gm.dls file to the “windows/system32/drivers” folder of the wine-prefix. Select the starter of your BiaB Installation and select “open a directory”

Okay, BiaB starts now but it wont play sounds 😀

  • The last step is starting timidity++ before you start BiaB.
  • Here is your command:

timidity -iA -Os -B2,8 &

Then you can start BiaB and it should play sounds and so on.

Gratz! 🙂

WordPress – Changing Permalinks

Hi,

in the net you find tons of posts what changes you have to made if you wanna change your permalinks to postname. But mostly in combination with an apache webserver.

So im using nginx and this is a bit more difficult.

But i found the solution.

Simply add this line to your vhost configuration:


if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}

For apache just place an empty .htaccess file in your wordpress-folder, give it 666 permissions and insert this:


# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Spacewalk – Automatic Creation of a Kickstartable Tree

Spacewalk is a tool for (mainly) managing and provisioning server or client linux-systems.

I’m using for a few months now and yeah. Its not well documented, especially the provisioning part.

Spacewalk uses kickstart as provisioning tool.

You have to add a kickstartable tree. Then make your kickstart distribution and then finally your kickstart profile where you define the properties for your system.

The problem is the kickstartable tree. The documentation says, simple mount a distribution dvd and then use the path where the distro is mounted.

Uhm… no. wont work for CentOS 🙂

I found a script on the net wich dowloads all the distribution files that you need. its name is mkelfs.

The github entry was updated in Nov 2015 but it still works.

Just download it from here: https://github.com/stdevel/mkelfs/blob/master/mkelfs.py

Before you can use the command you have to create the folders in which the script deploys the distro data.

mkdir /var/satellite/kickstart_tree

Here is the command you need for CentOS 7 (dont be suprised, the reason why Centos is not in the parameters is that its a default value 😀 )

./mkelfs.py --release 7 --arch x86_64 -b centos7-x86_64

-b is the name of your base channel

CentOS 7 – Firewalld allow all traffic from a Server

I hate the default firewall in CentOS. 😀

Its so unneeded complicated that a simple Access-Rule seems to be as hard as climbing up the mount everest.

So, my problem was i wanted to configure a CentOS-Server for our backup system. Backup client was installed but the CentOS-Firwall was blocking the traffic.

Our backup-system needs several ports (in range) and communication comes from multiple servers.

But i didnt wanted to allow a port range because of security. So open up traffic for our backup-subnet was the way to go.

Here is the command:

firewall-cmd --permanent --zone=public --direct --add-rule ipv4 filter IN_public_allow 0 -s xx.x.xx.x/xx -j ACCEPT

firewall-cmd --reload

Have fun 😀

KDE4 Lock Screen Background anpassen

Hallo,

wenn ihr unter KDE4 den Standard Screen-Locker eingestellt habt, könnt ihr dort auch ein eigenes Hintergrundbild verwenden.

KDE Plasma < 5.5

Dazu müsst ihr als erstes eurer Image in den entsprechenden Pfad kopieren.

cp Pictures/xxx.jpg /usr/share/kde4/apps/ksmserver/screenlocker/org.kde.passworddialog/contents/ui/

Danach öffnet ihr die Datei main.qml mit eurem favorisierten Editor

und geht zur Image {-Sektion

Dort tauscht ihr die Zeile

source: theme.wallpaperPathForSize(parent.width, parent.height)

durch den Pfad zu eurem Image.

source: xxx.jpg

KDE Plasma 5.5

Bei KDE-Plasma 5.5 funktioniert leider der oben genannten Mechanismus NICHT mehr…

Dort wird einfach folgender Befehl ausgeführt:

kcmshell5 screenlocker

Dort kann man über das Menü ein Bild auswählen.

LSI-Raid Controller Megacli Kommandos

Hallo,

einige meiner Server, die ich betreue, haben LSI-RAID-Controller verbaut. Bei den LSI-Controllern gibt es die Möglichkeit über Linux diese komplett zu Konfigurieren und Abzufragen.
Leider ist das Megacli-Kommando extrem umfangreich und auch sehr unübersichtlich. Daher wollte ich einfach mal ein paar nützliche Kommandos mit euch teilen.

Übersicht der konfigurieren Virtual-Drives und Status

`which megacli` -LDInfo -Lall -aALL

Output:
Virtual Drive: 0 (Target Id: 0)
Name :
RAID Level : Primary-6, Secondary-0, RAID Level Qualifier-3
Size : 9.093 TB
Sector Size : 512
Is VD emulated : No
Parity Size : 3.637 TB
State : Optimal
Strip Size : 256 KB
Number Of Drives : 7
Span Depth : 1
Default Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAhead, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disk's Default
Encryption Type : None
PI type: No PI

Is VD Cached: No

Status aller Festplatten mit den Werten Größe, Backplane, Slot, Firmware Status und Temperatur

`which megacli` -PDList -a0 | grep -e '^Coerced Size:' -e '^Enclosure Device ID:' -e '^Slot Number:' -e '^Firmware state:' -e '^Drive Temperature :'

Output:
Enclosure Device ID: 19
Slot Number: 0
Coerced Size: 1.818 TB [0xe8d00000 Sectors]
Firmware state: Online, Spun Up
Drive Temperature :39C (102.20 F)

Dann hatte ich das Problem, dass ich eine Festplatte getauscht habe, dabei die Global Spare eingesprungen ist und dadurch der Controller angefangen hat zu beepen.
Auch nach dem Rebuild blieb der Alarm. Per megacli kann man diesen auch stumm stellen.

megacli -AdpSetProp -AlarmSilence -aALL

Adapter 0: Set alarm to Silenced success.

Exit Code: 0x00

Man kann auch den Alarm permanent abschalten. Dazu folgendes Kommando:

megacli -AdpSetProp -AlarmDsbl -aALL

Mit folgendem Kommando kann man den Alarm wieder anschalten:

megacli -AdpSetProp -AlarmEnbl -aALL

WordPress XMLRPC Angriff

Hallo,

diesmal etwas in eigener Sache. Und zwar war mein Blog in letzter Zeit öfters down und ich habe mich gefragt, was da los ist.Der Server ging irgendwann in die Knie und warf beim Laden der Seite eine 502 – Bad Gateway Fehler.

Analyse des Angriffs

Im Log des Webservers tauchen folgende Meldungen auf:


/var/log/nginx/access.log

xx.xxx.xx.xxx - - [22/Jan/2015:03:36:59 +0100] "POST /xmlrpc.php HTTP/1.0" 403 529 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
xx.xxx.xx.xxx - - [22/Jan/2015:02:57:50 +0100] "POST /wp-login.php HTTP/1.1" 200 1326 "http://warpdrive-on.de/wp-login.php" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0"

Nach kurzer google-Recherche stellte sich heraus, dass es in den letzten WordPress Versionen eine Sicherheitslücke gibt, und zwar die xmlrpc-Schnittstelle. Darüber können Blogeinträge über externe Programme hinzugefügt werden.

Schließen der Sicherhheitslücke

Da ich diese Möglichkeit sowieso nicht benutze, entschied ich, den Zugriff auf die Datei xmlrpc.php direkt im Webserver zu sperren.

Dies kann im nginx-Webserver in der virtual Host-Konfiguration mit folgendem Eintrag eingestellt werden:


/etc/nginx/sites-enabled/default

location /xmlrpc.php {
deny all;
}

Bot-Zugriffe mit fail2ban blockieren

Damit war das Problem erst einmal behoben. Da ich aber trotzdem noch zahlreiche Seitenaufrufe hatte (die Zahlen hatten nichts mit der Realität zu tun 🙂 ), dachte ich mir, wenn ich grad dabei bin sperre ich diese vermeindlichen Bots auch noch aus. Dazu gibt es die Möglichkeit, diese mit der Software Fail2ban zu blocken.

Als erstes legt man idealerweise im Nginx conf.d Verzeichnis eine Datei bots.map an.


/etc/nginx/conf.d/bots.map

map $http_user_agent $is_bot {
default 0;

~Sogou 1;
~Abonti 1;
~Pixray 1;
~Python 1;
~Spinn3r 1;
~libwww-perl 1;
~Wget 1;
~Curl 1;
~Ezooms 1;
~mShots 1;
~SemrushBot 1;
~Exabot 1;
~ZmEu 1;
~iCjobs 1;
~QuerySeekerSpider 1;
~Baiduspider 1;
~AhrefsBot 1;
~CareerBot 1;
~coccoc 1;
~MJ12bot 1;
~SeznamBot 1;
~spbot 1;
~ShowyouBot 1;
~adressendeutschland 1;
~PagesInventory 1;
~aboutWebSearch 1;
~Java 1;
~JCE 1;
~bitlybot 1;
~WeSEE 1;
~updown_tester 1;
~200PleaseBot 1;
~Nutch 1;
~HTTP_Request 1;
~AnyOther 1;
~Crawler 1;
~BLEXBot 1;
~yacybot 1;
~Cliqzbot 1;
}

Durch das Nginx-Module map wird entschieden, ob ein spezifizierter User-Agent als Bot definiert wird (die Variable $is_bot also als Wert 1 enthält) oder nicht.

Anschließend bindet man man die Datei als Include in die Nginx.conf ein:


/etc/nginx/nginx.conf

http {

include /etc/nginx/conf.d/bots.map;

}

Dann wird noch in der vhost konfiguration abgefragt, ob die is_bot Variable gesetzt ist und wenn ja, wird der Zugriff gesperrt.


/etc/nginx/sites-enabled/default

server {
...

if ( $is_bot ) {
return 444;

}

}

Um hier eine dauerhafte Lösung zu schaffen, sollten bereits abgewiesene Bots dauerhaft gesperrt werden. Dazu wird in Fail2ban eine Ressource angelegt, die das Access-Log des Webservers überwacht und schaut, ob der Statuscode 444 auftaucht. Diese IP-Adressen würden dann blockiert werden.

Zuerst legt man also eine neue Filter-Regel an. Im Verzeichnis /etc/fail2ban/filter.d/ eine Datei nginx-bots.conf angelegt.


/etc/fail2ban/filter.d/nginx-bots.conf

# Fail2Ban configuration file
#
# List of bad requests
#
# Server: Nginx
# Author: Sergej Müller
#

[Definition]

# Option: failregex
# Notes : Detection of 444 requests.
# Values: TEXT
#

failregex = ^ - .+ 444 0 ".+"$

# Option: ignoreregex
# Notes : Regex to ignore.
# Values: TEXT
#

ignoreregex =

Damit die Filterregel auch geladen wird, muss folgendes in der Datei /etc/fail2ban/jail.conf angehängt werden:


/etc/fail2ban/jail.conf

[nginx-bots]

enabled = true
port = http
filter = nginx-bots
logpath = /var/log/nginx/access.log
maxretry = 0
findtime = 86400
bantime = -1


Anschließend sowohl nginx als auch Fail2ban durchstarten und der Anti-Bot-Schutz ist aktiv.

Hinzufügen eines custom-Repositorys in Novell SMT

Hi,

im Novell SMT hat man die Möglichkeit, externe Repositorys anzubinden, die dann genauso gemirrort werden, wie die Repos von Novell selbst auch (zb. SLES 11).
Man muss sich aber vorher im klaren sein, an welche Produkte man das Repo anhängen möchte.

Konkret war es bei uns so, dass wir beim Registrieren der Sles11-Server am SMT ein Repo mit ausrollen wollten, was zb die VMware-Tools enthält.

Zuerst sucht man sich die Produkt-ID des Produkts heraus, mit dem man das Repository ausrollen möchte (z.b Sles11-SP3-x86_64):

smt-list-products

Dann bekommt man eine u.U recht lange Liste an Produkten, in der man sich die ID heraussuchen muss. Sieht dann zb so aus:

| 3890 | SUSE_SLES | 11.3 | x86_64 | – | 5 |

Nun kann man das Repo unter Angabe der URL und ID hinzufügen:

smt-setup-custom-repos –productid 3890 –name ‘Blablubb-Repo’ –exturl ‘http://blablubb.org’

Das Repository wird dann beim Registrieren eines SLES11-Sp3-Clients mit hinzugefügt.

Targetcli Skript

Hi,

wenn man einen Standard-Linux-Server zur Bereitstellung von Speicher per Fibre-Channel nutzen möchte, kann man das Tool Targetcli benutzen.
Ich habe ein Skript zum Konfigurieren eines Fibre-Channel Targets auf einem Linux Host geschrieben.
Nachdem das Target angelegt ist, soll eine Lun angelegt werden und die entsprechend gezonten Server Zugriff erhalten.

Hinweis: Hier wird ein Qlogic 2562 HBA verwendet. Dieser funktioniert mit targetcli sehr gut.

addfclun.sh

#!/bin/bash
port1=`targetcli “/qla2xxx/ info” |awk ‘/Allowed WWNs list/’ |cut -d’:’ -f2 |awk -F’,’ ‘{print $1}’|cut -c2-21`
port2=`targetcli “/qla2xxx/ info” |awk ‘/Allowed WWNs list/’ |cut -d’:’ -f2 |awk -F’,’ ‘{print $2}’|cut -c2-21`

function createtarget {
targetcli /qla2xxx create $port1
targetcli /qla2xxx create $port2
}
function createlun {
read -p “Bitte den Namen der Lun angeben: ” lunname
ls /dev/mapper
read -p “Bitte Logical-Volume angeben (voller Pfad): ” lv
targetcli /backstores/block create $lunname $lv
targetcli /qla2xxx/$port1/luns create /backstores/block/$lunname
targetcli /qla2xxx/$port2/luns create /backstores/block/$lunname
}
function maplun {
read -p “Bitte die WWN des ersten Ports des anzubindenden Servers angeben: ” wwn1
targetcli /qla2xxx/$port1/acls create $wwn1
read -p “Bitte die WWN des zweiten Ports des anzubindenden Servers angeben: ” wwn2
targetcli /qla2xxx/$port2/acls create $wwn2
}

PS3=”Auswahl: ”
echo “Was moechten sie tun: ”
select aufgabe in “Target anlegen” “Lun anlegen” “Lun mappen” “beenden”;
do
case $aufgabe in
“Target anlegen”) createtarget;;
“Lun anlegen”) createlun ;;
“Lun mappen”) maplun ;;
“beenden”) break;;
esac
done