23. December 2017

Courier: 556 Address unavailable

Courier Mail Server has many interesting features. One of the features is support for backscatter blacklist. It helps to protect the server from receiving emails which are not possible to deliver (e.g. in case of some problems with recipient’s account).

The common error message in that case is:

Courier: 556 Address unavailable

It’s not very straightforward how should an administrator resolve error 556. Even after fix of user’s account configuration, the message might appear and the Courier won’t accept an email even after restart. It could be even more confusing when Courier accepts email from some subnets, but it returns 556 Address unavailable on other subnets.

The resolution of the problem is simple: fix backscatter database.

Display list of addresses with on backscatter blacklist:

courier show all

Remove problematic address from the list:

courier clear user@domain

You can remove all addresses:

courier clear all

You can find more about backscatter blacklist in Courier’s documentation.

23. December 2017

How to start all SAP services on openSUSE

The default installation of SAP Netweaver AS ABAP Developer Edition on openSUSE might not start all services after a reboot.

An indication of the problem: port 3300 is not open. After an attempt to connect from SAP Logon you’ll get following error:

WSAECONNREFUSED: Connection refused

When you logon to the system with SAP you may see that some of SAP processes are running, but not all of them:

root      1471  0.0  0.1 172524 10772 ?        Sl   09:01   0:00 /usr/sap/hostctrl/exe/saphostexec pf=/usr/sap/hostctrl/exe/host_profile
sapadm    1521  0.0  0.0  36892  4700 ?        Ss   09:01   0:00 /usr/lib/systemd/systemd --user
sapadm    1526  0.0  0.0  86200  1716 ?        S    09:01   0:00 (sd-pam)
sapadm    1536  0.1  0.3 348208 32260 ?        Ssl  09:01   0:00 /usr/sap/hostctrl/exe/sapstartsrv pf=/usr/sap/hostctrl/exe/host_profile -D
root      1625  0.0  0.0  25568  5316 ?        Ss   09:01   0:00 /usr/sap/hostctrl/exe/saposcol -l -w60 pf=/usr/sap/hostctrl/exe/host_profile
npladm    1889  0.2  1.1 661916 92220 ?        Ssl  09:01   0:00 /usr/sap/NPL/D00/exe/sapstartsrv pf=/usr/sap/NPL/SYS/profile/NPL_D00_georgik -D -u npladm
npladm    2069  0.0  1.1 661304 89420 ?        Ssl  09:01   0:00 /usr/sap/NPL/ASCS01/exe/sapstartsrv pf=/usr/sap/NPL/SYS/profile/NPL_ASCS01_georgik -D -u npladm

As you can see there are two system accounts running on the system: sapadm, npladm. NPL is in my case System ID. The start command should be executed under npladm identity.

Launch following command as root of the system (change npladm to you own System ID):

su -c "startsap all" -l npladm

The system will start with following messages displayed in the console:

Checking syb Database
-------------------------------------------
starting database NPL ...
Log file: /sybase/NPL/startdb.log
parse level 0: identified message 'Database 'master' is now online.'
parse level 1: identified message 'Database 'tempdb' is now online.'
parse level 2: identified message 'Database 'sybsystemprocs' is now online.'
parse level 3: identified message 'Recovery complete.'
Recovery Complete
startdb completed successfully
Starting Startup Agent sapstartsrv
OK
Instance Service on host georgik started
-------------------------------------------
starting SAP Instance ASCS01
Startup-Log is written to /home/npladm/startsap_ASCS01.log
-------------------------------------------
/usr/sap/NPL/ASCS01/exe/sapcontrol -prot NI_HTTP -nr 01 -function Start
Instance on host rihy started
Starting Startup Agent sapstartsrv
OK
Instance Service on host rihy started
-------------------------------------------
starting SAP Instance D00
Startup-Log is written to /home/npladm/startsap_D00.log
-------------------------------------------
/usr/sap/NPL/D00/exe/sapcontrol -prot NI_HTTP -nr 00 -function Start
Instance on host georgik started

You can check whether port 3300 is open:

netstat -anp | grep 3300
tcp        0      0 0.0.0.0:3300            0.0.0.0:*               LISTEN      20212/gwrd

You should be able logon to the SAP on openSUSE without a problem.

If you’re still not able to access the machine from remote then it’s necessary to check the firewall configuration. openSUSE has a strict firewall when using default installation.

You can change firewall configuration by the command:

yast2 firewall

22. October 2017

SDL2_image for iOS with JPEG image format

Adding SDL2_image with JPEG support for iOS is a little bit different than for Android. In case of Android, it was necessary to add JPEG library in C and build it. iOS has JPEG dependency hidden in another library which is already compiled in frameworks.

If you just add SDL2_image to your project for iOS, you will very likely end up with following linker error:

"_kUTTypeJPEG", referenced from ...
Linker command failed with exit code 1

To resolve this issue, it is sufficient to add two dependencies into your project.

Go to Project and select Build Phases.

In the section Linking add library: ImageIO.framework

Then add the second dependency: MobileCoreServices.framework

Then Clean and Build the project.

These steps should resolve the linker issue, and JPEG should work.

4. October 2017

Webpack: How to read version from file and render it into React web

Imagine the simple scenario.The string with version is stored in the file, and it is necessary to transport it from the file into a React application using Webpack.

The solution is relatively simple.

The whole idea is to execute child process which will read the file and transfers the content via variable into the application.

You will need DefinePlugin which allows defining a custom variable and transports it into the transpiler.

Update your package.json and add there

new webpack.DefinePlugin({
   __VERSION__: JSON.stringify('1.2.3')
})

Update your compoents to render the version:

... {__VERSION__} ...

Check the application and you should see there version 1.2.3.

Let’s move further and read a value from the file version.txt. You will need child_process. Add following line to package.json:

const childProcess = require('child_process');

Now update our previous code to read the value from the file. It is necessary to wrap the output into JSON.stringify otherwise you won’t be able to render the version properly.

new webpack.DefinePlugin({
   __VERSION__: JSON.stringify(childProcess.execSync('cat version.txt').toString())
})

This command will invoke the cat command and the output of the command will be set to variable.

If you want a little bit more portable version of the script, then use ShellJS instead of a plain cat.

The code with ShellJS will look like this:

cons shell = require('shelljs');

new webpack.DefinePlugin({
   __VERSION__: JSON.stringify(shell.cat('version.txt').toString())
})

1. October 2017

Missing Run or Debug action in Android Studio with Gradle project

Imagine the simple situation. You want to open an Android project in Android Studio.

Click File, Open. Find the project and click Ok.

Android Studio will open the project. Gradle seems to be working, but there is no Run or Debug action.

Android Studio does not provide any hint where is the issue.

The solution is simple. One important file is missing: settings.gradle. The file defines which modules should be included during the build.

To fix the issue just create settings.gradle in the root of your project:

include ':app'

Click Sync Gradle and within few moments you should be able to run the application.

If your application contains more modules, you can specify them in a similar way like in sdl2-android-example/settings.gradle.