Writing nested Systemd Scripts

The trick here is to use a dummy program to start the wrapper and hold them active after the program was terminated.

dummy-master.service

[Unit]
Description=Dummy Master Service

[Service]
# The dummy program will exit
Type=oneshot
# Execute a dummy program
ExecStart=/bin/true
# This service shall be considered active after start
RemainAfterExit=yes

[Install]
# Components of this application should be started at boot time
WantedBy=multi-user.target

dummy-db.service

[Unit]
Description=Dummy Database
# When systemd stops or restarts the dummy-master.service, the action is propagated to this unit
PartOf=dummy-master.service
# Start this unit after the dummy-master.service start
After=dummy-master.service

[Service]
User=dummyuser
Type=forking
# Pretend that the component is running
ExecStart=/usr/local/database.sh start
ExecStop=/usr/local/database.sh stop
# Restart the service on non-zero exit code when terminated by a signal other than SIGHUP, SIGINT, SIGTERM or SIGPIPE
Restart=on-failure

[Install]
# This unit should start when app.service is starting
WantedBy=dummy-master.service

dummy-listener.service

[Unit]
Description=Dummy Listener
# When systemd stops or restarts the dummy-master.service, the action is propagated to this unit
PartOf=dummy-master.service
# Start this unit after the dummy-master.service start
After=dummy-master.service
After=dummy-db.service

[Service]
User=dummyuser
Type=forking
# Pretend that the component is running
ExecStart=/usr/local/listener.sh start
ExecStop=/usr/local/listener.sh stop
# Restart the service on non-zero exit code when terminated by a signal other than SIGHUP, SIGINT, SIGTERM or SIGPIPE
Restart=on-failure

[Install]
# This unit should start when dummy-master.service is starting
WantedBy=dummy-master.service

dummy-cron.service

[Unit]
Description=Dummy Cron
# When systemd stops or restarts the dummy-master.service, the action is propagated to this unit
PartOf=dummy-master.service
# Start this unit after the dummy-master.service start
After=dummy-master.service
After=dummy-listener.service

[Service]
User=dummyuser
Type=forking
# Pretend that the component is running
ExecStart=/usr/local/cron.sh start
ExecStop=/usr/local/cron.sh stop
# Restart the service on non-zero exit code when terminated by a signal other than SIGHUP, SIGINT, SIGTERM or SIGPIPE
Restart=on-failure
RemainAfterExit=yes

[Install]
# This unit should start when dummy-master.service is starting
WantedBy=dummy-master.service

After defining the related services, you have to enable all of them.

systemctl enable dummy-master dummy-db dummy-listener dummy-cron

Now you can control the whole workflow with one systemd script:

systemctl start|stop|status dummy-master

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! 🙂

Dell iDrac – Fixing SSL Problem

Hi,

i got two Dell R710 servers which have the problem, that if you wanna open the iDrac web interface, google chrome gives you the error:

ERR_SSL_SERVER_CERT_BAD_FORMAT

its not the usual “hey you got a self signed certificate, its not cool, but you can pass” error ;D this error wont let you open the website.

You can fix this by the following steps:

  • Open a ssh connection to the corresponding iDrac (use the same password as for the webinterface)

ssh root@idrac-ip

  • Regenerate the certifcate

/admin1-> racadm sslresetcfg
Certificate regenerated successfully and webserver restarted

  • Reset the iDrac

/admin1-> racadm racreset soft
RAC reset operation initiated successfully. It may take up to a minute
for the RAC to come back online again.

 

and youre done!

Archlinux – Set Vim Alias

On Archlinux, you got the problem that even if you install vim, you have to type vim to open files with vim.

But normally you want to type vi and open the file with vim – as you know from other distributions.

The solution is setting a symbolic link, but its easyer on arch.

Just install the vi-vim-symlink Package from AUR

Now you got your symlink even without logging out.

Scalar i6000 – Connect to the Webinterface

I got issues connecting to the Webinteface of our Scalar i6000.

Its java based and the problem is that it is designed for java version 1.6.

That means that if your’e using lets say java 1.8, there will be errors that prevents the execution of the applet.

So i found out that there are two main problems:


java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:799)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:728)
at sun.applet.AppletPanel.run(AppletPanel.java:378)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.home" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1294)
at java.lang.System.getProperty(System.java:717)
at com.adic.amc.lm.client.LM3Applet.(LM3Applet.java:35)
... 9 more


java.security.AccessControlException: access denied ("java.security.SecurityPermission" "setProperty.networkaddress.cache.ttl")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkSecurityAccess(SecurityManager.java:1759)
at java.security.Security.check(Security.java:854)
at java.security.Security.setProperty(Security.java:792)
at com.adic.amc.lm.client.LM3Applet.init(LM3Applet.java:57)
at sun.applet.AppletPanel.run(AppletPanel.java:434)
at java.lang.Thread.run(Thread.java:748)

You see java has a problem with AccessControl of
“java.util.PropertyPermission” “user.home” “read”
and “java.security.SecurityPermission” “setProperty.networkaddress.cache.ttl”

The solution is pretty simple.

Java has a file in which permissions are controlled. In my system (archlinux), its located here:

/etc/java-jdk8/security/java.policy

Maybe in your system the file can be located otherwhere, so just use find oder locate.

I made two entrys in the grant-section in it:

grant {
...
permission java.util.PropertyPermission "user.home", "read";
permission java.security.AllPermission;
...
}

The the applet loads and you dont have to install a old java version 🙂

Xfce4 – Save Display Settings

Hi,

Xfce4 is relatively good in dynamically setting your Display Settings if you use multiple Monitors or plugging in Beamers or so.

But sometimes it confuses the configuration.

Therefor you can save your settings if you copy the xml file where the options are written in and replace the confused config with the saved config.

you can find the configuration file here:

.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml

Copy the file to your preferred location.

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