blob: bd6665bfd63304ac757d1bcff8a22ff17c3c4801 [file] [log] [blame]
#!/bin/dash
# Copyright 2016 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Crosh command that is only loaded when CUPS is present. Note that
# this command is just a stopgap measure and should be dropped once
# a proper UI is formed. See http://crbug.com/593139
USAGE_cups='[--start | --stop | --status | --restart | --reset]'
HELP_cups='
Start, stop, check the status of, restart, or reset the CUPS daemon. --reset
will stop cupsd (if running) and remove any local state (e.g., saved
printers, jobs, etc.). For initial development only; will be removed in a
future release.
'
cups_initctl() {
sudo /sbin/initctl $1 cupsd
}
cups_reset() {
# Stop the daemon first; ignore errors in case it's already stopped.
cups_initctl "stop" > /dev/null 2>&1
echo "Clearing CUPS daemon state"
sudo rm -rf \
/var/cache/cups/ \
/run/cups/ \
/var/spool/cups/
}
cmd_cups() {
if [ $# -ne 1 ]; then
help "incorrect number of arguments: $@"
return 1
fi
case "$1" in
"--start")
cups_initctl "start"
;;
"--stop")
cups_initctl "stop"
;;
"--status")
cups_initctl "status"
;;
"--restart")
cups_initctl "restart"
;;
"--reset")
cups_reset
;;
*)
help "unknown option: $1"
return 1
esac
}