Removing Xi-Text from a System
What to save first, how to remove an RPM, Debian package or tarball, and what each route destroys, licence included
Removing Xi-Text deletes its data along with its programs. This article says what each removal route deletes, what to save before you start, and how to remove the product installed as an RPM, as a Debian package or from the tarball.
What a removal deletes
Removing the RPM or the Debian package deletes the spool directory, the printer setup files, the socket directory, the master configuration, the hosts file, the licence file and the spooler account. There is no prompt and no data-preserving form of the command: on Debian, apt remove deletes as much as apt purge. Save everything you want to keep before you start.
The licence file goes with it. Every packaged removal and the tarball de-installer delete it, and a later installation of Xi-Text writes a trial licence in its place. Copy the licence file out of the installation before you remove anything, and put it back afterwards: it stays valid on the same machine, and restoring it returns the installation to its own licence.
Removal stops all printing, and a clean stop can take up to five minutes on a busy system. Schedule the work in a maintenance window.
Stop the spooler, then take the backup
The saved queue files are rewritten at most every 300 seconds, so an export taken from a running spooler can be minutes behind the live queue. Stopping flushes both files.
# Stop the spooler
sstop -y
# Verify stopped
ps -ef | grep spshed
sstop -y halts every printer, synchronises the spool files and then releases the shared memory. It waits in fifteen-second intervals for up to 300 seconds and prints its progress, so let it finish.
If you started Xi-Text with spstart by hand rather than through the service, note that removing the package asks systemd to stop the service and systemd knows nothing about a hand-started spooler. The removal will then delete the spool tree underneath a running scheduler. Stop it yourself, as above, in every case.
Export what you want to keep
With the spooler stopped, export what you want to keep. Put the backup directory outside /var/spool/xi, since a packaged removal deletes that whole tree.
# Create backup directory
BACKUP_DIR="/var/tmp/xitext-final-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR/Scripts"
# The licence file - save this first, every removal route deletes it
cp /usr/libexec/xi/.xitext.lic "$BACKUP_DIR"
# Export jobs (writes a replayable script plus the job files)
xt-cjlist -D /var/spool/xi/spd spshed_jfile "$BACKUP_DIR/joblist.sh" "$BACKUP_DIR/Scripts"
# Export printers
xt-cplist -D /var/spool/xi/spd spshed_pfile "$BACKUP_DIR/ptrlist.sh"
# Export user permissions
xt-spuconv -D /var/spool/xi/spd spufile23 "$BACKUP_DIR/userlist.sh"
# Backup printer setup files
cd /var/spool/xi/printers
tar cf "$BACKUP_DIR/ptrdefs.tar" .
# Backup configuration files
cp /etc/xi/textconfig /etc/xi/text-hosts "$BACKUP_DIR"
Xi-Text ships xt-backup, which runs the same four export steps - jobs, printers, printer definitions and user permissions - and asks you where to put the results. It must be run as root, and it is installed by the RPM, the Debian package and the tarball alike. It asks questions where the commands above take paths.
The three converters produce shell scripts you can replay on a new installation, and the printer archive restores by unpacking. Neither xt-backup nor the converters save the licence file or the master configuration, so both are copied by hand above.
Which installation method was used
The three tests are independent, and on a relocated or custom installation the paths may differ - see the note on directories below.
# Find any Xi packages that are installed
rpm -qa | grep -E 'xitext|xibatch'
dpkg -l | grep -E 'xitext|xibatch'
# Tarball installations, and only tarball installations, write this file
ls -l /usr/lib/xi/install.manifest
An RPM answers to a name that carries the build variant, written below as xitext_\
Finding your own directories
The paths in this article are the default ones. A relocated installation, or a custom build, puts the same files elsewhere. Your own directories are recorded in the master configuration:
grep -E 'SPOOLDIR|SPOOLPT|SPUDSOCKS|SPROGDIR|SPHELPDIR|USERPATH' /etc/xi/textconfig
A setting that matches the product's own default is written out commented, so an entry starting with # still tells you the value in use.
Removing an RPM installation
Step 1: Stop Xi-Text and check the IPC resources
Stop the spooler as described above if you have not already. A clean stop releases every System V resource Xi-Text holds: the three shared memory segments are removed, the two lock files and the two request sockets are unlinked. Xi-Text creates no semaphores and no message queue.
Check that the stop did its job, while the package - and therefore Xi-Text's own tools - are still installed:
# Xi-Text's shared memory keys all begin 0x58691
ipcs -m | grep 0x58691
Expected: no results. If segments remain - which happens when the scheduler was killed rather than stopped, or when the service stop timed out and systemd terminated it part-way - clear them with Xi-Text's own tool before removing the package, because the package removal deletes the tool along with everything else:
# Run as root: dump and delete the leftover Xi-Text IPC resources
xt-ripc -d
A leftover segment shows in ipcs -m with no dest flag, which means the scheduler never got as far as releasing it. That flag is a Linux one, and it has one case that catches people: the moment a segment is marked for destruction its key is reported as 0x00000000, so a segment showing dest has already dropped out of the listing above. Run ipcs -m unfiltered before concluding that nothing is left.
If xt-ripc has already gone, remove the segments by key. List them with ipcs -m, take each key that begins 0x58691, and remove it individually:
ipcrm -M 0x58691003
Do not match on 0x5869 alone. That prefix is shared with Xi-Batch, whose keys begin 0x5869b, so a four-digit match on a machine running both products removes Xi-Batch's live queue.
Guard against the stop timing out in advance on an RPM installation: the service unit the RPM writes uses systemd's default 90-second stop timeout, while a clean stop can need up to 300 seconds. Check yours, and raise it before a removal on a busy system:
systemctl show xitext -p TimeoutStopUSec
Step 2: Remove the RPM package
Remove the GUI sub-packages in the same command if they are installed, because each of them requires the main package:
# Uninstall package (add the sub-packages you have)
rpm -e xitext_<variant>-motif xitext_<variant>-gtk3 xitext_<variant>
# Verify removal
rpm -q xitext_<variant>
Expected output: package xitext_\
Step 3: What the removal has already done
The package does the clean-up itself. It stops and disables the service and deletes the service unit; it removes the licence file, /etc/xi/textconfig, /etc/xi/text-hosts, /etc/Xitext-extern and the Xi-Text entries in /etc/services; it deletes the spool, printers and socket directories with everything in them; it deletes /etc/xi itself unless Xi-Batch is still installed; and it deletes the spooler account. The table below states this for each format.
Two things remain after an RPM removal:
- The physical printers and their device files. Removal deletes Xi-Text's printer definitions and their setup files; the devices themselves, and any ownership or permission changes made to them when the printers were installed, are left as they are.
- A spooler group, on installations that have one. The RPM gives the account an existing system group rather than creating one, so there is normally no spooler group to remove. Check with getent group spooler before assuming there is.
Removing a Debian package installation
Debian and Ubuntu-family systems install Xi-Text from a .deb. The procedure is the same shape as the RPM one, and the package is named xitext with no build variant in the name.
# Stop and check the IPC resources exactly as for the RPM
sstop -y
ipcs -m | grep 0x58691
# Remove the package
dpkg -r xitext
# Verify removal
dpkg -l xitext
On Debian there is no data-preserving removal. dpkg -r and apt remove run the same clean-up as dpkg --purge: the spool tree, the printer setup files, the licence, /etc/xi/textconfig, /etc/xi/text-hosts and the spooler account all go.
Two things the RPM removes are left behind by the Debian package, and you may want to tidy them by hand:
# The Xi-Text entries in the services file (xitext, spq, xtnetsrv, xtapi)
grep -E 'xitext|xtnetsrv|xtapi' /etc/services
# The external-printer definition file
rm -f /etc/Xitext-extern
What each removal route removes
| Item | RPM | Debian package | Tarball DEINSTALL.sh |
|---|---|---|---|
| Installed programs and help files | removed | removed | removed, from the install manifest |
| Saved queue, printer and user files, and the report file | removed | removed | removed |
| Spool directory and the queued job files in it | removed | removed | kept - the directory is only removed when it is empty |
| Printer setup files | removed | removed | kept |
| Licence file | removed | removed | removed |
| Master configuration and hosts file | removed | removed | removed |
| /etc/Xitext-extern | removed | kept | kept |
| Xi-Text entries in /etc/services | removed | kept | kept |
| spooler account | removed | removed | kept |
| systemd unit | removed | removed | removed on systemd only |
| SysV init script, inittab or /etc/rc entries | never installed | never installed | kept - see the tarball section |
The /etc/xi directory itself is removed by both packages unless Xi-Batch's batchconfig is still in it, and by the tarball de-installer only when it is empty.
Removing a tarball installation
Step 1: Locate DEINSTALL.sh
The distribution archive contains a script called DEINSTALL.sh. There is no file called UNINSTALL and no file called DEINSTALL - the name carries its suffix. It lives at the top level of the unpacked distribution, beside INSTALL:
# In the directory the distribution was unpacked into
ls -l DEINSTALL.sh
If the unpacked distribution has been deleted, unpack the archive again from your download or your media; the script needs nothing from it but itself.
Step 2: Check its prerequisites
Xi-Text's de-installer will refuse to run without all of the following:
- root. It exits immediately for any other user.
- The install manifest at /usr/lib/xi/install.manifest, which the tarball installer wrote and which lists every file and directory it created. Without it the script exits, because the manifest is its only record of what to remove. Keep a copy of this file - it is your only inventory afterwards.
- Today's date as its only argument, in YYYYMMDD form. This is a deliberate confirmation step, and the script prints what it is about to do and exits when the argument is missing or stale.
- sudo on the PATH. The script deletes the manifest's files through sudo, even when it is already running as root.
Step 3: Run DEINSTALL.sh
# Execute as root, with today's date
./DEINSTALL.sh $(date +%Y%m%d)
The script runs sstop -y itself, so it stops Xi-Text for you. Take the backup before you run it, which means stopping the spooler yourself first, as above.
It then removes the systemd unit, deletes the licence file, the saved job, printer, user and report files and the request socket, and finally deletes every file the manifest lists and removes the manifest's directories.
Step 4: Finish the parts DEINSTALL.sh leaves
Five things are left behind, and each needs a decision before it is deleted.
Queued jobs and the spool directory
The script removes directories with rmdir, which fails on a directory that still has contents. A queue with jobs in it therefore remains, along with the numbered subdirectories the spool directory uses. Inspect before deleting:
ls -la /var/spool/xi/spd
# When you are satisfied nothing there is wanted
rm -rf /var/spool/xi/spd
Printer setup files
Printer setup files are created after installation, by Ptrinstall rather than by the installer, so the manifest never lists them and they remain. They are the record of how each printer was configured, and the hardest part of an installation to reproduce. Save them before deleting them.
# One directory per printer
ls -l /var/spool/xi/printers
# Keep a copy
cd /var/spool/xi/printers
tar cf /var/tmp/xitext-printers.tar .
# Then, if you are sure
rm -rf /var/spool/xi/printers
The physical printers and their device files are untouched by any removal route, as are any ownership and permission changes made to those devices when the printers were installed.
Startup integration on systems without systemd
The de-installer removes the systemd unit and prints a warning for every other init system. On a machine using SysV init, upstart, AIX inittab or the HP-UX /etc/rc mechanism, remove the entries the installer added by hand:
# SysV init
/etc/init.d/xitext stop
rm -f /etc/init.d/xitext
rm -f /etc/rc*.d/*xitext
# AIX - remove the spstart line
grep spstart /etc/inittab
# HP-UX - remove the Xi-Text lines from /etc/rc
Leftover sockets and lock files
The de-installer removes the stream request socket and leaves its datagram twin and the two lock files. They are harmless, and they are tidied with the socket directory:
ls -l /var/spool/xi/spuds /var/spool/xi/spd/*.lock
rm -f /var/spool/xi/spuds/spshed_req_udp /var/spool/xi/spd/spjob.lock /var/spool/xi/spd/spptr.lock
The system account, the services file and the extern file
# Xi-Text service entries (xitext, spq, xtnetsrv, xtapi)
grep -E 'xitext|xtnetsrv|xtapi' /etc/services
# External printer definitions
rm -f /etc/Xitext-extern
# The system account - only if Xi-Batch is not also using it
userdel spooler
Check before removing the account: Xi-Batch runs as batch rather than spooler, so the two products do not share it, and a site may have given the account other work.
Confirming the removal
Processes
# No Xi-Text processes should be running
ps -ef | grep -E 'spshed|spd|xtnetserv'
Expected: no results, other than the grep itself.
IPC resources
# No Xi-Text shared memory should remain
ipcs -m | grep 0x58691
Expected: no results. There is nothing to check with ipcs -q or ipcs -s, because Xi-Text uses neither message queues nor semaphores.
Files
# User commands
ls -l /usr/local/bin/sp* /usr/local/bin/xt-* 2>/dev/null
# Internal programs and help files
ls -ld /usr/libexec/xi /usr/share/xi 2>/dev/null
# Spool, sockets and printer setup files
ls -ld /var/spool/xi/spd /var/spool/xi/spuds /var/spool/xi/printers 2>/dev/null
# Tarball install manifest
ls -l /usr/lib/xi/install.manifest 2>/dev/null
Expected: "No such file or directory" for each, on a packaged removal. After a tarball removal, expect the spool and printers directories to remain if they had contents.
Configuration
ls -l /etc/xi/textconfig /etc/xi/text-hosts /etc/Xitext-extern 2>/dev/null
grep -E 'xitext|xtnetsrv|xtapi' /etc/services
Expected after an RPM removal: no results from either. After a Debian or tarball removal, expect /etc/Xitext-extern and the services entries to remain.
Services
systemctl status xitext
ls -l /usr/lib/systemd/system/xitext.service /lib/systemd/system/xitext.service 2>/dev/null
Expected: unit not found, and no unit file. The unit is installed under /usr/lib/systemd/system or /lib/systemd/system depending on the format, and never under /etc/systemd/system.
The system account
id spooler
Expected: "no such user" after a packaged removal. After a tarball removal the account is still there, because the de-installer leaves it.
Platforms other than Linux
RPM and Debian packages are Linux-only formats. On Solaris, AIX and HP-UX the tarball is the only distribution, so the tarball procedure above is the one that applies - including the point that its startup clean-up is implemented for systemd alone, which none of those platforms uses.
Removing the system account
Only the tarball route leaves the account behind. The command differs by platform:
# Linux, Solaris and HP-UX
/usr/sbin/userdel spooler
# AIX
rmuser spooler
Clearing IPC resources
xt-ripc -d is the portable answer and works on every platform Xi-Text ships for. Where it has already been removed, list the segments with ipcs -m and remove each Xi-Text key individually with ipcrm -M \
Troubleshooting
"Permission denied" errors
Ensure running as root or with sudo privileges. The tarball de-installer also requires sudo to be on the PATH, because it deletes the manifest's files through it.
RPM removal fails with a dependency error
The Motif and GTK3 GUI sub-packages each require the main package. Remove them in the same command rather than forcing the removal.
Shared memory segments remain after the stop
The scheduler releases them itself during a clean shutdown, so leftovers mean the shutdown did not complete - commonly because the service stop timed out and the scheduler was terminated part-way. A clean stop can need up to 300 seconds. Run sstop -y, wait for it, and use xt-ripc -d for anything still there.
DEINSTALL.sh exits with "Date didn't match"
The script takes today's date as its argument in YYYYMMDD form, as its own message shows. This is the confirmation step working as intended.
DEINSTALL.sh exits with "Manifest file ... not readible"
The install manifest at /usr/lib/xi/install.manifest is missing. The script cannot proceed without it, because the manifest is its only record of what was installed. Restore a copy if you kept one; otherwise the installation has to be removed by hand, directory by directory, using the master configuration to find where each one is.
Files remain after uninstall
Check for files in relocated directories. Read the master configuration first if it is still there, and otherwise search:
find / \( -name 'spshed*' -o -name '.xitext.lic' \) -print 2>/dev/null
Cannot remove user (user busy)
Other processes may still be running as the account. Identify them with:
ps -ef | grep spooler
You removed Xi-Text and now need it back
Reinstall, then restore the licence file you copied out before the removal and confirm it with xt-checklic. A fresh installation writes a trial licence, so check this rather than assuming the product is correctly licensed because it starts.
Related articles
Removing Xi-Batch from a System
What to save first, how to remove an RPM, Debian package or tarball, and why only packaged routes delete the licence
Installing an Emergency Seven-Day Licence on Xi-Text
Recovering a system whose licence has been lost or damaged with xt-emerglic, and replacing it with a permanent licence
Migrating Xi-Text to Another System
Exporting the print queue, printers and users with xt-backup, and restoring them on a newly licensed machine