summaryrefslogtreecommitdiffstats
path: root/printerd
blob: ef93722b7c7411aa0a3cba0589fcda60a4f93d27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /bin/bash

# This script runs a daemon that listens on a port for printjobs and pipes
# incoming data into UNIX lpd, which starts a helper program when a print-
# job is incoming.

USER="$1"
BUSYBOX="busybox"
IP="0.0.0.0"
PORT="515"
SPOOLDIR="/var/spool"
SPOOLQUEUE="STANDARD"
GUIBINARY="printerGUI"

# Create the directory for the queue
mkdir -p "$SPOOLDIR/$SPOOLQUEUE"

# Change the owner of the directory such that lpd 
# is able to write to it
chown $USER:$USER "$SPOOLDIR/$SPOOLQUEUE"

# Start the lpdaemon listening on the given port
exec "$BUSYBOX" tcpsvd -Eu "$USER:$USER" "$IP" "$PORT" \
  "$BUSYBOX" lpd "$SPOOLDIR" \
  "$GUIBINARY"