-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
61 lines (49 loc) · 997 Bytes
/
entrypoint.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
start_cupsd() {
if ! pgrep -x "cupsd" > /dev/null; then
cupsd
fi
}
err() {
echo -e >&2 "$@"
exit 1
}
model() {
start_cupsd
lpinfo -m | fzf --tac --layout=reverse --with-nth 2.. --bind 'enter:become(echo {1})'
}
print() {
if [ -z ${URI+_} ]; then
err No printer URI is specified
fi
if [ -z ${MODEL+_} ]; then
err "No printer MODEL is specified\nTry running with \"model\" argument to select a supported model"
fi
start_cupsd
# Add the printer
lpadmin -p default -v "$URI" -m "$MODEL"
# Enable and accept print job
cupsaccept default
cupsenable default
# Set as a default printer
lpoptions -d default
# Send the print job
lp /usr/share/cups/data/testprint
# wait
sleep ${WAIT:-5}
}
ulimit -n 65536
case "$1" in
model)
model
;;
bash)
bash
;;
print)
print
;;
*)
sleep infinity
;;
esac