_hyhome='/var/spool/hylafax' _hyfax='/usr/lib/fax' #_hyuser='fax' _hyuser='uucp' _hygroup='uucp' _print_install() { echo -e '\n' echo 'Run faxsetup to configure and be sure to set...' echo ' The device to configure is usually ttyS0, ttyUSB0, or ttyACM0' echo ' The number of pages to accept to more than 25' echo ' The country code and area code' echo ' The Fax Class to 2.0' echo ' Most other defaults are OK' echo -e '\n' } _print_remove() { echo -e '\n\n' echo "You may manually remove ${_hyhome} and ${_hyfax} if you do not need anything." echo 'You may also remove any aliases added to /etc/mail/aliases.' echo -e '\n' } post_install() { set -u #groupadd -g 14 "${_hygroup}" &>/dev/null useradd -u 10 -g "${_hygroup}" -d "${_hyhome}" -s '/bin/false' "${_hyuser}" &>/dev/null #useradd -u 69 -g 'daemon' -d '/' -s '/bin/false' 'fax' &>/dev/null post_upgrade #usermod -d '/' "${_hyuser}" &>/dev/null _print_install mandb -q set +u } # define _clean_or_copy_doit() to tell this what to do _clean_or_copy() { for _outfile in 'archive' 'faxrcvd' 'notify' 'pollrcvd'; do _clean_or_copy_doit "${_hyhome}/bin/${_outfile}.hylafaxplus.default" "${_hyhome}/bin/${_outfile}" done for _outfile in ${_hyhome}/etc/*.default; do _clean_or_copy_doit "${_outfile}" "$(expr "${_outfile}" : '^\(.\+\).default$')" done } post_upgrade() { set -u # Only some of the files and folders are chown chown "${_hyuser}:${_hygroup}" "${_hyhome}"/{,archive,bin,client,config,dev,docq,doneq,etc} chown "${_hyuser}:${_hygroup}" "${_hyhome}"/{info,log,pollq,recvq,sendq,status,tmp} chown "${_hyuser}:${_hygroup}" "${_hyhome}/FIFO" "${_hyhome}"/FIFO.* 2> /dev/null # Don't overwrite existing configuration files. _clean_or_copy_doit() { cp -np "$1" "$2" chmod 'u+w' "$2" } _clean_or_copy cp -n /dev/null "${_hyhome}/etc/xferfaxlog" # This doesn't modify the timestamp of an existing file chown "${_hyuser}:${_hygroup}" "${_hyhome}/etc"/{hosts.hfaxd,lutRS18.pcf,xferfaxlog} # chown -R "${_hyuser}:${_hygroup}"\ "${_hyhome}/etc/templates" systemctl daemon-reload systemctl enable 'hylafax.timer' systemctl start 'hylafax.timer' # Now done by pacman hook #if [ ! -z "$(command -v 'avantfaxsetup.sh')" ]; then # avantfaxsetup.sh 2 'install' #fi set +u } _pre_upgrade_fix_faxcover() { # Two fax covers in different places causes problems. Since I didn't notice this before I can't trash the covers if [ ! -L "${_hyfax}/faxcover.ps" ]; then if [ "$(md5sum < "${_hyfax}/faxcover.ps" | cut -d' ' -f1)" != '756ff1ce327f89d5651cdb99f02efc25' ]; then if [ "$(md5sum < "${_hyhome}/etc/cover.templ")" = "$(md5sum < "${_hyhome}/etc/cover.templ.default")" ]; then mv "${_hyfax}/faxcover.ps" "${_hyhome}/etc/cover.templ" else mv "${_hyfax}/faxcover.ps"{,.pacsave} echo "Modified faxcover.ps has been saved as ${_hyfax}/faxcover.ps.pacsave" fi fi fi } pre_upgrade() { set -u _pre_upgrade_fix_faxcover _clean_or_copy_doit() { # Delete unmodified files if [ "$(md5sum < "$1")" = "$(md5sum < "$2")" ]; then rm -f "$2" fi } _clean_or_copy set +u } pre_remove() { set -u pre_upgrade userdel "${_hyuser}" &>/dev/null ##groupdel "${_hygroup}" &>/dev/null # we could put this into pre_upgrade() but I'd rather let the admin restart when convenient. systemctl stop 'hfaxd.service' systemctl disable 'hfaxd.service' systemctl stop 'faxq.service' systemctl disable 'faxq.service' systemctl stop 'faxgetty@*.service' rm -f '/etc/systemd/system/multi-user.target.wants'/faxgetty@*.service # systemctl disable doesn't accept wildcards/PATTERN systemctl stop 'hylafax.timer' systemctl disable 'hylafax.timer' #rm -f "${_hyhome}/bin"/{pdf2fax,ps2fax} "${_hyhome}/dev/null" _print_remove set +u } post_remove() { set -u systemctl daemon-reload mandb -q set +u }