VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/installer/runlevel.sh@ 52

Last change on this file since 52 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1#! /bin/bash
2# InnoTek VirtualBox
3# Linux Additions add/delete init script
4#
5# Copyright (C) 2006 InnoTek Systemberatung GmbH
6#
7# This file is part of VirtualBox Open Source Edition (OSE), as
8# available from http://www.virtualbox.org. This file is free software;
9# you can redistribute it and/or modify it under the terms of the GNU
10# General Public License as published by the Free Software Foundation,
11# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
12# distribution. VirtualBox OSE is distributed in the hope that it will
13# be useful, but WITHOUT ANY WARRANTY of any kind.
14#
15# If you received this file as part of a commercial VirtualBox
16# distribution, then only the terms of your commercial VirtualBox
17# license agreement apply instead of the previous paragraph.
18
19runlevels=35
20
21system=unknown
22if [ -f /etc/redhat-release ]; then
23 system=redhat
24 util=$(type -p /sbin/chkconfig)
25elif [ -f /etc/SuSE-release ]; then
26 system=suse
27 util=$(type -p /sbin/chkconfig)
28elif [ -f /etc/debian_version ]; then
29 system=debian
30 util=$(type -p update-rc.d)
31elif [ -f /etc/gentoo-release ]; then
32 system=gentoo
33 util=$(type -p rc-update)
34else
35 echo "$0: Unknown system" 1>&2
36fi
37
38if [ -z $util ];then
39 echo Could not find add/remove init scripts to a runlevel utility 1>&2
40 echo This operation can not continue without it 1>&2
41 exit 1
42fi
43
44fail() {
45 echo "$1"
46 exit 1
47}
48
49
50addrunlevel() {
51 if [ $system == "redhat" ] || [ $system == "suse" ]; then
52 $util --del $1 >&/dev/null
53
54 if $util -v &>/dev/null; then
55 $util --level $runlevels $1 on || {
56 fail "Cannot add $1 to run levels: $runlevels"
57 }
58 else
59 $util $1 $runlevels || {
60 fail "Cannot add $1 to run levels: $runlevels"
61 }
62 fi
63 elif [ $system == "debian" ]; then
64 # Debian does not support dependencies currently -- use argument $2
65 # for start sequence number and argument $3 for stop sequence number
66 $util -f $1 remove >&/dev/null
67 $util $1 defaults $2 $3 >&/dev/null
68 elif [ $system == "gentoo" ]; then
69 $util del $1 >&/dev/null
70 $util add $1 default >&/dev/null
71 fi
72}
73
74
75delrunlevel() {
76 if [ $system == "redhat" ] || [ $system == "suse" ]; then
77 if $util --list $1 >& /dev/null; then
78 $util --del $1 >& /dev/null || {
79 fail "Cannot delete $1 from runlevels"
80 }
81 fi
82 elif [ $system == "debian" ]; then
83 $util -f $1 remove >&/dev/null
84 elif [ $system == "gentoo" ]; then
85 $util del $1 >&/dev/null
86 fi
87}
88
89
90usage() {
91 echo "Usage: $0 {add|del} script"
92 exit 1
93}
94
95
96# Test for second argument
97test -z $2 && {
98 usage
99}
100
101case "$1" in
102add)
103 addrunlevel $2 $3 $4
104 ;;
105del)
106 delrunlevel $2
107 ;;
108*)
109 usage
110esac
111
112exit
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette