1#!/bin/sh
2
3PATH="/bin:/sbin:/usr/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:."
4
5# check if we are root
6if [ "$(id -u)" != "0" ]; then
7	echo "You must run this script as root..."
8	exit 1
9fi
10
11job=0
12
13echo "Checking what needs to be done"
14
15# check for parport devices
16if [ ! -c /dev/parport0 ]; then
17	echo "Creating parport devices"
18	DIR=`pwd`
19	cd /dev
20	MAKEDEV parport
21	cd $DIR
22	job=1
23fi
24
25# check for kernel modules
26if ! lsmod|grep parport > /dev/null; then
27	echo "Loading parport modules"
28	modprobe parport_pc
29	modprobe parport
30	job=1
31fi
32
33if lsmod|grep lp|grep " 0 " > /dev/null; then
34	echo "Unloading lp module"
35	rmmod lp
36	job=1
37fi
38
39if ! lsmod|grep ppdev > /dev/null; then
40	echo "Loading ppdev module"
41	modprobe ppdev
42	job=1
43fi
44
45if [ $job -eq 1 ]; then
46	echo "Setup is ready"
47else
48	echo "Nothing to do, your setup is okay"
49fi
50
51echo "Please run \"cwdaemon -n\" (as root) for diagnosis"
52