Debian Codegraph @

scripts/sbin/tune-debian-dev-group-perm

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: DRBL utitilty to add users to group plugdev, audio... devices
5 # Ref: http://drbl.org/faq/index.php#path=./2_System&entry=05_usb_sound.faq
6
7 # Load DRBL setting and functions
8 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
9 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
10
11 # Some default setting for Debian
12 # dialout:x:20
13 # cdrom:x:24:
14 # floppy:x:25:
15 # audio:x:29:
16 # video:x:44:
17 # plugdev:x:46:
18
19 prog="$(basenamescip-shell system . . basename. $0)"
20 usagescip-shell shell shell-project 0.0.0 usage().() {
21 echoscip-shell system . . echo. "Enable or disable audio, plugdev permission... to all users."
22 echoscip-shell system . . echo. "Usage: $0 [Options]"
23 echoscip-shell system . . echo. "Options:"
24 language_help_prompt_by_idx_no
25 echoscip-shell system . . echo. "-g, --group [GROUP1, GROUP2...]: Assign the GROUP1, GROUP2... to be process"
26 echoscip-shell system . . echo. "-e, --enable Enable GROUP open to all users"
27 echoscip-shell system . . echo. "-d, --disable Disable GROUP open to all users"
28 echoscip-shell system . . echo. "-n, --no-update-yp Do NOT update YP/NIS"
29 echoscip-shell system . . echo. "-r, --no-restart-prompt Do not show the prompt to restart X"
30 echoscip-shell system . . echo. "-v, --verbose Prints out verbose information"
31 echoscip-shell system . . echo.
32 echoscip-shell system . . echo. "Ex:"
33 echoscip-shell system . . echo. "$0 -g \"$desktop_user_group_debian\" -e"
34 }
35
36 # functions
37 enable_groupscip-shell shell shell-project 0.0.0 enable_group().() {
38 local tune_group="$1"
39 if [scip-shell system . . `[`. -z "$tune_group" ]; then
40 echoscip-shell system . . echo. "No assigned tune group! Skip this!"
41 return 3
42 fi
43 # For new device group, better to use
44 # "find /usr /sbin /bin -group $tune_group -print" to show the related programs.
45 if [scip-shell system . . `[`. -z "$(grepscip-shell system . . grep. -E "^$tune_group:" /etc/groupscip-shell filesystem . . `/etc/group`.)" ]; then
46 echoscip-shell system . . echo. "Group $tune_group does NOT exist! Skip open $tune_group!"
47 return 1
48 fi
49 common_users="$(drbl-get-common-username 2>/dev/nullscip-shell filesystem . . `/dev/null`.)"
50 for iuser in $common_users; do
51 if [scip-shell system . . `[`. "$iuser" != "nobody" -a -z "$(groupsscip-shell system . . groups. $iuser | grepscip-shell system . . grep. $tune_group)" ]; then
52 adduserscip-shell system . . adduser. $iuser $tune_group >/dev/nullscip-shell filesystem . . `/dev/null`.
53 fi
54 done
55 grp_list="$(grepscip-shell system . . grep. -E "^$tune_group:.*" /etc/groupscip-shell filesystem . . `/etc/group`.)"
56 for ihost in $drbl_common_root/ $drblroot/* /scip-shell filesystem . . `/`.; do
57 if [scip-shell system . . `[`. -f $ihost/etc/group ]; then
58 perlscip-shell system . . perl. -p -i -e "s/^$tune_group:.*/$grp_list/g" $ihost/etc/group
59 fi
60 done
61 } # end of enable_group
62
63 disable_groupscip-shell shell shell-project 0.0.0 disable_group().() {
64 local tune_group="$1"
65 if [scip-shell system . . `[`. -z "$tune_group" ]; then
66 echoscip-shell system . . echo. "No assigned tune group! Skip this!"
67 return 3
68 fi
69 if [scip-shell system . . `[`. -z "$(grepscip-shell system . . grep. "^$tune_group:" /etc/groupscip-shell filesystem . . `/etc/group`.)" ]; then
70 echoscip-shell system . . echo. "Group $tune_group does NOT exist! Skip open $tune_group!"
71 return 1
72 fi
73 for ihost in $drbl_common_root/ $drblroot/* /scip-shell filesystem . . `/`.; do
74 if [scip-shell system . . `[`. -f $ihost/etc/group ]; then
75 # TO modify, make them sync
76 perlscip-shell system . . perl. -p -i -e "s/^($tune_group:.*:.*:).*/\$1/g" $ihost/etc/group
77 fi
78 done
79 } # end of disable_group
80
81 #
82 check_if_root
83
84 #
85 while [scip-shell system . . `[`. $# -gt 0 ]; do
86 case "$1" in
87 -e|--enable) shift; MODE="enable" ;;
88 -d|--disable) shift; MODE="disable" ;;
89 -g|--group)
90 shift;
91 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
92 # skip the -xx option, in case
93 GRPS="$1"
94 shift
95 fi
96 ;;
97 -l|--language)
98 shift;
99 if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then
100 # skip the -xx option, in case
101 specified_lang="$1"
102 shift
103 fi
104 ;;
105 -n|--no-update-yp:) shift; YP_UPDATE="no" ;;
106 -r|--no-restart-prompt) shift; RESTART_PROMPT="no" ;;
107 -v|--verbose) shift; VERBOSE="on" ;;
108 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
109 usagescip-shell shell shell-project 0.0.0 usage(). >& 2
110 exit 2 ;;
111 *) break ;;
112 esac
113 done
114
115 #
116 if [scip-shell system . . `[`. ! -e /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ]; then
117 echoscip-shell system . . echo. "This is not Debian Linux! This program only works in Debian Linux!!! Program terminated!"
118 exit 1
119 fi
120 #
121 ask_and_load_lang_set $specified_lang
122
123 [scip-shell system . . `[`. -z "$GRPS" -o -z "$MODE" ] && usagescip-shell shell shell-project 0.0.0 usage(). && exit 1
124
125 echoscip-shell system . . echo. "$msg_delimiter_star_line"
126 # Part 1: For audio device: dsp mixer
127 case "$MODE" in
128 enable)
129 echoscip-shell system . . echo. -n "Adding normal users to group \"$GRPS\"..."
130 for igrp in $GRPS; do
131 echoscip-shell system . . echo. -n "."
132 enable_groupscip-shell shell shell-project 0.0.0 enable_group(). $igrp
133 done
134 echoscip-shell system . . echo. " done!"
135 ;;
136 disable)
137 echoscip-shell system . . echo. -n "Removing normal users from group \"$GRPS\"..."
138 for igrp in $GRPS; do
139 echoscip-shell system . . echo. -n "."
140 disable_groupscip-shell shell shell-project 0.0.0 disable_group(). $igrp
141 done
142 echoscip-shell system . . echo. " done!"
143 ;;
144 esac
145
146 # update YP
147 if [scip-shell system . . `[`. "$YP_UPDATE" != "no" ]; then
148 echoscip-shell system . . echo. "$msg_delimiter_star_line"
149 echoscip-shell system . . echo. "Updating the YP/NIS for group..."
150 makescip-shell system . . make. -C /var/ypscip-shell filesystem . . `/var/yp`. &>/dev/nullscip-shell filesystem . . `/dev/null`.
151 fi
152
153 # restart prompt
154 if [scip-shell system . . `[`. "$RESTART_PROMPT" != "no" ]; then
155 if [scip-shell system . . `[`. "$MODE" = "enable" ]; then
156 echoscip-shell system . . echo. "$msg_delimiter_star_line"
157 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
158 echoscip-shell system . . echo. "$msg_restart_prompt_for_dev"
159 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
160 fi
161 fi
162
163 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
164 if [scip-shell system . . `[`. "$MODE" = "enable" ]; then
165 echoscip-shell system . . echo. "$msg_run_update_dev_again:"
166 echoscip-shell system . . echo. "$prog -g \"$GRPS\" -e"
167 fi
168 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL