-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathcups-session
59 lines (53 loc) · 1.64 KB
/
cups-session
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
#!/bin/bash
# Script for open CUPS webpage and install it if not installed
# If cups is running open x-www-browser in https://localhost:631
# If cups is not installed installl cups and open browser
# NO CUPS INSTALLED
if [ "$1" = "-I" ]; then
# INSTALL CUPS
if ! dpkg -l cups &>/dev/null | grep -q "^ii"; then
# Install package
clear
echo
echo " INSTALL PRINTING SUPPORT"
echo " ------------------------"
echo " CUPS Printing System is not installed"
echo
while true; do
read -p " Install CUPS? (Y/n) " q;
[ "${q,,}" = "n" ] && exit
([ ! "$q" ] || [ "${q,,}" = "y" ]) && break
done
echo
sudo apt-get install -y cups || exit 1
# Adduser to lpadmin
clear
echo
echo " SELECT USERS FOR ADMIN PRINTERS"
echo " -------------------------------"
echo " Users must allow to lpadmin group in order to admin printers"
echo
read -p " Users (space separated): " ul
for u in $ul; do
sudo adduser $u lpadmin
done
# Open browser
echo
read -p "Press enter to open CUPS admin page"
x-www-browser "http://localhost:631"
# START CUPS
else
echo "CUPS is installed but not running"
read -p "Press enter to try to start CUPS"
sudo systemctl start cups.service
sleep 1
systemctl status cups&>/dev/null && x-www-browser "http://localhost:631"
fi
# OPEN CUPS ADMIN
elif systemctl status cups&>/dev/null; then
x-www-browser "http://localhost:631"
exit
# CALL TO INSTALL CUPS
else
x-terminal-emulator -e "$(readlink -f "$0")" -I
fi