Update yoto HA component together with its library (#372489)
[NixPkgs.git] / nixos / modules / services / networking / hylafax / spool.sh
blob8b723df77df9aeeb4ee26ba65afa06ba229f86f9
1 #! @runtimeShell@ -e
3 # The following lines create/update the HylaFAX spool directory:
4 # Subdirectories/files with persistent data are kept,
5 # other directories/files are removed/recreated,
6 # mostly from the template spool
7 # directory in the HylaFAX package.
9 # This block explains how the spool area is
10 # derived from the spool template in the HylaFAX package:
12 # + capital letter: directory; file otherwise
13 # + P/p: persistent directory
14 # + F/f: directory with symlinks per entry
15 # + T/t: temporary data
16 # + S/s: single symlink into package
17 # |
18 # | + u: change ownership to uucp:uucp
19 # | + U: ..also change access mode to user-only
20 # | |
21 # archive P U
22 # bin S
23 # client T u (client connection info)
24 # config S
25 # COPYRIGHT s
26 # dev T u (maybe some FIFOs)
27 # docq P U
28 # doneq P U
29 # etc F contains customized config files!
30 # etc/hosts.hfaxd f
31 # etc/xferfaxlog f
32 # info P u (database of called devices)
33 # log P u (communication logs)
34 # pollq P U
35 # recvq P u
36 # sendq P U
37 # status T u (modem status info files)
38 # tmp T U
41 shopt -s dotglob # if bash sees "*", it also includes dot files
42 lnsym () { ln --symbol "$@" ; }
43 lnsymfrc () { ln --symbolic --force "$@" ; }
44 cprd () { cp --remove-destination "$@" ; }
45 update () { install --owner=@faxuser@ --group=@faxgroup@ "$@" ; }
48 ## create/update spooling area
50 update --mode=0750 -d "@spoolAreaPath@"
51 cd "@spoolAreaPath@"
53 persist=(archive docq doneq info log pollq recvq sendq)
55 # remove entries that don't belong here
56 touch dummy # ensure "*" resolves to something
57 for k in *
59 keep=0
60 for j in "${persist[@]}" xferfaxlog clientlog faxcron.lastrun
62 if test "$k" == "$j"
63 then
64 keep=1
65 break
67 done
68 if test "$keep" == "0"
69 then
70 rm --recursive "$k"
72 done
74 # create persistent data directories (unless they exist already)
75 update --mode=0700 -d "${persist[@]}"
76 chmod 0755 info log recvq
78 # create ``xferfaxlog``, ``faxcron.lastrun``, ``clientlog``
79 touch clientlog faxcron.lastrun xferfaxlog
80 chown @faxuser@:@faxgroup@ clientlog faxcron.lastrun xferfaxlog
82 # create symlinks for frozen directories/files
83 lnsym --target-directory=. "@hylafaxplus@"/spool/{COPYRIGHT,bin,config}
85 # create empty temporary directories
86 update --mode=0700 -d client dev status
87 update -d tmp
90 ## create and fill etc
92 install -d "@spoolAreaPath@/etc"
93 cd "@spoolAreaPath@/etc"
95 # create symlinks to all files in template's etc
96 lnsym --target-directory=. "@hylafaxplus@/spool/etc"/*
98 # set LOCKDIR in setup.cache
99 sed --regexp-extended 's|^(UUCP_LOCKDIR=).*$|\1'"'@lockPath@'|g" --in-place setup.cache
101 # etc/{xferfaxlog,lastrun} are stored in the spool root
102 lnsymfrc --target-directory=. ../xferfaxlog
103 lnsymfrc --no-target-directory ../faxcron.lastrun lastrun
105 # etc/hosts.hfaxd is provided by the NixOS configuration
106 lnsymfrc --no-target-directory "@userAccessFile@" hosts.hfaxd
108 # etc/config and etc/config.${DEVID} must be copied:
109 # hfaxd reads these file after locking itself up in a chroot
110 cprd --no-target-directory "@globalConfigPath@" config
111 cprd --target-directory=. "@modemConfigPath@"/*