Monday, April 4, 2016

GPG Sharing encrypted files

Occasionally you want to share a secret file, be it a password, or some credentials, or even somethings else with colleague(s) over the unsecure internet or via Email.

gpg is a useful program for achieving this but it does require you to have the public key of the person you are intending to encrypt the file for, or a shared public key to which everyone has the private one.


You ENCRYPT: gpg -z0 --output message.gpg --encrypt --recipient “Person-B" message.txt
Colleague DECRYPT: gpg --output message --decrypt message.gpg

Sunday, March 20, 2016

Making Live CDs with latest updates

Not too long back I bought a new laptop, and as always needed to put my favourite Linux OS on it to keep ahead of the enterprise version.  If you haven't guessed I'm referring to Fedora.  Being about 3 years ahead of what is about to hit RedHat is extremely useful.

However the laptop that I decided to buy, from pcspecialist looked like a Mac Airbook, or whatever they call their slimest one, but with the latest and greatest faster i7 6th Gen processor, etc.  So in short far superior to the Apple, but less than 1/2 the price at £620.

When it arrived, it was excellent - F23 installed, but after a short while it started to hang if it was stressed, so diverted over to Elementary OS, which although pretty, was a little old from a Kernel perspective and lacking some features.

Last weekend I had some time to sit down, since F23 wouldn't run as a Live USB stick from download I decided to build my own spin.  I've been building kickstart systems for a very long time, especially over networks and also on DVDs, however in recent times the process has changed a little since you can't get the entire OS DVD, but have to create a live one.

So using some useful sites around livecd-tools decided to install it and create F23 spin with all of the latest updates taken from rpmfusion.  Here is how it is done on a Fedora system;

1.Install livecd-tools
    1. sudo dnf -y install livecd-tools fedora-kickstarts
      1. The fedora-kickstarts will provide the basis for your files to build the livecd
2. Create a directory to perform the work and store your final ISO image
    1. mkdir -p $HOME/livecds/fc23
      1. I've added fc23 so that I can build different versions
    2. I also created a script called $HOME/livecds/livecd so that I don't have to remember the options;

#!/bin/bash

# URL location
# https://fedoraproject.org/wiki/How_to_create_and_use_a_Live_CD
if (( $# < 3 ))
then
  echo "Syntax: $0 " >&2
  exit 1
fi

pathToKickstartFileks="$1"
tmpcacheLocation="$2"
cdLabel="$3"

livecd-creator --verbose --config="$pathToKickstartFileks" --fslabel="CDLabel" \
--cache="$tmpcacheLocation"

3. The main element to creating a live CD with the latest kernel, etc is to include the repositories of rpmfusion, and to add the necessary packages to the kickstart file.
  1. Copy the example kickstart base file for Fedora 23 so that you can modify it;
    1. cp /usr/share/spin-kickstarts/fedora-live-workstation.ks $HOME/livecds/fc23
  2. Modify the kickstart file, changing the following to make it fit on an 8GB USB
    1. part / --size 8192  --fstype ext4 --grow
      1. The original only allows for a 4GB and doesn't have grow
    2. Under the %packages section you can add your extra Groups or individual packages that you need.  Note if you are adding a group then something like "Development tools" should be written as development-tools
    3. If you don't want a package then precede it with a hyphen (-)
      1. e.g. -shotwell
    4. You will also notice in this file the line;
      1. %include fedora-repo.ks
      2. Create this file with the following for F23, change version based on OS
repo --name=fedora --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-23&arch=$basearch
repo --name=fedora-updates --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f23&arch=$basearch
repo --name=fpmfusionfreerawhide --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-rawhide&arch=$basearch
repo --name=rpmfusionnonfreerawhide --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-rawhide&arch=$basearch
repo --name=rpmfusionfree --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-23&arch=$basearch
repo --name=rpmfusionfreeupdates --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-updates-released-23&arch=$basearch
repo --name=rpmfusionnonfree --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-23&arch=$basearch
repo --name=rpmfusionnonfreeupdate --mirrorlist=http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-updates-released-23&arch=$basearch
repo --name=google --baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64

You'll note that I've also included Chrome.  Each repo is one complete line.  The key ones are the rpmfusion and the updates so that we get the latest and greatest software installed.

4. To build the ISO image simply run your livecd script from within the F23 directory;
  1. $HOME/livecds/livecd ../fedora-live-base.ks ../cache F23-livecd
    1. This command then connects with the relevant repositories to download the rpms and builds the DVD ISO image
    2. You should watch the early output since it will tell you if you have any mistakes with package names or groups
5. Finally put the image on to you USB stick with;
  1. dd if=F23-livecd.iso of=/dev/sdd
    1. Where /dev/sdd should be changed to your USB drive
    2. If you don't know how to find out then;
      1. df -h
        1. Get a list of all the Filesystems
      2. Insert the USB stick
        1. df -h
        2. Look for the Filesystems that was not their previously
      3. Unmount the USB stick so you can write to it with dd
        1. sudo umount /dev/sdd

Troubleshooting

In most cases you are likely to see the following error if the partition size in the kickstart file is not large enough for the image.  If this is the case you will see;
Error creating Live CD : Unable to install: Could not run transaction.
Unmounting directory /var/tmp/imgcreate-vo3YLW/install_root
Losetup remove /dev/loop1
In the above case you should increase the part --size until the error no longer appears.

If you have an incorrect package you will see something like;
Retrieving http://www.mirrorservice.org/sites/download1.rpmfusion.org/nonfree/fedora/updates/testing/23/x86_64/repodata/d5d34f8bad2e14babefd4ff808715d34cdd5637475759a76c58852f211892340-primary.sqlite.xz ...OK
Skipping missing group 'Web Server'
Edit the fedora-live-base.ks file and modify the name in the %package section.

Sunday, November 8, 2015

PCSpecialist Lafite II - Fedora 22 - Backlight fixed

I recently purchased the Lafite II from PCSpecialist  with a high spec;
- i7-6500U
- Intel 520 Core Skylake integrated graphics
- 8GB Ram
- 250GB Samsung 850 EVO SSD, SATA 6GB/s (540MBs R/520MBs W)

URL: http://www.pcspecialist.co.uk/notebooks/lafiteII/

This laptop uses the same Aluminimum chassis as the Apple MacBook 13.3, but the spec of the internals is obviously way more than that of the Apple and for 1/2 the price of their top spec.  Given that Apple still only use an inferior i5 processor (4th Gen) and not even an i7, this laptop is far superior.

I got it to run Linux as I always do, and in this case Fedora 22.  Installing F22 was the easiest install ever, and with the SSD doesn't take hours to do the fsck that it does on standard hard disks.  After installing from a live USB version of the OS the only extras required were;

  1. Tether my phone to the laptop to do an update so that the wireless driver installed.  The base image for the live image does not include the wireless driver, and there is no ethernet connector unless you by a USB adapter (which I have for the USB 3.1 port).
  2. The only other issue, even after the update was the screen brightness, which can be fixed through grub by adding the following;
    1. Edit the file /etc/default/grub
      GRUB_CMDLINE_LINUX="rhgb quiet acpi_backlight=vendor i915.preliminary_hw_support=1"
    2. Run the following command to update the boot loader;
      grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
After that the laptop is fully working, with all buttons.  The HDMI port though needs to be connected on boot to make it work with an external screen.  I also purchased HDMI to VGA connector since I have to connect to projectors that are so out of date, and also a mic/headphone combo cable.  The 3 cables (includes the ethernet/3 USB connector) were purchased from Amazon for less than £20.

Makes those of you with an Apple look like you are using something from the 1950s ;-)


Tuesday, August 11, 2015

Setting the keyboard and language RHEL and CentOS 7 command line

Setting the console keyboard RHEL and CentOS 7

When transferring VMs and systems built in one locale to another the keyboards become a problem.  In the earlier versions of Linux we simply changed a symlink or edited the /etc/sysconfig/keyboard file, but as of version 7 we now have to use localectl or edit the correct files to make the change permanent.

Having read various pages scattered across the Internet a lot of them talk about using the localectl command to change your keyboard and locale settings for a console installation.  However, the localectl command did not update the console keyboard and things such as the | key didn't work when changing from UK to US locale.  Even after a reboot the keyboard would still be wrong.

So how do you get the keyboard changed for the console in RHEL and CentOS 7 permanently?

Persistant Changing The Keyboard and Locale

Here we will assume that the system is currently set to en_GB.UTF-8 and uk keyboard.

1. Edit the /etc/locale.conf file and make sure the following is in it;
LANG="en_US.utf8"

2. Edit the /boot/grub2/grub.cfg file and change
vconsole.keymap=uk    change to    vconsole.keymap=us
Do that for all occurrences, a quick method is;
sed -i 's/vconsole.keymap=uk/vconsole.keymap=us/g' /boot/grub2/grub.cfg

3. Edit /etc/sysconfig/grub and change
vconsole.keymap=uk    change to     vconsole.keymap=us
Like step 2 you can use sed to perform the change as follows;
sed -i 's/vconsole.keymap=uk/vconsole.keymap=us/g' /etc/sysconfig/grub

By doing these steps and then rebooting your system your keyboard and locale would set itself to the new locals for the console.

Sunday, August 9, 2015

Fedora 22 - What a mess!!!!

Well, having done the fedup upgrade, and a fresh install of Fedora 22, I must say I am extremely disappointed.  It's like having taken a backward step into the dark ages of the early days of Sun OS (when they used to re-write the OS from scratch).  What did you do guys?  Fedora 20 was the easiest and by far the fastest of the versions to date, both to install and to use.  Today I have lost days trying to get Fedora 22 to work from my nice stable Fedora 20, and boy have you messed it up.  Are you trying to lose people to the Debian side?  I hope you don't try to put any of this into RHEL 8 otherwise you'll lose them a major market share.

The problems;
1. First WTF - you do an fsck on every partition and disk, making us wait days before we can go and select the disks we want to use for the installation.  There are many complaints I see out their about slow installations and people blaming anaconda for kernel issues, when clearly you decide to run an fsck on every disk and partition.  I have 1TB of  disk space partitioned across about 6 or so partitions, this took nearly 1 hour before I could continue the install, and only found out by monitoring the processes and running strace on what you were doing.  COME ON - we're supposed to install sub 20 minutes, not take 3 hours to do an install.

RECOMMENDATION: Shoot the person who created the new installer.  Do they work for Microsoft or something?  A spy in the camp perhaps?

2. The fedup upgrade messed up the audio big time.  Instead of being able to plug in and out a head set I find that the audio recording works fine as long as you don't plug in an external headset, or unplug it if you booted it with the headset in.  The weird thing is that when you do this it for some reason decides to only record the last second or so of what you recorded last!  Another WTF moment, when Fedora 20 worked perfectly fine with plugging in and out a headset between the built-in and external jack sockets.
I'm still working on what the cause of this is, since I have to remember to boot my system with the headset in if I want to use it for recording or using skype, since as soon as I unplug I have no microphone capability.  The output audio is working (but only after installing from scratch).
This is without mentioning the freezes and hard reboots.

RECOMMENDATION: Use the driver code that worked previously for older kit, and add to it, not destroy it.

3. Although FedUp is a nice way of getting your system up to date, it unfortunately has the same problems as with any upgrade - existing files.  I'm a stickler and even more so for keeping my system config files in a directory of their own and symlinking to them.  So that way I can do a fresh update and a diff if need be to work in the new, and of course a good partitioning scheme.

4. Slow start up and shutdown.  Another backward step, thanks guys.  How slow do you really want this system to be?  I'm using an SSD and F20 came up faster and shutdown a lot quicker (apart from the pulse audio process that would take ages to stop if you didn't log out before shutting down).  Now, I don't know what you're doing, but come on, if the system doesn't shutdown in less than 30 seconds I want to know what you're playing at.

5. The Live image is a nice image, although takes ages to start up from USB, and too long for the installer, but it works nicely with audio and everything.  So why when I install it does it then break everything?

  • I'm forced to create a new user as any old GNOME configs cause the log in screen to break, that's if you can get to the login screen.
  • The login screen might not even appear - until after you update the system, which you have to do from single user mode since the whole damn system hangs at the login screen or before.
  • After the update you can eventually get to the login screen, and start to get your system working, but don't take any of your old GNOME config, apart from specific applications
What I want to know is why you don't just transfer the working image directly to the hard disk?  If it works on the USB it should work exactly the same after I install to hard disk.  But oh, no.


On going work
Only a few points so far, as I've only just got 22 working today from a fresh install, and so far NOT impressed.  If the developers at Fedora keep going in this direction I will almost likely move to Debian, which for me would be a nightmare as since 1996 I've been a RedHat fan and promoted it everywhere with its stability and resilience, but all of a sudden we seem to be leaking crap into the development of the system and as an S.A. and infrastructure builder, would not currently be encouraging people to use the next RHEL 8 (if it's going to be based on this) into their environments.

Be warned!
So a warning to you all, don't believe what these magazine writers (online or otherwise) tell you.  If you do this stuff for real and use it every day for your main operating system, I would give F22 a miss, and wait until they can make it faster, other wise like me you will lose a day and a half of your life debugging the crap that has recently made the best operating system one that will quickly slip away if it continues on this path.

Update as of 1st September 2015
Having had F22 running for a few weeks now I've swapped gdm for kdm, and as per F20 improved boot up and shutdown speeds immensely. GDM has become so complex that the speed of start up and shutdown is painful. For those of you wanting to get back to an O/S that boots up and shutdown faster than windows or mac then i recommend changing to GDM but still using gnome for its features.

Saturday, July 4, 2015

XBMC iPlayer and other tv

Scenario

In this page I  will take you through getting iPlayer working in XBMC through the chromium web browser in full screen mode with audio.
BBC have decided that the public funding doesn't warrant them providing their services to those who use other types of computer systems to access the public service that they should be providing (shame on you BBC. I don't know why we have to pay you so much money,  it's disgusting). These include XBMC, and many other 3rd party applications.
The good news is that web browsers are still valid.
Another problem is that Adobe (most likely being paid by the beeb) are stopping support of flash played for Linux.  Don't they realise there is a growing trend of people using linux and it's only getting bigger?
This page is mainly for those using the XBMC o/s, but may contain useful elements if you've installed it on other operating systems (o/s).
Note that this method can be used for any of the on demand sites.

Requirements

  • XBMC plugin Advanced Launcher
  • pepper plugin for the o/s (to get flash audio working)
  • chromium-browser
  • wrapper script to stay chromium in XBMC nicely
  • http://www.bbc.co.uk/iplayer, or any other urls you want to view

Download and install Advanced Launcher

Download the plugin from:
http://ftp.heanet.ie/mirrors/xbmc/addons/eden/plugin.program.advanced.launcher/plugin.program.advanced.launcher-1.7.6.zip

Install the plugin through XBMC using the install from zip file through System -> Add-ons

Adobe Flash plugin is no longer being supported on Linux platforms so you need to obtain the pepper player flash plugin for chromium.  This can be done using apt-get as follows;

Install package with;
    sudo apt-get install

Install for chromium with;
  sudo apt-get install pepperflashplugin-nonfree
  sudo update-pepperflashplugin-nonfree --install

Wrapper scripts to run chromium within XBMC

I wrote 2 scripts to make it possible to run the web browser through XBMC without having to exit to a different window manager. I set various options with chromium to make it run in full screen mode. The key difference between the two scripts is whether we want the address bar or not. You will need to access the command line on your XBMC system for this,  which you can do with CTRL+ALT+F2. You will then be asked to login in. You will need to know the user and password that was created during install. I created a directory called bin in that users home directory and put the scripts in their.

Full screen kiosk mode script,  called browser.sh (remember to chmod +x browser.sh after creating);

#!/bin/bash
CHROMIUM_FLAGS=""
flashso="/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so"
flashversion=`strings $flashso|grep ^LNX|sed -e "s/^LNX //"|sed -e "s/,/./g"`
CHROMIUM_FLAGS="$CHROMIUM_FLAGS --ppapi-flash-path=$flashso --ppapi-flash-version=$flashversion"
openbox &
/usr/bin/chromium-browser --start-maximized --disable-new-tab-first-run --no-default-browser-check --no-first-run --kiosk $CHROMIUM_FLAGS $*
killall -9 openbox

Full screen with address bar, called browser-nonfull.sh;
#!/bin/bash
CHROMIUM_FLAGS=""
flashso="/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so"
flashversion=`strings $flashso|grep ^LNX|sed -e "s/^LNX //"|sed -e "s/,/./g"`
CHROMIUM_FLAGS="$CHROMIUM_FLAGS --ppapi-flash-path=$flashso --ppapi-flash-version=$flashversion"
openbox &
/usr/bin/chromium-browser --start-maximized --disable-new-tab-first-run --no-default-browser-check --no-first-run $CHROMIUM_FLAGS $*
#/usr/bin/firefox
killall -9 openbox

Adding the scripts directory as a source

You must make your bin directory available to the Advanced Launcher so that you can use your scripts.
  • Select Advanced Launcher
  • Right click Default
  • Select Manage Sources
  • Select Add Source
  • Select Browse and locate your bin directory

Creating the menu items

Create the menu items to launch the web browser with the right  starting page using the advanced launcher. Since we used the $* in the scripts we can pass extra parameters of which one is the url we require.
To do this go to the Programs menu in XBMC.
  • Select Advanced Launcher
  • Using the mouse right click the Default
  • Select add new launcher
  • Select standalone (in my example below it is the xbmc-scripts)
  • Locate your script.
  • Provide any arguments, e.g. the url, such as http://www.bbc.co.uk/iplayer
  • Give the program a name, e.g. BBC iPlayer
  • Select Linux as the operating system
  • Select ok for the next 2 items which are thumbnails and fanarts
  • The final link
You now have a link that will start iPlayer in a web browser and goes straight to the web page. You will however still need a keyboard and mouse since applications don't use the remote. On the upside you do have access to lots of other online services that are retorted as broken in XBMC or Kodi.

One thing you need to be aware of though, is that the audio will take a little while to become available as XBMC likes to work out that it's not using it and then lets the web browser use it.  This can take several minutes, so be patient.

Thursday, June 18, 2015

Red Hat 6 to Red Hat 7 system start up configuration

The Linux start up sequence for many years had been a hybrid of BSD and SVR4 stay up files. These files consisted of the /etc/inittab, /etc/rc.local and the /etc/init.d/* and /etc/rc[0-6].d/* locations. The sequence was sequential and in most cases required each command to complete before moving on to the next. Debian based systems atempted to tackle this issue and sped up the start up process by introducing upstart which enabled milestones and dependencies, but was cumbersome and not as effective as the Solaris 10 start up method. Red Hat 7 took its startup sequence from the Fedora project, with Fedora 18 and 19 making the change to systemd which by Fedora 20 was firmly in place and saw the demize of the old mechanism, but like Red Hat 7 still allows the old style SVR4 scripts to be used.
In the rest of this document I will take you through the necesary changes from v6 to v7 start up, covering;
  • Essential commands to start and stop services
  • Commands to disable or enable a service at boot
  • How to change the default run level
  • How to configure your own boot script

Essential service commands

In this section we will look at how you start, stop and view the status services in Red Hat 7.

Starting a service Red Hat 6

The service command in Red Hat 6 is used to control daemon process and associated files, such as the pid file, subdydtem lock file and others. In the event that a service (daemon) terminates unexpectedly these files remain in place as a foot print to let us know that the system didn't stop cleanly. To get the service back up and running you would need to remove these files from within the /var subdirectories. They are normally in /var/run and /var/lock.
service serviceName start
E.g. service dhcpd start

Starting a service Red Hat 7

systemctl start serviceName
E.g. systemctl start dhcpd.service

Stopping a service Red Hat 6

service serviceName stop
E.g. service network stop

Stopping a service Red Hat 7

systemctl stop serviceName
E.g. systemctl stop network.service
You'll notice that the syntax for the systemctl command lead to better history editing since the name of the service comes after the action unlike the old service commands, alowing us to simply recall the command and remove the service name and put in the next.

Systemctl syntax

systemctl action serviceName
systemctl [start|stop|status] serviceName

Listing services Red Hat 6

chkconfig --list [serviceName]
This will list whether a service is set to run at boot time if the service name is supplied, or list all services run ability at boot.
If you wish to se current state of all processes then you would require the following shell script;
for serviceName in $(chkconfig --list | cut -f1 -d' ')do  service $serviceName statusdone

Listing services Red Hat 7

systemctl -a
This one command tells us whether the service is running or is set to run at boot time.
You can also see if an individual service is enabled with;
systemctl is-enabled serviceName
Another useful command for checking a daemons status is the new journalctl command which shows information that will have been written to the log file. This command shows up if you start a service from the command line, and mentions the use of option -xn.
To list all available services;
systemctl list-unit-files --type=service

Red Hat 6 enable or disable services at boot

The chkconfig command was used up to and including Red Hat 6 systems to define if a service should be included in the run level as part of its start up sequence. This command like the service command can still be used in v7, but you should become familiar with the new commands.
Enabling a service for any runlevel was performed with;
chkconfig serviceName on
And to disable it;
chkconfig serviceName off
To specify the runlevel you would use the --level option
E.g. chkconfig --level 23 network on
These commands simply created the correct S or K script in the relevant rc.d directories.
To add your own boot script to a system you used;
chkconfig --add scriptName
Where scriptName is the name of the boot script in the /etc/rc.d/init.d directory that you created. There is also a corresponding --del to remove it from the boot sequence, but not the init.d directory.

Red Hat 7 enable or disable services at boot

In the v7 systems we continue to use the one command, systemctl.
Enable a service or resource with;
systemctl enable serviceName
E.g. systemctl enable cupsd.service
Disable a service with;
systemctl disable serviceName

Modifying the boot sequence

In this section we will look at how to set the default runlevel, add your own service and change the runlevel on boot.

Red Hat 6 setting default runlevel

The /etc/inittab file is used up to and including v6. One line in the file needed the numerical value changed. The initdefault line required the number in column 2 to be set to your desired run level. E.g.
id1:3:initdefault:
Note that with the lines in the inittab it was always essential to have the correct number of : characters on the line.
The above example sets the default run level to 3.

Red Hat 7 setting default runlevel

The inittab has now been retired and a symlink system is now in use that points to the relevant configuration file containing the runlevel to be started on boot. The files that define the levels are located in the /lib/systemd/system directory and end .system, e.g. graphical.target.
To find out the current and default runlevel use the following command;
systemctl get-default
To change the resources to start on boot you use the set-default option as follows;
systemctl set-default multi-user.target
If you wish to use run levels in v7 you can by specifying;
runlevel?.target
The ? should be changed for the number of the run level you want to set. You can then use;
systemctl set-default runlevel5.target
The above example is the same as graphical.target.

Red Hat 6 temporarily change runlevel at boot

Through grub boot menu you would press a key to halt the countdown. You then press e to edit the kernel boot line you wish to start the system with and add the runlevel number to the end of the kernel line and press the relevant key to boot the system using your current settings.
This of course can be used to alter any kernel values.

Red Hat 7 temporarily change runlevel at boot

The process is the same as v6, but instead of specifying the numerical run level you will need to use the target name at the end of the kernel line. For example to use rescue mode;
systemd.unit=rescue.target

Red Hat 6 boot scripts

These are simple bash shell scripts which make use of the case statement, but require 2 special comments to appear in the file. The 2 comments required are;
#description:
#chkconfig:
Note that they must have the colon (:) symbol immediately street the name.
Following the colon are the directives to define what the script is for and what the default start and stop run levels are.
Example:
#!/bin/bash#description: Describes what your service does, used by apps that can provide more info#chkconfig 235 99 01# the above line sets the service to start at # run levels 2, 3 and 5 as the 99th item, e.g S99xxx# and spots add the 1st, e.g K01case $1 in  'start')    # start the service here and create pid and lock files    ;;  'stop')    # stop the service using pid file, remove lock file    ;;  'status')    # use pid file to check process is running
    # and if lock file exists
    ;;
esac

Red Hat 7 boot scripts

The equivalent of the init.d script is to create a .sevice file in the /lib/systemd directory. Notice that you can still use your old style init.d script by placing it into /usr/lib/systemd/scripts.
[Unit]Description=Describe your service[Service]Type=oneshotExecStart=/usr/lib/systemd/scripts/yourInitScript startExecStop=/usr/lib/systemd/scripts/yourInitScript stopRemainAfterExit=yes[Install]WantedBy=multi-user.target
You change the relevant parts, e.g. what this script needs before it can start, the daemon to run our the script.

Useful references