-
Notifications
You must be signed in to change notification settings - Fork 0
pistopclient.1
pistopserver - pistop server to provide pistop server events
pistopclient - pistop client to watch pistop server events
pistopserver [options]
pistopclient [options]
pistopserver and pistopclient together provide a way to achieve synchronized startup and shutdown of multiple clients associated with a single central server. This association can be arbitrary. See the section EXAMPLE.
pistopserver needs to be run with fd 0 and 1 connected to some TCP/IP port. This can be done using tcpserver(1), xinetd(1). It can be any unused port, but having a port greater than 1024 will allow pistopserver to be run as non-root user. Similarly pistopclient needs to be connected to some TCP/IP port, with fd 6 reading from the network and fd 7 writing to the network. This can be easily done by using tcpclient(1). pistopclient must be run under root if it has to start/stop system services. It will look for a script named pistopstart under $HOME/.pistop directory. If this script is not found, it will use pistopstart script in /usr/libexec/pistop. The default pistopstart script starts/stops autofs and mpd service on startup/shutdown and additionally mounts NFS/samba shares. pistopstart script expects either start or stop arguments. If you have the script/program in $HOME/.pistop it will get updated with the latest script in /usr/libexec/pistop. To prevent your script from getting automatically upgraded, create a file named .pistopstart.noovewrite in $HOME/.pistop directory. pistopstart scripts executes the following user defined scripts (if present) during mount and unmount of NFS/samba shares
1. $HOME/.pistop/pre_mount - before auto-mounting a share
2. $HOME/.pistop/post_mount - after auto-mounting a share
3. $HOME/.pistop/pre_unmount - before unmounting an auto-mounted share
4. $HOME/.pistop/post_unmount - after unmounting an auto-mounted share
You can have pistopserver and pistopclient to be automatically started on bootup by creating appropriate configuration in rc, systemd(1) or as a supervised service under svscan(8). You can use /usr/libexec/pistop/create_service to create a supervised service for pistopserver on your central server or a supervised service for pistopclient on your satellite hosts as shown in the examples below.
Assuming your central host is 192.168.1.100
Create a supervised service for pistopserver on 192.168.1.100
create_service --servicedir=/service --service_name=fclient --user=pi --host=192.168.2.101 --port=5555 --add-service
Create a supervised service for pistopclient on all satellite hosts
create_service --servicedir=/service --service_name=fserver --user=pi --host=192.168.1.100 --port=5555 --add-service
If you have your own custom script in $HOME/.pistop directory and don't require root privileges to stop/start your services, you can edit /service/fclient/variables/USER and restart fclient supervised service.
An example of an association is a host with mpd(1) running providing it's music database using the simple database plugin and all clients using the same database using the proxy database plugin. When you shutdown the host with the music database and you want all connected clients to shutdown, you can use pistopserver and pistopclient. This is what you need to do
1. run pistopserver on the host having the mpd database under tcpserver(1)
$ tcpserver -vDHRo 0 5555 /usr/libexec/pistop/pistopserver
2. run pistopclient on all clients with IP of the above tcpserver host as
ipaddr. Run this with root privileges so that it can start/stop
system services
$ sudo tcpclient -vDHR -t 300 ipaddr 5555 /usr/libexec/pistop/pistopclient
pistopclient(1), tcpserver(1) tcpclient(1) svscan(8) supervise(8) svc(1) mpd(1)