serv/README.md

95 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

2021-07-11 10:20:48 +10:00
# Overview
2021-07-11 10:32:28 +10:00
Script to manage custom /etc/services entries.
2021-07-11 10:20:48 +10:00
# Usage
2021-07-11 10:22:19 +10:00
Show usage
2021-07-11 10:20:48 +10:00
rpearce@crom:serv$ ./serv.sh -h
usage: ./serv.sh [OPTIONS] command [command_args]
Manage custom /etc/services entries.
Valid commands are: diff sync init add del query cat
-f Force removal of service even if multiple match.
-w Update system services file (/etc/services)
-y Same as -w
2021-07-11 10:22:19 +10:00
Create working area in ~/.serv/
2021-07-11 10:20:48 +10:00
rpearce@crom:serv$ ./serv.sh init
Initialisation of /Users/rpearce/.serv complete.
2021-07-11 10:22:19 +10:00
Add a custom service
2021-07-11 10:20:48 +10:00
rpearce@crom:serv$ ./serv.sh add myservice 34777/udp
Added 'myservice' (34777/udp) to custom services file.
NOTE: /etc/services not touched - use -w to update it.
The following changes were NOT made:
13921a13922,13924
>
> # custom services from serv.sh
> myservice 34777/udp
2021-07-11 10:22:19 +10:00
Look up a custom service
2021-07-11 10:20:48 +10:00
rpearce@crom:serv$ ./serv.sh query myservice
Found in custom services file:
myservice 34777/udp
2021-07-11 10:22:19 +10:00
Update system /etc/services with custom services
2021-07-11 10:20:48 +10:00
rpearce@crom:serv$ ./serv.sh -w sync
(using sudo - you may be prompted for your password)
Password:
/etc/services updated:
13921a13922,13924
>
> # custom services from serv.sh
> myservice 34777/udp
rpearce@crom:serv$ tail -5 /etc/services
# 48557-49150 Unassigned
# 49151 IANA Reserved
# custom services from serv.sh
myservice 34777/udp
rpearce@crom:serv$
2021-07-11 10:32:28 +10:00
Confirm updates are working
rpearce@crom:serv$ sudo tcpdump -i lo0 port 34777 &
[1] 54039
rpearce@crom:serv$ nc -v -u 127.0.0.1 34777
10:28:38.061303 IP localhost.58916 > localhost.myservice: UDP, length 1
10:28:38.061314 IP localhost.58916 > localhost.myservice: UDP, length 1
10:28:38.061318 IP localhost.58916 > localhost.myservice: UDP, length 1
10:28:38.061323 IP localhost.58916 > localhost.myservice: UDP, length 1
Connection to 127.0.0.1 port 34777 [udp/myservice] succeeded!
rpearce@crom:serv$ sudo kill 54039
4 packets captured
178 packets
rpearce@crom:serv$
2021-07-11 10:22:19 +10:00
Remove a custom service, and also update /etc/services
2021-07-11 10:20:48 +10:00
rpearce@crom:serv$ ./serv.sh -w rm myservice
Removed 'myservice' from custom services file (1 line).
(using sudo - you may be prompted for your password)
/etc/services updated:
13924d13923
< myservice 34777/udp
rpearce@crom:serv$ tail -5 /etc/services
com-bardac-dw 48556/udp # com-bardac-dw
com-bardac-dw 48556/tcp # com-bardac-dw
# Nicholas J Howes <nick@ghostwood.org>
# 48557-49150 Unassigned
# 49151 IANA Reserved
rpearce@crom:serv$