- Timestamp:
- Jul 3, 2015 12:34:24 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 101427
- Location:
- trunk/src/VBox/Installer/linux
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/linux/Makefile.kmk
r56299 r56777 70 70 scripts/VBoxHeadlessXOrg.sh=>scripts/VBoxHeadlessXOrg.sh \ 71 71 VBoxSysInfo.sh \ 72 vboxautostart-service.sh \ 73 vboxballoonctrl-service.sh \ 72 74 VBoxCreateUSBNode.sh \ 75 vboxweb-service.sh \ 73 76 VBox.sh=>VBox.sh \ 74 77 $(if $(VBOX_WITH_PYTHON),$(PATH_ROOT)/src/VBox/Frontends/VBoxShell/vboxshell.py=>vboxshell.py,) … … 79 82 linux-scripts_SOURCES = \ 80 83 deffiles \ 84 install-common.sh \ 85 postinst-common.sh \ 81 86 routines.sh \ 82 87 uninstall.sh \ … … 203 208 ExtensionPacks/VNC/ExtPack-license.txt,) \ 204 209 VBoxSysInfo.sh \ 210 vboxautostart-service.sh \ 211 vboxballoonctrl-service.sh \ 205 212 VBoxCreateUSBNode.sh \ 213 vboxdrv.sh \ 206 214 VBox.sh \ 215 vboxweb-service.sh \ 207 216 VBox.png \ 208 217 scripts … … 372 381 --output $@ \ 373 382 $< 383 384 $(PATH_STAGE_BIN)/vboxdrv.sh: $(VBOX_PATH_LNX_INST_SRC)/vboxdrv.sh.in | $$(dir $$@) 385 $(QUIET)$(SED_EXT) \ 386 -e "s|%VERSION%|$(VBOX_VERSION_STRING)|g" \ 387 -e "s|%GROUP%|$(if $(VBOX_WITHOUT_HARDENING),vboxusers,root)|g" \ 388 --output $@ \ 389 $< 390 $(QUIET)$(CHMOD) 0755 $@ 374 391 375 392 $(VBOX_LNX_INST_OUT_DIR)/install.sh: $(VBOX_PATH_LNX_INST_SRC)/install.sh $(VBOX_PATH_LNX_INST_SRC)/installer-common.sh $(VBOX_VERSION_STAMP) $(VBOX_SVN_REV_KMK).ts | $$(dir $$@) -
trunk/src/VBox/Installer/linux/install.sh
r56299 r56777 384 384 install_init_script vboxautostart-service.sh vboxautostart-service 385 385 install_init_script vboxweb-service.sh vboxweb-service 386 387 # Write the configuration. Do this before we call /etc/init.d/vboxdrv setup! 388 echo "# VirtualBox installation directory" > $CONFIG_DIR/$CONFIG 389 echo "INSTALL_DIR='$INSTALLATION_DIR'" >> $CONFIG_DIR/$CONFIG 390 echo "# VirtualBox version" >> $CONFIG_DIR/$CONFIG 391 echo "INSTALL_VER='$VERSION'" >> $CONFIG_DIR/$CONFIG 392 echo "INSTALL_REV='$SVNREV'" >> $CONFIG_DIR/$CONFIG 393 echo "# Build type and user name for logging purposes" >> $CONFIG_DIR/$CONFIG 394 echo "BUILD_TYPE='$BUILD_BUILDTYPE'" >> $CONFIG_DIR/$CONFIG 395 echo "USERNAME='$BUILD_USERNAME'" >> $CONFIG_DIR/$CONFIG 396 386 397 delrunlevel vboxdrv > /dev/null 2>&1 387 addrunlevel vboxdrv 20 80# This may produce useful output398 addrunlevel vboxdrv # This may produce useful output 388 399 delrunlevel vboxballoonctrl-service > /dev/null 2>&1 389 addrunlevel vboxballoonctrl-service 25 75# This may produce useful output400 addrunlevel vboxballoonctrl-service # This may produce useful output 390 401 delrunlevel vboxautostart-service > /dev/null 2>&1 391 addrunlevel vboxautostart-service 25 75# This may produce useful output402 addrunlevel vboxautostart-service # This may produce useful output 392 403 delrunlevel vboxweb-service > /dev/null 2>&1 393 addrunlevel vboxweb-service 25 75# This may produce useful output404 addrunlevel vboxweb-service # This may produce useful output 394 405 395 406 # Create users group … … 461 472 install_device_node_setup "$VBOXDRV_GRP" "$VBOXDRV_MODE" "$INSTALLATION_DIR" 462 473 463 # Write the configuration. Do this before we call /etc/init.d/vboxdrv setup!464 echo "# VirtualBox installation directory" > $CONFIG_DIR/$CONFIG465 echo "INSTALL_DIR='$INSTALLATION_DIR'" >> $CONFIG_DIR/$CONFIG466 echo "# VirtualBox version" >> $CONFIG_DIR/$CONFIG467 echo "INSTALL_VER='$VERSION'" >> $CONFIG_DIR/$CONFIG468 echo "INSTALL_REV='$SVNREV'" >> $CONFIG_DIR/$CONFIG469 echo "# Build type and user name for logging purposes" >> $CONFIG_DIR/$CONFIG470 echo "BUILD_TYPE='$BUILD_BUILDTYPE'" >> $CONFIG_DIR/$CONFIG471 echo "USERNAME='$BUILD_USERNAME'" >> $CONFIG_DIR/$CONFIG472 473 474 # Make kernel module 474 475 MODULE_FAILED="false" -
trunk/src/VBox/Installer/linux/routines.sh
r56299 r56777 18 18 ro_KDE_AUTOSTART="/usr/share/autostart" 19 19 20 # Aborts the script and prints an error message to stderr.20 ## Aborts the script and prints an error message to stderr. 21 21 # 22 22 # syntax: abort message 23 23 24 abort() { 24 abort() 25 { 25 26 echo 1>&2 "$1" 26 27 exit 1 27 28 } 28 29 29 # Creates an empty log file and remembers the name for future logging30 ## Creates an empty log file and remembers the name for future logging 30 31 # operations 31 # 32 # syntax: create_log logfile 33 34 create_log() { 32 create_log() 33 { 34 ## The path of the file to create. 35 35 ro_LOG_FILE="$1" 36 36 if [ "$ro_LOG_FILE" = "" ]; then … … 44 44 } 45 45 46 # Writes text to standard error46 ## Writes text to standard error 47 47 # 48 48 # Syntax: info text 49 50 info(){49 info() 50 { 51 51 echo 1>&2 "$1" 52 52 } 53 53 54 # Writes text to the log file54 ## Writes text to the log file 55 55 # 56 56 # Syntax: log text 57 58 log(){57 log() 58 { 59 59 if [ "$ro_LOG_FILE" = "" ]; then 60 60 abort "Error! Logging has not been set up yet! Aborting..." … … 64 64 } 65 65 66 # Writes test to standard output and to the log file66 ## Writes test to standard output and to the log file 67 67 # 68 68 # Syntax: infolog text 69 70 infolog(){69 infolog() 70 { 71 71 info "$1" 72 72 log "$1" 73 73 } 74 74 75 # Checks whether a module is loaded with a given string in its name.75 ## Checks whether a module is loaded with a given string in its name. 76 76 # 77 77 # syntax: module_loaded string 78 79 module_loaded(){78 module_loaded() 79 { 80 80 if [ "$1" = "" ]; then 81 81 log "module_loaded called without an argument. Aborting..." … … 85 85 } 86 86 87 # Abort if we are not running as root88 89 check_root(){87 ## Abort if we are not running as root 88 check_root() 89 { 90 90 if [ `id -u` -ne 0 ]; then 91 91 abort "This program must be run with administrator privileges. Aborting" … … 93 93 } 94 94 95 # Abort if a copy of VirtualBox is already running96 97 check_running(){95 ## Abort if a copy of VirtualBox is already running 96 check_running() 97 { 98 98 VBOXSVC_PID=`pidof VBoxSVC 2> /dev/null` 99 99 if [ -n "$VBOXSVC_PID" ]; then … … 109 109 } 110 110 111 # Do we have bzip2?112 113 check_bzip2(){111 ## Do we have bzip2? 112 check_bzip2() 113 { 114 114 if ! ls /bin/bzip2 /usr/bin/bzip2 /usr/local/bin/bzip2 2> /dev/null | grep bzip2 > /dev/null; then 115 115 echo 1>&2 "Please install the bzip2 utility." … … 120 120 } 121 121 122 # Do we have GNU make?123 124 check_gmake(){122 ## Do we have GNU make? 123 check_gmake() 124 { 125 125 make --version 2>&1 | grep GNU > /dev/null 126 126 if [ ! $? = 0 ]; then … … 132 132 } 133 133 134 # Can we find the kernel source?135 136 check_ksource(){134 ## Can we find the kernel source? 135 check_ksource() 136 { 137 137 ro_KBUILD_DIR=/lib/modules/`uname -r`/build 138 138 if [ ! -d $ro_KBUILD_DIR/include ]; then … … 151 151 } 152 152 153 # Is GCC installed?154 155 check_gcc(){153 ## Is GCC installed? 154 check_gcc() 155 { 156 156 ro_gcc_version=`gcc --version 2> /dev/null | head -n 1` 157 157 if [ "$ro_gcc_version" = "" ]; then … … 163 163 } 164 164 165 # Is bash installed? You never know...166 167 check_bash(){165 ## Is bash installed? You never know... 166 check_bash() 167 { 168 168 if [ ! -x /bin/bash ]; then 169 169 echo 1>&2 "Please install GNU bash." … … 174 174 } 175 175 176 # Is perl installed?177 178 check_perl(){176 ## Is perl installed? 177 check_perl() 178 { 179 179 if [ ! `perl -e 'print "test"' 2> /dev/null` = "test" ]; then 180 180 echo 1>&2 "Please install perl." … … 185 185 } 186 186 187 # What type of system are we running on? 188 189 check_system_type() { 190 if [ ! "$ro_SYS_TYPE" = "" ]; then 191 return 0 192 elif [ -f /etc/debian_version ]; then 193 ro_SYS_TYPE=debian 194 ro_INIT_TYPE=sysv 195 elif [ -f /etc/gentoo-release ]; then 196 ro_SYS_TYPE=gentoo 197 ro_INIT_TYPE=sysv 198 elif [ -x /sbin/chkconfig ]; then 199 ro_SYS_TYPE=redhat 200 ro_INIT_TYPE=sysv 201 elif [ -x /sbin/insserv ]; then 202 ro_SYS_TYPE=suse 203 ro_INIT_TYPE=sysv 204 elif [ -f /etc/lfs-release -a -d /etc/rc.d/init.d ]; then 205 ro_SYS_TYPE=lfs 206 ro_INIT_TYPE=lfs 207 elif [ -f /etc/pardus-release ]; then 208 ro_SYS_TYPE=pardus 209 ro_INIT_TYPE=pardus 210 elif [ -f /etc/rc.d/rc.local ]; then 211 ro_SYS_TYPE=unknown 212 ro_INIT_TYPE=bsd 213 ro_RC_LOCAL=/etc/rc.d/rc.local 214 elif [ -f /etc/rc.local ]; then 215 ro_SYS_TYPE=unknown 216 ro_INIT_TYPE=bsd 217 ro_RC_LOCAL=/etc/rc.local 218 elif [ -d /etc/init.d ]; then 219 ro_SYS_TYPE=unknown 220 ro_INIT_TYPE=sysv 221 else # Perhaps we can determine what we need to know anyway though? 222 echo 1>&2 "Unable to determine your Linux distribution" 223 log "Unable to determine the Linux distribution" 224 return 1 225 fi 226 return 0 227 } 228 229 # Hack to handle Mandriva's speedboot runlevel 230 copy_install_script() { 231 if [ "$ro_INIT_TYPE" = "sysv" -a -r /etc/sysconfig/speedboot ]; then 232 cp "$1" "$2" 2>/dev/null 233 else 234 sed -e 's/^\(#\s*chkconfig:\s*[0-9]*\)7/\1/' "$1" > "$2" 235 fi 236 } 237 238 # Installs a file containing a shell script as an init script 239 # 240 # syntax: install_init_script file name 241 # 242 # where file is the file to be installed and 243 # name is the name of the new init script 244 245 install_init_script() { 187 ## Installs a file containing a shell script as an init script 188 install_init_script() 189 { 246 190 self="install_init_script" 247 script=$1 248 name=$2 249 pardus_script=$name-pardus.py 250 check_system_type 251 test $? -ne 1 || return 1 252 test -r "$script" || return 1 253 test ! "$name" = "" || \ 191 ## The init script to be installed. The file may be copied or referenced. 192 script="$1" 193 ## Name for the service. 194 name="$2" 195 test -x "$script" && test ! "$name" = "" || \ 254 196 { log "$self: invalid arguments" && return 1; } 255 if [ "$ro_INIT_TYPE" = "pardus" ];then 256 test -r "$pardus_script" || \ 257 { log "$self: Pardus service script missing" && return 1; } 258 fi 259 if [ "$ro_INIT_TYPE" = "sysv" ]; then 260 copy_install_script "$script" "/etc/init.d/$name" 197 if test -d /etc/rc.d/init.d 198 then 199 cp "$script" "/etc/rc.d/init.d/$name" 2> /dev/null 200 chmod 755 "/etc/rc.d/init.d/$name" 2> /dev/null 201 elif test -d /etc/init.d 202 then 203 cp "$script" "/etc/init.d/$name" 2> /dev/null 261 204 chmod 755 "/etc/init.d/$name" 2> /dev/null 262 elif [ "$ro_INIT_TYPE" = "bsd" ]; then 263 copy_install_script "$script" "/etc/rc.d/rc.$name" 264 chmod 755 "/etc/rc.d/rc.$name" 2> /dev/null 265 elif [ "$ro_INIT_TYPE" = "lfs" ]; then 266 copy_install_script "$script" "/etc/rc.d/init.d/$name" 267 chmod 755 "/etc/rc.d/init.d/$name" 2> /dev/null 268 elif [ "$ro_INIT_TYPE" = "pardus" ]; then 269 copy_install_script "$script" "/usr/sbin/$name" 270 chmod 755 "/usr/sbin/$name" 2> /dev/null 271 hav register $name System.Service $pardus_script 272 else 273 log "install_init_script: error: unknown init type" 274 return 1 275 fi 276 return 0 277 } 278 279 # Remove the init script "name" 280 # 281 # syntax: remove_init_script name 282 283 remove_init_script() { 205 else 206 log "${self}: error: unknown init type" 207 return 1 208 fi 209 return 0 210 } 211 212 ## Remove the init script "name" 213 remove_init_script() 214 { 284 215 self="remove_init_script" 285 name=$1 286 check_system_type 287 test $? -ne 1 || return 1 216 ## Name of the service to remove. 217 name="$1" 288 218 test ! "$name" = "" || \ 289 219 { log "$self: missing argument" && return 1; } 290 if [ "$ro_INIT_TYPE" = "sysv" ]; then 220 if test -d /etc/rc.d/init.d 221 then 222 rm -f "/etc/rc.d/init.d/$name" > /dev/null 2>&1 223 elif test -d /etc/init.d 224 then 291 225 rm -f "/etc/init.d/$name" > /dev/null 2>&1 292 elif [ "$ro_INIT_TYPE" = "bsd" ]; then 293 rm -f "/etc/rc.d/rc.$name" > /dev/null 2>&1 294 elif [ "$ro_INIT_TYPE" = "lfs" ]; then 295 rm -f "/etc/rc.d/init.d/$name" > /dev/null 2>&1 296 elif [ "$ro_INIT_TYPE" = "pardus" ]; then 297 hav remove $name 298 rm -f "/usr/sbin/$name" > /dev/null 2>&1 299 else 300 log "remove_init_script: error: unknown init type" 301 return 1 302 fi 303 return 0 304 } 305 306 # Start the init script "name" 307 # 308 # syntax: start_init_script name 309 310 start_init_script() { 311 self="start_init_script" 312 name=$1 313 check_system_type 314 test $? -ne 1 || return 1 315 test ! -z "$name" || \ 316 { log "$self: missing argument" && return 1; } 317 if [ "$ro_INIT_TYPE" = "sysv" ]; then 318 "/etc/init.d/$name" start >> $ro_LOG_FILE 2>&1 319 elif [ "$ro_INIT_TYPE" = "bsd" ]; then 320 "/etc/rc.d/rc.$name" start >> $ro_LOG_FILE 2>&1 321 elif [ "$ro_INIT_TYPE" = "lfs" ]; then 322 "/etc/rc.d/init.d/$name" start >> $ro_LOG_FILE 2>&1 323 elif [ "$ro_INIT_TYPE" = "pardus" ]; then 324 service $name on 325 else 326 log "$self: error: unknown init type" 327 return 1 328 fi 329 } 330 331 # Stop the init script "name" 332 # 333 # syntax: stop_init_script name 334 335 stop_init_script() { 336 self=stop_init_script 337 name=$1 338 check_system_type 339 test $? -ne 1 || return 1 340 test ! -z "$name" || \ 341 { log "$self: missing argument" && return 1; } 342 if [ "$ro_INIT_TYPE" = "sysv" ]; then 343 "/etc/init.d/$name" stop >> $ro_LOG_FILE 2>&1 344 elif [ "$ro_INIT_TYPE" = "bsd" ]; then 345 "/etc/rc.d/rc.$name" stop >> $ro_LOG_FILE 2>&1 346 elif [ "$ro_INIT_TYPE" = "lfs" ]; then 347 "/etc/rc.d/init.d/$name" stop >> $ro_LOG_FILE 2>&1 348 elif [ "$ro_INIT_TYPE" = "pardus" ]; then 349 service $name off 350 else 351 log "$self: error: unknown init type" 352 return 1 353 fi 354 return 0 355 } 356 357 # Add a service to a runlevel 358 # 359 # syntax: addrunlevel name start_order stop_order 360 361 addrunlevel() { 362 test ! -z "$1" || \ 363 { log "addrunlevel: missing argument(s)" && return 1; } 364 check_system_type 365 # Redhat based systems 366 if [ "$ro_SYS_TYPE" = "redhat" ] 367 then 368 test -x "/sbin/chkconfig" || \ 369 { log "addrunlevel: /sbin/chkconfig not found" && return 1; } 370 /sbin/chkconfig --del $1 > /dev/null 2>&1 371 372 if /sbin/chkconfig -v > /dev/null 2>&1; then 373 /sbin/chkconfig --level 35 $1 on || { 374 log "Cannot add $1 to run levels: 35" && return 1 375 } 226 else 227 log "${self}: error: unknown init type" 228 return 1 229 fi 230 return 0 231 } 232 233 ## Perform an action on a service 234 do_sysvinit_action() 235 { 236 self="do_sysvinit_action" 237 ## Name of service to start. 238 name="${1}" 239 ## The action to perform, normally "start", "stop" or "status". 240 action="${2}" 241 ## The optional expression to check for in the script before starting. 242 expression="${3}" 243 test ! -z "${name}" && test ! -z "${action}" || \ 244 { log "${self}: missing argument" && return 1; } 245 if test -x "/etc/rc.d/init.d/${name}" 246 then 247 script="/etc/rc.d/init.d/${name}" 248 elif test -x "/etc/init.d/${name}" 249 then 250 script="/etc/init.d/${name}" 251 else 252 log "${self}: error: unknown init type or unknown service ${name}" 253 return 1 254 fi 255 test -n "${expression}" && ! grep -q "${expression}" "${script}" && return 0 256 case "${action}" in 257 start|stop|reload|restart|try-restart|force-reload|status) 258 if test -x "`which service 2>/dev/null`" 259 then 260 service "${name}" ${action} 261 elif test -x "`which invoke-rc.d 2>/dev/null`" 262 then 263 invoke-rc.d "${name}" ${action} 376 264 else 377 /sbin/chkconfig $1 35 || { 378 log "Cannot add $1 to run levels: 35" && return 1 379 } 265 "${script}" "${action}" 380 266 fi 381 # SUSE-base systems 382 elif [ "$ro_SYS_TYPE" = "suse" ] 383 then 384 test -x /sbin/insserv || { 385 log "addrunlevel: insserv not found" && return 1; 267 ;; 268 *) 269 "${script}" "${action}" 270 ;; 271 esac 272 } 273 274 ## Start a service 275 start_init_script() 276 { 277 do_sysvinit_action "${1}" start 278 } 279 280 ## Stop the init script "name" 281 stop_init_script() 282 { 283 do_sysvinit_action "${1}" stop 284 } 285 286 ## Do initial setup of an installed service 287 setup_init_script() 288 { 289 do_sysvinit_action "${1}" setup '^# *setup_script *$' 290 } 291 292 ## Do pre-removal cleanup of an installed service 293 cleanup_init_script() 294 { 295 do_sysvinit_action "${1}" cleanup '^# *cleanup_script *$' 296 } 297 298 ## Extract chkconfig information from a sysvinit script. 299 get_chkconfig_info() 300 { 301 ## The script to extract the information from. 302 script="${1}" 303 set `sed -n 's/# *chkconfig: *\([0-9]*\) *\(.*\)/\1 \2/p' "${script}"` 304 ## Which runlevels should we start in? 305 runlevels="${1}" 306 ## How soon in the boot process will we start, from 00 (first) to 99 307 start_order="${2}" 308 ## How soon in the shutdown process will we stop, from 99 (first) to 00 309 stop_order="${3}" 310 test ! -z "${name}" || \ 311 { log "${self}: missing name" && return 1; } 312 expr "${start_order}" + 0 > /dev/null 2>&1 && \ 313 expr 0 \<= "${start_order}" > /dev/null 2>&1 && \ 314 test `expr length "${start_order}"` -eq 2 > /dev/null 2>&1 || \ 315 { log "${self}: start sequence number must be between 00 and 99" && return 1; } 316 expr "${stop_order}" + 0 > /dev/null 2>&1 && \ 317 expr 0 \<= "${stop_order}" > /dev/null 2>&1 && \ 318 test `expr length "${stop_order}"` -eq 2 > /dev/null 2>&1 || \ 319 { log "${self}: stop sequence number must be between 00 and 99" && return 1; } 320 return 0 321 } 322 323 ## Add a service to a runlevel 324 addrunlevel() 325 { 326 self="addrunlevel" 327 ## Service name. 328 name="${1}" 329 if test -x "/etc/rc.d/init.d/${name}" 330 then 331 init_d_path=/etc/rc.d 332 elif test -x "/etc/init.d/${name}" 333 then 334 init_d_path=/etc 335 else 336 log "${self}: error: unknown init type or unknown service ${name}" 337 return 1 338 fi 339 get_chkconfig_info "${init_d_path}/init.d/${name}" || return 1 340 # Redhat based sysvinit systems 341 if test -x "`which chkconfig 2>/dev/null`" 342 then 343 chkconfig --add "${name}" || { 344 log "Failed to set up init script ${name}" && return 1 386 345 } 387 /sbin/insserv -r $1 > /dev/null 2>&1 388 /sbin/insserv $1 > /dev/null 346 # SUSE-based sysvinit systems 347 elif test -x "`which insserv 2>/dev/null`" 348 then 349 insserv "${name}" > /dev/null 389 350 # Debian/Ubuntu-based systems 390 elif [ "$ro_SYS_TYPE" = "debian" ]; then 391 test -x `which update-rc.d` || \ 392 { log "addrunlevel: update-rc.d not found" && return 1; } 393 test ! -z "$2" || \ 394 { log "addrunlevel: missing second argument" && return 1; } 395 test ! -z "$3" || \ 396 { log "addrunlevel: missing third argument" && return 1; } 397 # Debian does not support dependencies currently -- use argument $2 398 # for start sequence number and argument $3 for stop sequence number 399 update-rc.d -f $1 remove > /dev/null 2>&1 400 update-rc.d $1 defaults $2 $3 > /dev/null 2>&1 351 elif test -x "`which update-rc.d 2>/dev/null`" 352 then 353 # Old Debians did not support dependencies 354 update-rc.d "${name}" defaults "${start_order}" "${stop_order}" \ 355 > /dev/null 2>&1 401 356 # Gentoo Linux 402 elif [ "$ro_SYS_TYPE" = "gentoo" ]; then 403 test -x `which rc-update` || \ 404 { log "addrunlevel: update-rc.d not found" && return 1; } 405 rc-update del $1 > /dev/null 2>&1 406 rc-update add $1 default > /dev/null 2>&1 407 # Linux from scratch, by the book 408 elif [ "$ro_SYS_TYPE" = "lfs" ]; then 409 test -x /etc/rc.d/init.d/$1 || \ 410 { log "addrunlevel: name argument must be a script in /etc/rc.d/init.d" && return 1; } 411 P2=$2 412 P3=$3 413 # add leading zero 414 if [ `expr length "$P2"` -eq 1 ]; then 415 P2=`expr 0$P2` 416 fi 417 if [ `expr length "$P3"` -eq 1 ]; then 418 P3=`expr 0$P3` 419 fi 420 expr "$P2" + 0 > /dev/null 2>&1 && expr 0 \<= "$P2" > /dev/null && \ 421 [ `expr length "$P2"` -eq 2 ] || \ 422 { log "addrunlevel: start sequence number must be between 00 and 99" && return 1; } 423 expr "$P3" + 0 > /dev/null 2>&1 && expr 0 \<= "$P3" > /dev/null && \ 424 [ `expr length "$P3"` -eq 2 ] || \ 425 { log "addrunlevel: stop sequence number must be between 00 and 99" && return 1; } 426 ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc0.d/K`expr $P3`$1" > /dev/null 2>&1 427 ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc1.d/K`expr $P3`$1" > /dev/null 2>&1 428 ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc2.d/S`expr $P2`$1" > /dev/null 2>&1 429 ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc3.d/S`expr $P2`$1" > /dev/null 2>&1 430 ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc4.d/S`expr $P2`$1" > /dev/null 2>&1 431 ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc5.d/S`expr $P2`$1" > /dev/null 2>&1 432 ln -fs "/etc/rc.d/init.d/$1" "/etc/rc.d/rc6.d/K`expr $P3`$1" > /dev/null 2>&1 433 # BSD-based systems require changing the rc.local file to start a new service. 434 elif [ "$ro_INIT_TYPE" = "bsd" ]; then 435 if ! grep -q $1 $ro_RC_LOCAL 436 then 437 echo "# Start $1" >> $ro_RC_LOCAL 438 echo "# If you do not wish this to be executed here then comment it out," >> $ro_RC_LOCAL 439 echo "# and the installer will skip it next time." >> $ro_RC_LOCAL 440 echo "if [ -x /etc/rc.d/rc.$1 ]; then" >> $ro_RC_LOCAL 441 echo " /etc/rc.d/rc.$1 start" >> $ro_RC_LOCAL 442 echo "fi" >> $ro_RC_LOCAL 443 echo "" >> $ro_RC_LOCAL 444 fi 445 # Probably most unknown Linux systems will be sysv type ones. These can theoretically 446 # be handled automatically if people give us information about them. 447 elif [ "$ro_INIT_TYPE" = "sysv" ]; then 448 echo 1>&2 "As our installer does not recognize your Linux distribution, we were unable to" 449 echo 1>&2 "set up the initialization script $1 correctly. The script has been copied" 450 echo 1>&2 "copied to the /etc/init.d directory. You should set up your system to start" 451 echo 1>&2 "it at system start, or start it manually before using VirtualBox." 452 echo 1>&2 "" 453 echo 1>&2 "If you would like to help us add support for your distribution, please open a" 454 echo 1>&2 "new ticket on http://www.virtualbox.org/wiki/Bugtracker." 455 fi 456 return 0 457 } 458 459 460 # Delete a service from a runlevel 461 # 462 # syntax: delrunlevel name 463 464 delrunlevel() { 465 test ! -z "$1" || \ 466 { log "delrunlevel: missing argument" && return 1; } 467 check_system_type 357 elif test -x "`which rc-update 2>/dev/null`"; then 358 rc-update add "${name}" default > /dev/null 2>&1 359 # Generic sysvinit 360 elif test -n "${init_d_path}/rc0.d" 361 then 362 for locali in 0 1 2 3 4 5 6 363 do 364 target="${init_d_path}/rc${locali}.d/K${stop_order}${name}" 365 expr "${runlevels}" : ".*${locali}" >/dev/null && \ 366 target="${init_d_path}/rc${locali}.d/S${start_order}${name}" 367 test -e "${init_d_path}/rc${locali}.d/"[KS][0-9]*"${name}" || \ 368 ln -fs "${init_d_path}/init.d/${name}" "${target}" 2> /dev/null 369 done 370 else 371 log "${self}: error: unknown init type" 372 return 1 373 fi 374 return 0 375 } 376 377 378 ## Delete a service from a runlevel 379 delrunlevel() 380 { 381 self="delrunlevel" 382 ## Service name. 383 name="${1}" 384 test ! -z "${name}" || \ 385 { log "${self}: missing argument" && return 1; } 468 386 # Redhat-based systems 469 if [ "$ro_SYS_TYPE" = "redhat" ] 470 then 471 test -x "/sbin/chkconfig" || \ 472 { log "delrunlevel: /sbin/chkconfig not found" && return 1; } 473 if /sbin/chkconfig --list $1 > /dev/null 2>&1; then 474 /sbin/chkconfig --del $1 > /dev/null 2>&1 || { 475 log "Cannot delete $1 from runlevels" && return 1 476 } 477 fi 478 # SUSE-based systems 479 elif [ "$ro_SYS_TYPE" = "suse" ] 480 then 481 test -x /sbin/insserv || { 482 log "delrunlevel: insserv not found" && return 1; 483 } 484 /sbin/insserv -r $1 > /dev/null 2>&1 387 if test -x "/sbin/chkconfig" 388 then 389 /sbin/chkconfig --del "${name}" > /dev/null 2>&1 390 # SUSE-based sysvinit systems 391 elif test -x /sbin/insserv 392 then 393 /sbin/insserv -r "${name}" > /dev/null 2>&1 485 394 # Debian/Ubuntu-based systems 486 elif [ "$ro_SYS_TYPE" = "debian" ]; then 487 test -x `which update-rc.d` || \ 488 { log "delrunlevel: update-rc.d not found" && return 1; } 489 update-rc.d -f $1 remove > /dev/null 2>&1 395 elif test -x "`which update-rc.d 2>/dev/null`" 396 then 397 update-rc.d -f "${name}" remove > /dev/null 2>&1 490 398 # Gentoo Linux 491 elif [ "$ro_SYS_TYPE" = "gentoo" ]; then 492 test -x `which rc-update` || \ 493 { log "delrunlevel: update-rc.d not found" && return 1; } 494 rc-update del "$1" > /dev/null 2>&1 495 # Linux from scratch, by the book 496 elif [ "$ro_SYS_TYPE" = "lfs" ]; then 497 rm "/etc/rc0.d/K??$1" > /dev/null 2>&1 498 rm "/etc/rc1.d/K??$1" > /dev/null 2>&1 499 rm "/etc/rc2.d/S??$1" > /dev/null 2>&1 500 rm "/etc/rc3.d/S??$1" > /dev/null 2>&1 501 rm "/etc/rc4.d/S??$1" > /dev/null 2>&1 502 rm "/etc/rc5.d/S??$1" > /dev/null 2>&1 503 rm "/etc/rc6.d/K??$1" > /dev/null 2>&1 504 # Unknown sysv-type system 505 elif [ "$ro_INIT_TYPE" = "sysv" ]; then 506 echo 1>&2 "Please remove remove references to the initialization script" 507 echo 1>&2 "/etc/init.d/$1 to complete the uninstallation." 508 fi 509 # BSD-type systems will just not start the script if it is not there. 510 # Assume that BSD users understand their system. 511 return 0 512 } 513 514 # Do initial setup of an installed service 515 # 516 # syntax: setup_init_script name 517 518 setup_init_script() 519 { 520 self=setup_init_script 521 name=$1 522 spaces=`printf " %b" "\t"` 523 check_system_type 524 test $? -ne 1 || return 1 525 test ! -z "$name" || 526 { log "$self: missing argument" && return 1; } 527 if [ "$ro_INIT_TYPE" = "sysv" ]; then 528 scriptname="/etc/init.d/$name" 529 elif [ "$ro_INIT_TYPE" = "bsd" ]; then 530 scriptname="/etc/rc.d/rc.$name" 531 elif [ "$ro_INIT_TYPE" = "lfs" ]; then 532 scriptname="/etc/rc.d/init.d/$name" 533 elif [ "$ro_INIT_TYPE" = "pardus" ]; then 534 scriptname="/usr/sbin/$name" 535 else 536 log "$self: error: unknown init type" 537 return 1 538 fi 539 # Add the init script to the default runlevel 540 # This is complicated by the fact that we need to pass older Debian-based 541 # systems the start and stop order numbers, which we extract from the 542 # Redhat chkconfig information. 543 if test "$ro_INIT_TYPE" = "sysv" -a -r "$scriptname"; then 544 orders=`grep '^#['"$spaces"']*chkconfig:' "$scriptname" | 545 sed -e 's/^#['"$spaces"']*chkconfig:['"$spaces"']*[0-9]*['"$spaces"']*//'` 546 expr "$orders" : '.*[0-9][0-9]*['"$spaces"']['"$spaces"']*[0-9][0-9]*$' > /dev/null || 547 { 548 log "$self: bad or missing chkconfig line in init script $scriptname" 549 return 1 550 } 551 # $orders is deliberately not quoted here 552 addrunlevel "$name" $orders 553 else 554 addrunlevel "$name" 555 fi 556 test -r "$scriptname" && 557 grep -q '^#['"$spaces"']*setup_script['"$spaces"']*$' "$scriptname" && 558 "$scriptname" setup 559 return 0 560 } 561 562 # Do pre-removal cleanup of an installed service 563 # 564 # syntax: cleanup_init_script name 565 566 cleanup_init() 567 { 568 self=cleanup_init_script 569 name=$1 570 spaces=`printf " %b" "\t"` 571 check_system_type 572 test $? -ne 1 || return 1 573 test ! -z "$name" || \ 574 { log "$self: missing argument" && return 1; } 575 if [ "$ro_INIT_TYPE" = "sysv" ]; then 576 scriptname="/etc/init.d/$name" 577 elif [ "$ro_INIT_TYPE" = "bsd" ]; then 578 scriptname="/etc/rc.d/rc.$name" 579 elif [ "$ro_INIT_TYPE" = "lfs" ]; then 580 scriptname="/etc/rc.d/init.d/$name" 581 elif [ "$ro_INIT_TYPE" = "pardus" ]; then 582 scriptname="/usr/sbin/$name" 583 else 584 log "$self: error: unknown init type" 585 return 1 586 fi 587 test -r "$scriptname" && 588 grep -q '^#['"$spaces"']*cleanup_script['"$spaces"']*$' "$scriptname" && 589 "$scriptname" cleanup >> $ro_LOG_FILE 2>&1 590 delrunlevel "$name" 399 elif test -x "`which rc-update 2>/dev/null`" 400 then 401 rc-update del "${name}" > /dev/null 2>&1 402 # Generic sysvinit 403 elif test -d /etc/rc.d/init.d 404 then 405 rm /etc/rc.d/rc?.d/[SK]??"${name}" > /dev/null 2>&1 406 elif test -d /etc/init.d 407 then 408 rm /etc/rc?.d/[SK]??"${name}" > /dev/null 2>&1 409 else 410 log "${self}: error: unknown init type" 411 return 1 412 fi 591 413 return 0 592 414 } … … 594 416 595 417 terminate_proc() { 596 PROC_NAME= $1418 PROC_NAME="${1}" 597 419 SERVER_PID=`pidof $PROC_NAME 2> /dev/null` 598 420 if [ "$SERVER_PID" != "" ]; then … … 604 426 605 427 maybe_run_python_bindings_installer() { 606 VBOX_INSTALL_PATH= $1428 VBOX_INSTALL_PATH="${1}" 607 429 608 430 PYTHON=python … … 621 443 return 0 622 444 } 623 -
trunk/src/VBox/Installer/linux/run-inst.sh
r56299 r56777 151 151 for i in $UNINSTALL_SCRIPTS; do 152 152 stop_init_script "$i" 153 cleanup_init "$i" 1>&2 2>> "$LOGFILE"153 cleanup_init_script "$i" 1>&2 2>> "$LOGFILE" 154 154 test -x "./$i" && "./$i" cleanup 1>&2 2>> "$LOGFILE" 155 delrunlevel "$i" 155 156 remove_init_script "$i" 156 157 done … … 419 420 if test -r "$i"; then 420 421 install_init_script "$i" "`basename "$i"`" 422 addrunlevel "`basename "$i"`" 421 423 test -n "$DO_SETUP" && setup_init_script "`basename "$i"`" 1>&2 422 424 start_init_script "`basename "$i"`" … … 459 461 if test -r "\$i"; then 460 462 stop_init_script "\`basename "\$i"\`" 461 test -z "\$NO_CLEANUP" && cleanup_init "\`basename "\$i"\`" 2>> "\$LOGFILE" 463 test -z "\$NO_CLEANUP" && cleanup_init_script "\`basename "\$i"\`" 2>> "\$LOGFILE" 464 delrunlevel "\`basename "\$i"\`" 462 465 remove_init_script "\`basename "\$i"\`" 463 466 fi
Note:
See TracChangeset
for help on using the changeset viewer.