File: freebsd-install

package info (click to toggle)
foo2zjs 20171202dfsg0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 9,320 kB
  • sloc: ansic: 40,789; xml: 12,512; sh: 7,385; makefile: 1,705; objc: 573; tcl: 173; perl: 102; python: 8
file content (103 lines) | stat: -rwxr-xr-x 1,473 bytes parent folder | download | duplicates (4)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh

PROGNAME="$0"

usage() {
	cat <<EOF
NAME
    `basename $PROGNAME` - freebsd-install

SYNOPSIS
    `basename $PROGNAME` [options]

DESCRIPTION
    freebsd-install

OPTIONS
    -D lvl	Debug level
EOF

	exit 1
}

#
#       Report an error and exit
#
error() {
	echo "`basename $PROGNAME`: $1" >&2
	exit 1
}

debug() {
	if [ $DEBUG -ge $1 ]; then
	    echo "`basename $PROGNAME`: $2" >&2
	fi
}

#
#       Process the options
#
DEBUG=0
while getopts "D:h?" opt
do
	case $opt in
	D)	DEBUG="$OPTARG";;
	h|\?)	usage;;
	esac
done
shift `expr $OPTIND - 1`

#
#	Main Program
#
RULES=/tmp/devfs.rules
RC_CONF=/tmp/rc.conf
RULES=/etc/devfs.rules
RC_CONF=/etc/rc.conf

RULESET_NAME=printers_foo2zjs
RULESET_NUM=42
RULESET="[$RULESET_NAME=$RULESET_NUM]"

#
#	Create devfs.rules
#
touch $RULES
if grep -s -q "Begin $RULESET_NAME" $RULES; then
	ex - $RULES <<-EOF
	/^# Begin $RULESET_NAME.*/,/^# End $RULESET_NAME.*/d
	w
	q
	EOF
fi
ex - $RULES <<-EOF
a
# Begin $RULESET_NAME (added by foo2zjs/freebsd-install)
$RULESET
add path 'ulpt*' mode 0666 group cups
add path 'unlpt*' mode 0666 group cups
add path 'ugen*' mode 0666 group cups
add path 'usb/*' mode 0666 group cups
# End $RULESET_NAME (added by foo2zjs/freebsd-install)
.
w
q
EOF

#
#	Add:	devfs_system_ruleset="printers_foo2zjs"
#
if grep -q -s $RULESET_NAME $RC_CONF; then
	ex - $RC_CONF <<-EOF
	/devfs_system_ruleset="$RULESET_NAME"/d
	w
	q
	EOF
fi
ex - $RC_CONF <<-EOF
a
devfs_system_ruleset="$RULESET_NAME"
.
w
q
EOF