Debian Codegraph @

sbin/Forcevideo-drbl-live

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: From X version 7.3, "dpkg-reconfigure xserver-xorg" won't ask about VGA driver and screeen resolution, therefore we have to drop the "dpkg-reconfigure xserver-xorg" mechanism.
5 # Ref: http://forums.debian.net/viewtopic.php?t=26577
6
7 # Load DRBL setting and functions
8 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
9
10 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
11 [scip-shell system . . `[`. -e /etc/drbl/drbl-ocs.confscip-shell filesystem . . `/etc/drbl/drbl-ocs.conf`. ] && . /etc/drbl/drbl-ocs.confscip-shell source . . `/etc/drbl/drbl-ocs.conf`.
12 [scip-shell system . . `[`. -e $DRBL_SCRIPT_PATH/sbin/ocs-functions ] && . $DRBL_SCRIPT_PATH/sbin/ocs-functions
13
14 # Load ocs_lang if it exists
15 [scip-shell system . . `[`. -e /etc/ocs/ocs-live.confscip-shell filesystem . . `/etc/ocs/ocs-live.conf`. ] && . /etc/ocs/ocs-live.confscip-shell source . . `/etc/ocs/ocs-live.conf`.
16
17 #
18 check_if_rootscip-shell shell shell-project 0.0.0 check_if_root().
19
20 # Get the live media mount point.
21 get_live_media_mnt_point
22
23 #
24 ask_and_load_lang_set
25
26 #
27 if [scip-shell system . . `[`. -z "$LIVE_MEDIA" -o ! -d "/$LIVE_MEDIA" ]; then
28 echoscip-shell system . . echo. "$0 should be run in DRBL Live!"
29 echoscip-shell system . . echo. "Program terminated!"
30 exit 1
31 fi
32
33 #
34 if ! type X >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
35 echoscip-shell system . . echo. "No X program! Skip X configure!"
36 exit 3
37 fi
38
39 # Default settings
40 xconf="/etc/X11/xorg.confscip-shell filesystem . . `/etc/X11/xorg.conf`."
41 start_x="yes"
42
43 # functions
44 USAGEscip-shell shell shell-project 0.0.0 USAGE().() {
45 echoscip-shell system . . echo. "Usage:"
46 echoscip-shell system . . echo. "To configure X config"
47 echoscip-shell system . . echo. "$0 [OPTION]"
48 echoscip-shell system . . echo. "OPTION:"
49 echoscip-shell system . . echo. "-s, --skip-start-x After xorg.conf is created, skip asking if want to start X"
50 } # end of USAGE
51 # Check if root or not
52 check_if_rootscip-shell shell shell-project 0.0.0 check_if_root().() {
53 if [scip-shell system . . `[`. ! "$UID" = "0" ]; then
54 echoscip-shell system . . echo.
55 echoscip-shell system . . echo. "[$LOGNAME] You need to run this script \"`basenamescip-shell system . . basename. $0`\" as root."
56 echoscip-shell system . . echo.
57 exit 1
58 fi
59 } # end of check_if_root
60 #
61 set_priorityscip-shell shell shell-project 0.0.0 set_priority().() {
62 echoscip-shell system . . echo. '*****************************************************'
63 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
64 echoscip-shell system . . echo. "Which mode do you want when configuring X ?"
65 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
66 echoscip-shell system . . echo. "0: Beginner mode, use whatever the default priority of question is."
67 echoscip-shell system . . echo. "1: Medium mode."
68 echoscip-shell system . . echo. "2: Expert mode, very verbose."
69 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
70 echoscip-shell system . . echo. "///NOTE/// If graphical environment (X-window) fails to start, you can:"
71 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
72 echoscip-shell system . . echo. " (a): Run \"sudo $0\" to configure it again. Use '1: Medium mode' or '2: Expert mode', then say 'no' to 'Attempt to autodetect video buffer' so that you can choose 'vesa' as the X server driver. When 'Attempt monitor autodetection', say 'no' either so that you can choose 1024x768, 800x600 or 640x480 as your resolution. For the rest of settings, you can accept the default values if you have no idea about them."
73 echoscip-shell system . . echo. " (b): Run \"sudo service lightdm restart\" to enter graphical environment."
74 echoscip-shell system . . echo. -n "[0] "
75 read ans_ver
76 case "$ans_ver" in
77 # Beginner means only ask high priority question
78 # Expert means ask low priority question
79 1) PRIORITY="medium" ;;
80 2) PRIORITY="low" ;;
81 *) PRIORITY="high" ;;
82 esac
83 } # end of set_priority
84 #
85 choose_resolutionscip-shell shell shell-project 0.0.0 choose_resolution().() {
86 echoscip-shell system . . echo. '*****************************************************'
87 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
88 echoscip-shell system . . echo. "$msg_program_to_create_X_config_with_60_Hz"
89 echoscip-shell system . . echo. "$msg_which_resolution_do_u_want"
90 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
91 echoscip-shell system . . echo. "0: 640x480"
92 echoscip-shell system . . echo. "1: 800x600"
93 echoscip-shell system . . echo. "2: 1024x768"
94 echoscip-shell system . . echo. "3: 1152x864"
95 echoscip-shell system . . echo. "4: 1280x800"
96 echoscip-shell system . . echo. "5: 1280x960"
97 echoscip-shell system . . echo. "6: 1280x1024"
98 echoscip-shell system . . echo. "7: 1440x1080"
99 echoscip-shell system . . echo. -n "[2] "
100 read ans_res
101 case "$ans_res" in
102 0) gtf_param="640 480 60"
103 pmode="640x480"
104 ;;
105 1) gtf_param="800 600 60"
106 pmode="800x600"
107 ;;
108 3) gtf_param="1152 864 60"
109 pmode="1152x864"
110 ;;
111 4) gtf_param="1280 800 60"
112 pmode="1280x800"
113 ;;
114 5) gtf_param="1280 960 60"
115 pmode="1280x960"
116 ;;
117 6) gtf_param="1280 1024 60"
118 pmode="1280x1024"
119 ;;
120 7) gtf_param="1440 1080 60"
121 pmode="1440x1080"
122 ;;
123 *) gtf_param="1024 768 60"
124 pmode="1024x768"
125 ;;
126 esac
127 echoscip-shell system . . echo. '*****************************************************'
128 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
129 echoscip-shell system . . echo. "$msg_which_vga_card_driver"
130 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
131 echoscip-shell system . . echo. -n "[vesa] "
132 read ans_vga
133 case "$ans_vga" in
134 "") vga_driver="vesa" ;;
135 *) vga_driver="$ans_vga" ;;
136 esac
137 echoscip-shell system . . echo. '*****************************************************'
138 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
139 echoscip-shell system . . echo. "$msg_which_color_depth_do_u_want"
140 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
141 echoscip-shell system . . echo. "0: 24"
142 echoscip-shell system . . echo. "1: 16"
143 echoscip-shell system . . echo. "2: 15"
144 echoscip-shell system . . echo. "3: 8"
145 echoscip-shell system . . echo. -n "[0] "
146 read ans_dep
147 case "$ans_dep" in
148 1) depth="16" ;;
149 2) depth="15" ;;
150 3) depth="8" ;;
151 *) depth="24" ;;
152 esac
153 } # end of choose_resolution
154 #
155 gen_xorg.confscip-shell shell shell-project 0.0.0 `gen_xorg.conf`().() {
156 catscip-shell system . . cat. <<-XCONF_END > $xconf
157 # xorg.conf (X.Org X Window System server configuration file)
158 #
159 # This file was generated by DRBL live.
160 #
161 # Edit this file with caution, and see the xorg.conf manual page.
162
163 Section "InputDevice"
164 # ///NOTE/// The keyboard layout will be overwritten when enter X by loadkey command. Therefore here this section is useless. Just for the X to start normally.
165 Identifier "Generic Keyboard"
166 Driver "kbd"
167 Option "XkbRules" "xorg"
168 Option "XkbModel" "pc104"
169 Option "XkbLayout" "us"
170 EndSection
171
172 Section "InputDevice"
173 Identifier "Configured Mouse"
174 Driver "mouse"
175 EndSection
176
177 Section "Device"
178 Identifier "Configured Video Device"
179 XCONF_END
180
181 catscip-shell system . . cat. <<-XCONF_END >> $xconf
182 Driver "$vga_driver"
183 EndSection
184
185 XCONF_END
186
187 catscip-shell system . . cat. <<-XCONF_END >> $xconf
188 Section "Monitor"
189 Identifier "Configured Monitor"
190 XCONF_END
191
192 gtf $gtf_param >> $xconf
193
194 catscip-shell system . . cat. <<-XCONF_END >> $xconf
195 Option "PreferredMode" "$pmode"
196 XCONF_END
197
198 catscip-shell system . . cat. <<-XCONF_END >> $xconf
199 EndSection
200
201 Section "Screen"
202 Identifier "Default Screen"
203 Monitor "Configured Monitor"
204 DefaultDepth $depth
205 SubSection "Display"
206 Depth $depth
207 Modes "$pmode"
208 EndSubSection
209 EndSection
210
211 XCONF_END
212 } # end of gen_xorg.conf
213 #
214 reconfig_Xorgscip-shell shell shell-project 0.0.0 reconfig_Xorg().() {
215 local xver RC
216 xver="$(dpkg-queryscip-shell system . . dpkg-query. -W --showformat '${Version}\n' xserver-xorg | awkscip-shell system . . awk. -F":" '{print $2}')"
217 # Ref: https://bugs.launchpad.net/bugs/207409
218 if dpkgscip-shell system . . dpkg. --compare-versions "$xver" ">=" "7.3"; then
219 choose_resolutionscip-shell shell shell-project 0.0.0 choose_resolution().
220 gen_xorg.confscip-shell shell shell-project 0.0.0 `gen_xorg.conf`().
221 echoscip-shell system . . echo. "$xconf was created."
222 [scip-shell system . . `[`. -e "$xconf" ] && RC=0
223 else
224 # For old version, we can use dpkg-reconfigure xserver-xorg
225 set_priorityscip-shell shell shell-project 0.0.0 set_priority().
226 echoscip-shell system . . echo. -n "Running \"dpkg-reconfigure --priority=$PRIORITY xserver-xorg\"... "
227 LC_ALL=C dpkg-reconfigurescip-shell system . . dpkg-reconfigure. --priority=$PRIORITY xserver-xorg
228 RC=$?
229 fi
230 if [scip-shell system . . `[`. "$RC" -eq 0 ]; then
231 echoscip-shell system . . echo. "X is now configured."
232 else
233 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
234 echoscip-shell system . . echo. "Failed to configure X config file."
235 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
236 echoscip-shell system . . echo. "$msg_program_stop"
237 exit 1
238 fi
239 } # end of reconfig_Xorg
240
241 ############
242 ### MAIN ###
243 ############
244
245 check_if_rootscip-shell shell shell-project 0.0.0 check_if_root().
246
247 #
248 while [scip-shell system . . `[`. $# -gt 0 ]; do
249 case "$1" in
250 -s|--skip-start-x)
251 start_x="no"
252 shift ;;
253 -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2
254 USAGEscip-shell shell shell-project 0.0.0 USAGE(). >& 2
255 exit 2 ;;
256 *) break ;;
257 esac
258 done
259
260 # Clean the old config if exists before reconfigure. It must be empty otherwise the setting we append won't work.
261 rmscip-shell system . . rm. -f $xconf
262 reconfig_Xorgscip-shell shell shell-project 0.0.0 reconfig_Xorg().
263
264 #
265 if [scip-shell system . . `[`. "$start_x" = "yes" ]; then
266 echoscip-shell system . . echo. '*****************************************************'
267 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
268 echoscip-shell system . . echo. "Do you want to run \"sudo service lightdm restart\" to enter graphical environment ?"
269 [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
270 echoscip-shell system . . echo. -n "[Y/n] "
271 read enter_X
272 case "$enter_X" in
273 n|N|[nN][oO])
274 exit 1
275 ;;
276 *)
277 sudoscip-shell system . . sudo. service lightdm restart
278 ;;
279 esac
280 fi