Changeset 43832 in vbox for trunk/src/VBox/Installer/linux
- Timestamp:
- Nov 7, 2012 2:37:42 PM (12 years ago)
- Location:
- trunk/src/VBox/Installer/linux
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/VBoxHeadlessXOrg.sh
r43797 r43832 69 69 rendering. We only support X.Org Server at the moment. Starting the X servers 70 70 is managed by dropping one or more files xorg.conf.<n> into a configuration 71 directory (by default ${DEFAULT_CONFIGURATION_FOLDER} -this can be overridden71 directory, by default ${DEFAULT_CONFIGURATION_FOLDER}, but this can be overridden 72 72 in the configuration file (see below). We will attempt to start an X server 73 73 process for each configuration file using display number <n>. … … 76 76 77 77 -c|--conf-file) Specify an alternative locations for the configuration 78 file. The default location is \"${CONFIGURATION_FILE}\".78 file. The default location is "${CONFIGURATION_FILE}". 79 79 80 80 --help|--usage Print this text. … … 119 119 120 120 HEADLESS_X_ORG_SERVER_COMMAND 121 The default X server start-up command, containing the variables "${screen}" 122 for the screen number, "${conf_file}" for the configuration file path and 123 ${log_file} for the log file. The variables must be quoted for expansion 124 at evaluation time, e.g. 125 HEADLESS_X_ORG_SERVER_COMMAND="Xorg :\${screen} [...] > \"\${log_file}\" 121 The default X server start-up command. It will be passed three parameters 122 - in order, the screen number to use, the path of the X.Org configuration 123 file to use and the path of the X server log file to create. 126 124 127 125 HEADLESS_X_ORG_SERVER_POST_COMMAND … … 129 127 default this stores the service configuration information to VirtualBox 130 128 extra data for each of the users in the list \${HEADLESS_X_ORG_USERS}. 131 132 HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE 133 The default X server log file name, containing the variable "\${screen}" for 134 the screen number. The variable must be quoted for expansion at evaluation 135 time, e.g. 136 HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE="Xorg.\${screen}.log" 129 It will be passed a single parameter which is a space-separated list of the 130 X server screen numbers. 137 131 EOF 138 132 } … … 144 138 HEADLESS_X_ORG_RUN_FOLDER="/var/run/${SERVICE_NAME}" 145 139 HEADLESS_X_ORG_CHECK_PREREQUISITES="udevadm settle || ! udevadm -V" 140 HEADLESS_X_ORG_USERS="" 141 146 142 X_AUTH_FILE="${HEADLESS_X_ORG_RUN_FOLDER}/xauth" 147 HEADLESS_X_ORG_SERVER_PRE_COMMAND="echo > \"${X_AUTH_FILE}\"; xauth -f \"${X_AUTH_FILE}\" add :0 . \"\$(dd if=/dev/urandom count=1 bs=16 2>/dev/null | od -An -x)\"; for i in ${HEADLESS_X_ORG_USERS}; do cp \"${X_AUTH_FILE}\" \"${X_AUTH_FILE}.${i}\"; chown \"${i}\" \"${X_AUTH_FILE}.${i}\"; done" 148 HEADLESS_X_ORG_SERVER_COMMAND="Xorg :\${screen} -auth \"${HEADLESS_X_ORG_RUN_FOLDER}/xauth\" -config \"\${conf_file}\" -logverbose 0 -logfile /dev/null -verbose 7 > \"\${log_file}\" 2>&1" 149 HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE="Xorg.\${screen}.log" 143 default_pre_command() 144 { 145 echo > "${X_AUTH_FILE}" 146 key="$(dd if=/dev/urandom count=1 bs=16 2>/dev/null | od -An -x)" 147 xauth -f "${X_AUTH_FILE}" add :0 . "${key}" 148 for i in ${HEADLESS_X_ORG_USERS}; do 149 cp "${X_AUTH_FILE}" "${X_AUTH_FILE}.${i}" 150 chown "${i}" "${X_AUTH_FILE}.${i}" 151 done 152 } 153 HEADLESS_X_ORG_SERVER_PRE_COMMAND="default_pre_command" 154 155 default_command() 156 { 157 auth="${HEADLESS_X_ORG_RUN_FOLDER}/xauth" 158 # screen=$1 159 # conf_file=$2 160 # log_file=$3 161 Xorg :"${1}" -auth "${auth}" -config "${2}" -logverbose 0 -logfile /dev/null -verbose 7 > "${3}" 2>&1 162 } 163 HEADLESS_X_ORG_SERVER_COMMAND="default_command" 164 165 default_post_command() 166 { 167 # screens=$1 168 for i in ${HEADLESS_X_ORG_USERS}; do 169 su ${i} -c "VBoxManage setextradata global HeadlessXServer/Screens \"${1}\"" 170 su ${i} -c "VBoxManage setextradata global HeadlessXServer/AuthFile \"${HEADLESS_X_ORG_RUN_FOLDER}/xauth\"" 171 done 172 } 173 HEADLESS_X_ORG_SERVER_POST_COMMAND="default_post_command" 150 174 151 175 ## The function definition at the start of every non-trivial shell script! … … 248 272 249 273 X_SERVER_PIDS="" 274 X_SERVER_SCREENS="" 250 275 trap "kill \${X_SERVER_PIDS} 2>/dev/null" ${EXIT_SIGNALS} 251 276 space="" # Hack to put spaces between the pids but not before or after. … … 258 283 [ 0 -le "${screen}" ] 2>/dev/null || 259 284 abort "Badly formed file name \"${conf_file}\".\n" 260 log_file="${HEADLESS_X_ORG_LOG_FOLDER}/ $(eval echo "${HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE}")"261 eval "${HEADLESS_X_ORG_SERVER_COMMAND} " "&"285 log_file="${HEADLESS_X_ORG_LOG_FOLDER}/Xorg.${screen}.log" 286 eval "${HEADLESS_X_ORG_SERVER_COMMAND} \"\${screen}\" \"\${conf_file}\" \"\${log_file}\"" "&" 262 287 X_SERVER_PIDS="${X_SERVER_PIDS}${space}$!" 288 X_SERVER_SCREENS="${X_SERVER_SCREENS}${space}${screen}" 263 289 space=" " 264 290 done 265 291 266 292 # Do any post-start work. 267 eval "${HEADLESS_X_ORG_SERVER_POST_COMMAND} "293 eval "${HEADLESS_X_ORG_SERVER_POST_COMMAND} \"${X_SERVER_SCREENS}\"" 268 294 269 295 wait -
trunk/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
r43797 r43832 69 69 HEADLESS_X_ORG_CHECK_PREREQUISITES= 70 70 HEADLESS_X_ORG_SERVER_PRE_COMMAND= 71 HEADLESS_X_ORG_SERVER_COMMAND="echo \\\${screen} \\\${conf_file} \\\${log_file}" 72 HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE="log.\\\${screen}" 71 HEADLESS_X_ORG_SERVER_COMMAND="echo" 73 72 EOF 74 73 … … 95 94 # Create a temporary directory for configuration and logging. 96 95 for i in 0 1 2 3 4 5 6 7 8 9; do 97 TEST_FOLDER="/tmp/${TEST_NAME} ${i}"96 TEST_FOLDER="/tmp/${TEST_NAME} ${i}" # Space in the name to test quoting. 98 97 mkdir -m 0700 "${TEST_FOLDER}" 2>/dev/null && break 99 98 done … … 105 104 mkdir -p "${XORG_FOLDER}" 106 105 107 # Simple start-up test. 106 ############################################################################### 107 # Simple start-up test. # 108 ############################################################################### 108 109 print_line "simple start-up test" 109 110 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" … … 118 119 LOG_FOLDER="${TEST_FOLDER}/log" 119 120 LOG="${LOG_FOLDER}/log" 120 if grep -q "2 ${XORG_FOLDER}/xorg.conf.2 ${LOG_FOLDER}/ log.2" "${LOG}" &&121 grep -q "4 ${XORG_FOLDER}/xorg.conf.4 ${LOG_FOLDER}/ log.4" "${LOG}"; then121 if grep -q "2 ${XORG_FOLDER}/xorg.conf.2 ${LOG_FOLDER}/Xorg.2.log" "${LOG}" && 122 grep -q "4 ${XORG_FOLDER}/xorg.conf.4 ${LOG_FOLDER}/Xorg.4.log" "${LOG}"; then 122 123 printf "SUCCESS.\n" 123 124 else … … 135 136 rm "${XORG_FOLDER}"/xorg.conf.* 136 137 137 # No configuration files. 138 ############################################################################### 139 # No configuration files. # 140 ############################################################################### 138 141 print_line "no configuration files" 139 142 … … 154 157 expect_exit "${PID}" 5 test_should_fail 155 158 156 # Bad configuration files. 159 ############################################################################### 160 # Bad configuration files. # 161 ############################################################################### 157 162 print_line "bad configuration files" 158 163 touch "${XORG_FOLDER}/xorg.conf.2" … … 164 169 rm "${XORG_FOLDER}/"xorg.conf.* 165 170 171 ############################################################################### 172 # Long running server command. # 173 ############################################################################### 174 166 175 # Set up a configuration file for a long-running command. 167 176 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" 168 177 cat >> "${TEST_FOLDER}/conf" << EOF 169 HEADLESS_X_ORG_SERVER_COMMAND="\"${TEST_NAME_FULL}\" --test-sleep \\\${screen}" 170 EOF 171 172 # Long running server command. 178 HEADLESS_X_ORG_SERVER_COMMAND="\"${TEST_NAME_FULL}\" --test-sleep" 179 EOF 180 173 181 print_line "long running server command (sleeps)" 174 182 touch "${XORG_FOLDER}/xorg.conf.1" … … 208 216 rm "${XORG_FOLDER}/"xorg.conf.* 209 217 218 ############################################################################### 219 # Pre-requisite test. # 220 ############################################################################### 221 210 222 # Set up a configuration file with a pre-requisite. 211 223 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" … … 214 226 EOF 215 227 216 # Pre-requisite test.217 228 print_line "configuration file with pre-requisite (sleeps)" 218 229 touch "${XORG_FOLDER}/xorg.conf.2" … … 231 242 rm -r "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}/run" 232 243 244 ############################################################################### 245 # Pre-command test. # 246 ############################################################################### 247 233 248 # Set up our pre-command test configuration file. 234 249 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" 250 235 251 cat >> "${TEST_FOLDER}/conf" << EOF 252 test_pre_command_server_command() 253 { 254 cp "${TEST_FOLDER}/run/pre" "${TEST_FOLDER}/run/pre2" 255 } 236 256 HEADLESS_X_ORG_SERVER_PRE_COMMAND="touch \"${TEST_FOLDER}/run/pre\"" 237 HEADLESS_X_ORG_SERVER_COMMAND="cp \"${TEST_FOLDER}/run/pre\" \"${TEST_FOLDER}/run/pre2\"" 238 EOF 239 240 # Pre-command test. 257 HEADLESS_X_ORG_SERVER_COMMAND="test_pre_command_server_command" 258 EOF 259 241 260 print_line "pre-command test" 242 261 touch "${XORG_FOLDER}/xorg.conf.2" … … 266 285 rm -f "${XORG_FOLDER}"/xorg.conf.* "${TEST_FOLDER}"/run/pre* 267 286 287 ############################################################################### 288 # Post-command test. # 289 ############################################################################### 290 268 291 # Set up our post-command test configuration file. 269 292 create_basic_configuration_file "${TEST_FOLDER}/conf" "${TEST_FOLDER}" 270 293 cat >> "${TEST_FOLDER}/conf" << EOF 271 HEADLESS_X_ORG_SERVER_COMMAND="rm -f \"${TEST_FOLDER}/run/post\"" 272 HEADLESS_X_ORG_SERVER_POST_COMMAND="touch \"${TEST_FOLDER}/run/post\"" 273 EOF 274 275 # Post-command test. 294 test_post_command_post_command() 295 { 296 echo "\${1}" > "${TEST_FOLDER}/run/post" 297 } 298 HEADLESS_X_ORG_SERVER_POST_COMMAND="test_post_command_post_command" 299 EOF 300 276 301 print_line "post-command test" 277 302 touch "${XORG_FOLDER}/xorg.conf.2" … … 285 310 LOG_FOLDER="${TEST_FOLDER}/log" 286 311 LOG="${LOG_FOLDER}/log" 287 if [ -e "${TEST_FOLDER}/run/post" ]; then312 if grep -q "2 4" "${TEST_FOLDER}/run/post"; then 288 313 printf "SUCCESS.\n" 289 314 else
Note:
See TracChangeset
for help on using the changeset viewer.