Dependency on Server at Boot
Naming
The names and descriptions used in the package and this post are:-
Package name: server-dependency
Package description: Dependency on server at boot
Short name (used in some files / directories): dosab
Example environment used in this post
The simplest explanation is to use an example and this example probably represents the most common usage scenario.
You have a laptop which you use at home or in the office which uses services only available in this LAN setting. ie When away from this location these services cannot be accessed but a replacement configuration may be required. These services could be:-
On your LAN you access an NFS share on an internal only server. Away from your LAN this setup must be skipped.
On your LAN you access a local internal only software package repository (a Debian repo in this example). Away from your LAN this must be skipped.
Implementation
The server-dependency package works by installing a systemd service which runs at boot. This service checks connectivity with the server(s) in question and then either alters the configuration files of other packages or runs specified commands. So in this example we need to do the following:-
Install the package.
Specify the servers to check.
Setup the share.
Setup the LAN based repository.
Reboot the machine.
Installation
Install the package. To prevent bitrot by unnecessary duplication of information, please follow the instructions on my GitHub wiki at:- https://github.com/m-grant-prg/server-dependency/wiki and choose the relevant installation method from the menu.
Servers to check
Inform the package with which servers we need to check connectivity. This involves editing the package server.list file and entering server names, 1 per line. The example shows vim as the editor but use your own preference.
Set up the share
Setting up the share involves 2 actions:-
Add the command to mount the share if the server is available to the .available file (in this example hermes.available).
Ensure that the share in fstab is not auto-mounted.
(We do not need to take any action if the server is unavailable as we are just omitting to mount it).
The screenshot below shows only the share entry, yours will, of course, have all your device entries in it.
Set up the LAN based repository
Setting up the LAN based repository requires 3 steps:-
Create the APT XXXXX.list file for the repository.
Edit the .available file to insert the required commands.
Edit the .unavailable file to insert the required commands.
And finally…
Please reboot the machine.
Authoritative sources
I shall attempt to keep this post accurate and updated, however, the ultimate repository of everything to do with this project is held on GitHub.
The code repository:- https://github.com/m-grant-prg/server-dependency
The wiki:- https://github.com/m-grant-prg/server-dependency/wiki
If you have any issues or discover a bug, please register it at:- https://github.com/m-grant-prg/server-dependency/issues
My Projects
Software and Debian packaging sources can be found on GitHub: https://github.com/m-grant-prg
Debian, Fedora, openSUSE and Raspbian packages can be found on the openSUSE Build Service: https://build.opensuse.org/project/show/home:m-grant-prg
Ubuntu packages can be found in my PPA on LaunchPad: https://code.launchpad.net/~m-grant-prg/+archive/ubuntu/utils
The entry point to my Ubuntu packages on LaunchPad: https://launchpad.net/~m-grant-prg
Subscribe to my newsletter
Read articles from Mark Grant directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Mark Grant
Mark Grant
I have spent many years in IT starting as a programmer in C and Basic then moving into general, data centre and infrastructure management. I am now back writing software mostly in bash and C. These are usually in the form of AutoTools projects which are often then packaged for various Linux distributions such as Debian, Raspbian, Ubuntu, Fedora and openSUSE.