~m-grant-prg/swoc/bionic-trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
------------------------------------
Server Wait On Clients (SWOC) System
====================================

Author - Copyright (C) 2018-2020 Mark Grant

--------
Contents
========

1 ... Project Description

2 ... AutoTools (configure and make) Installation

3 ... Installation of Distro-Native Packages

4 ... Utility Scripts



-------------------------
1 ... Project Description
=========================

System Synopsis
---------------
The Server Wait On Clients (SWOC) system provides a mechanism for clients to
register locks on a server which the server can then watch and wait until all
locks are released before taking some action.

It is easier to show an example:
Overnight, clients want to perform crontab work as a user and root, then do a
backup and then shutdown enabling the server to initiate its own shutdown.

So an example root crontab on the client:-
# This line adds a lock, performs some work of unknown duration and releases the
# lock.
10 00 * * 0,1,2,3,4,5,6 date ; swocclient -l ; apt-get update -qq ; \
apt-get upgrade -d -q -y ; apt-get dist-upgrade -d -q -y ; swocclient -r ; date

# This line adds a lock of its own, waits until this client has one lock
# outstanding, ie its own, then performs a backup, releases the lock and shuts
# down.
15 00 * * 0,1,2,3,4,6 date ; swocclient -l ; swocclient -w1 ; date ; \
netbckup -d ; swocclient -r ; date ; at -f shutdown now

At the same time, a user crontab on the client is using two crontab entries to
run some jobs each taking its own lock at the start and releasing it at the
end. Both of these lines are of unknown and variable duration:-
10 00 * * 0,1,2,3,4,6 swocclient -l ; \
get_iplayer --pvr 2>/home/mgrant/Videos/iPlayer/VideosErr.log ; date ; \
swocclient -r

10 00 * * 0,1,2,3,4,6 swocclient -l ; \
mget --quiet --sourcefile /home/mgrant/Downloads/MultiGetSource.txt \
--targetdir /home/mgrant/Downloads ; date ; swocclient -r

Meanwhile on the server, it waits until it has no more registered locks and then
initiates a shutdown.
20 00 * * 0,1,2,3,4,5,6 date ; swocserver -w ; date ; at -f shutdown now

This Project
------------
This AutoTools project contains the swocserver Server Wait On Clients Server
Programs.

This comprises of the command line program swocserver.

If you are going to build this swocserver SWOC Server Programs then you must
install the development files from libswocserver-dev. Other required
dependencies not installed on your system will be identified by the configure
script. Any of these produced by this author can be found in a repository
located here:-
https://github.com/m-grant-prg

Related packages in this system are the dev and lib packages for libswoccommon
SWOC Common Library, equivalent packages for the libswocserver Server Library,
equivalent packages for the libswocclient Client Library, a package swocclient
for the client application, a package swocserver for the server application and
a documentation project swocdoc. There is also a parent project, swoc-full.

So please refer also to the README files of these projects.

N.B.
----
At a source modification / development level, this project expects to reside in
a git environment. This manifests itself in 2 places:-
1) ... .gitignore files are included in the source.
2) ... The make target, 'srctarball', relies on the command 'git archive' so it
	will fail if git is not installed or it is not in a git repository.


-------------------------------------------------
2 ... AutoTools (configure and make) Installation
=================================================

a) ... Download either the source or distribution tarball (the .tar.gz file)
	from:-
	https://github.com/m-grant-prg/swoc/releases

b) ... Extract the tarball preserving the directory structure.

c) ... cd to the directory created.

d) ... If you downloaded the source tarball type 'autoreconf -if'

e) ... Type './configure'

f) ... As root or sudo, type 'make install clean'

g) ... Edit the sysconfdir/swocserverd.conf, (usually /etc/swocserverd.conf), as
	required.

(Quote marks are for textual clarity only).

To uninstall the package:

1 ... cd to the directory created in the above install process.

2 ... As root or sudo, type 'make uninstall clean'


--------------------------------------------
3 ... Installation of Distro-Native Packages
============================================
Installation packages native to different distributions are available, please
refer to the relevant installation section on the wiki at:-

https://github.com/m-grant-prg/swoc/wiki


---------------------
4 ... Utility Scripts
=====================
In the project root directory there are 2 helper scripts; bootstrap.sh and
gen-gnulib.sh.

bootstrap.sh
------------
This misleadingly named script bootstraps the project build and provides other
useful features. The main options are probably b, c, C, D and T.

In AutoTools it is usually advisable to perform parallel builds. This means you
build somewhere other than the project root. This is because building creates
files and they would confuse the project root downwards. I always create a build
directory straight off the project root, cd to there and do all build and git
work from there, (.gitignore is already set to ignore such a directory).

Assuming you adopt the preceding paragraph then a typical invocation of the
script would be:-

../bootstrap.sh --config --build ..

The last '..' points the way to project root.

For the full list of arguments to bootstrap.sh, please refer to the options
section of the acmbuild wiki, the options are identical:-

https://github.com/m-grant-prg/acmbuild/wiki


gen-gnulib.sh
-------------
This script generates or re-generates the gnulib requirements, I shan't go into
detail here.

It is useful when setting up the project initially, when you are actually
building in what is required and thinking about it, thereafter it is best to use
../bootstrap.sh --gnulib ..
as it determines whether to do a re-generate based on whether the cache file
exists, i.e. it has been wanted before.

setup.sh
--------
If the sysconfdir/swocserverd.conf configuration file is deleted, or, if
corrupted then delete it, and run setup.sh from the pkglibexec directory. To
find the script location on your system:-
	type 'find / -path */swocserver/setup.sh 2>/dev/null'.
Typically in an AutoTools build pkglibexec is /usr/local/libexec/PACKAGE
so as root or sudo you would type:-
	'/usr/local/libexec/swocserver/setup.sh'.
Answer the prompts from the setup script.
Subsequent to running this script, config files can only be modified with an
editor, setup.sh will not work unless the config file is deleted.